GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ENH: Expansion of Encoders Implementation for Full Flights. by phmbressan · Pull Request #679 · RocketPy-Team/RocketPy

Conversation

@phmbressan

@phmbressan phmbressan commented Aug 30, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added (partially done)
  • Docs have been reviewed and added / updated (future PR)
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

Currently the _encoding module is just a stub and cannot still encode full simulations into a JSON like format.

New behavior

This PR expand this module bringing the following:

  • Custom Encoding for more types;
  • Customized behavior for some required classes with methods to_dict;
  • Support for Function encoding.

This PR also introduces decoding functionalities. The way this works is:

  • If the is a to_dict or from_dict method, they are used to perform the (de)encoding;
  • Otherwise, a default encoding of all vars() and constructor based decoding is done.

Breaking change

  • Yes
  • No

Additional information

There is much to discuss here on the implementation and maintainability side of things. Main discussion points:

  • Should we add a to_dict and (in the future) a from_dict method to some (or all) rocketpy classes?
    • My Opinion: I think adding the methods to everything might be the only way out. But there is some work and maintainability considerations.
  • The current status of the encoding can be fully deserialized?
    • My Opinion: All the information is there, but the typing should be improved to know which objects to decode (deserialize) into. For that reason, I kept the _encoders private.
  • Are there any other modules to make our work easier?
    • From my research, I have tested the following:
      • simplejson: brings some more types and speed into encoding, but does not help much with custom types;
      • jsonpickle: really great for the typing handler (already writes by default each object type) and is able to serialize. The problem is that is does not handle functions/lambdas and I did not find a good way to implement custom handlers for our use case;
      • pickle / dill: the most plug and play solution, however the output is not human readable and not generally compatible between different rocketpy versions.

Of course, this is what I understood upon researching and testing, feel free to make any comments or suggest other modules.

Remarks and Future Considerations

Here are some of the steps that could be improved:

  • Verify why the test for hybrid motor flight requires higher tolerances;
    • Corrected, no higher tolerances needed anymore.
  • Test if all of the atmospheric models of Environments can be decoded without requiring re-read of files or API;
  • Evaluate whether we should encode outputs or only the minimum required information to decode the class from its init;
    • Option for including outputs or not was added.
  • (Optional) Expand implementation to AirBrakes + Controllers and new classes.

Some important remarks:

  • The simple getting started simulation is essentially identical comparing the store & load, the only difference is the random lag and noise from Parachute class. I could not found a simple solution to reset those and always get the same results.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@phmbressan phmbressan added the Enhancement New feature or request, including adjustments in current codes label Aug 30, 2024
@phmbressan phmbressan added this to the Release v1.X.0 milestone Aug 30, 2024
@phmbressan phmbressan self-assigned this Aug 30, 2024
@phmbressan
phmbressan requested a review from a team as a code owner August 30, 2024 21:32
@codecov

codecov Bot commented Aug 30, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 70.58824% with 115 lines in your changes missing coverage. Please review.

Project coverage is 76.34%. Comparing base (83aa20e) to head (c389519).
Report is 10 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/rocket/rocket.py 43.58% 22 Missing ⚠️
rocketpy/environment/environment.py 59.61% 21 Missing ⚠️
rocketpy/_encoders.py 78.18% 12 Missing ⚠️
rocketpy/motors/tank_geometry.py 64.51% 11 Missing ⚠️
...ocketpy/rocket/aero_surface/fins/free_form_fins.py 33.33% 6 Missing ⚠️
rocketpy/rocket/parachute.py 71.42% 6 Missing ⚠️
rocketpy/motors/tank.py 87.80% 5 Missing ⚠️
...cketpy/rocket/aero_surface/fins/elliptical_fins.py 37.50% 5 Missing ⚠️
rocketpy/rocket/components.py 37.50% 5 Missing ⚠️
rocketpy/simulation/flight.py 37.50% 5 Missing ⚠️
... and 9 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #679      +/-   ##
===========================================
- Coverage    76.42%   76.34%   -0.08%     
===========================================
  Files           95       96       +1     
  Lines        11090    11460     +370     
===========================================
+ Hits          8475     8749     +274     
- Misses        2615     2711      +96     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Gui-FernandesBR
Gui-FernandesBR approved these changes Sep 12, 2024
View reviewed changes

@Gui-FernandesBR Gui-FernandesBR left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to complain about, good work.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread requirements.txt Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread rocketpy/mathutils/function.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread rocketpy/rocket/components.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@phmbressan phmbressan mentioned this pull request Sep 22, 2024
ENH: Simulation Save and Load in JSON Files #695
Merged
7 of 12 tasks
@phmbressan
phmbressan requested a review from MateusStano November 12, 2024 07:57
@phmbressan

phmbressan commented Nov 12, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

I have just noticed that I made a mistake when merging CHANGELOG conflicts for this PR.

I will fix it before merging. This does not block reviewing.

  • Fix CHANGELOG.md merging errors.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Gui-FernandesBR
Gui-FernandesBR self-requested a review November 13, 2024 03:32
Gui-FernandesBR
Gui-FernandesBR reviewed Nov 13, 2024
View reviewed changes
Comment thread rocketpy/_encoders.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Gui-FernandesBR
Gui-FernandesBR reviewed Nov 13, 2024
View reviewed changes
Comment thread rocketpy/motors/fluid.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

MateusStano
MateusStano reviewed Nov 13, 2024
View reviewed changes

@MateusStano MateusStano left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall comments:

  • to_dict and from_dict methods are missing docstrings in all classes

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread rocketpy/simulation/flight.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread rocketpy/motors/tank_geometry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread rocketpy/_encoders.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Gui-FernandesBR

Gui-FernandesBR commented Nov 13, 2024

Copy link
Copy Markdown
Member

Overall comments:

  • to_dict and from_dict methods are missing docstrings in all classes

I strongly advise to not include dosctrings yet.
We don't really know if these methods will really be used.

Also, they exists mainly for private reasons: we need them in order have the JSONEncoder working.

Btw the methods are so simple that they don't even need docstrings. But that's a discussion for future sessions...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Gui-FernandesBR
Gui-FernandesBR reviewed Nov 17, 2024
View reviewed changes
Comment thread rocketpy/environment/environment.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Gui-FernandesBR
Gui-FernandesBR reviewed Nov 17, 2024
View reviewed changes
Comment thread rocketpy/environment/environment.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Gui-FernandesBR
Gui-FernandesBR reviewed Nov 17, 2024
View reviewed changes
Comment thread rocketpy/environment/environment.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Gui-FernandesBR
Gui-FernandesBR reviewed Nov 17, 2024
View reviewed changes

@Gui-FernandesBR Gui-FernandesBR left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last test we could run is: Create a Monte Carlo simulation with 100 simulations and verify if the output .txt files are still readable enough.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

phmbressan reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@Gui-FernandesBR Gui-FernandesBR linked an issue Nov 23, 2024 that may be closed by this pull request
ENH: make rocketpy classes json serializable #522
Closed
@phmbressan
phmbressan force-pushed the enh/sim-encoding branch from c8e1682 to 7834947 Compare December 7, 2024 14:36
@phmbressan

phmbressan commented Dec 7, 2024

Copy link
Copy Markdown
Collaborator Author

One last test we could run is: Create a Monte Carlo simulation with 100 simulations and verify if the output .txt files are still readable enough.

Good point. I have added some customization options to MonteCarlo so that one can choose whether to include all Function data or keep the way it is currently on develop that is only the Function string.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Gui-FernandesBR
Gui-FernandesBR force-pushed the develop branch from fe27050 to f1b57ef Compare December 8, 2024 02:06
phmbressan added 2 commits December 20, 2024 03:43
@phmbressan @Gui-FernandesBR
ENH: expand encoders implementation to support full flights.
07032f3
MNT: Add encoding feature to CHANGELOG.

BUG: add dill to the requirements file.
@phmbressan @Gui-FernandesBR
ENH: provide from_dict classmethods for decoding basic classes.
a57567d
ENH: extend encoding and decoding to Liquid and Hybrid.

MNT: correct decoding of liquid and hybrid motors.

STY: solve pylint remarks.

MNT: adapt encoding to new post merge attributes.

MNT: restore typo to correct values on flight test.

ENH: add option for including outputs on JSON export.

TST: add tests for motor encoding.

DOC: Improve docstrings of encoders signature.

MNT: Make no output encoding the default.

MNT: Standardize include outputs parameter.

DOC: Correct phrasing and typos of encoders docstring.

MNT: Correct json export environment naming.
@Gui-FernandesBR
Gui-FernandesBR force-pushed the enh/sim-encoding branch from 006f6a9 to c79930b Compare December 20, 2024 06:46
Gui-FernandesBR
Gui-FernandesBR requested changes Dec 20, 2024
View reviewed changes

@Gui-FernandesBR Gui-FernandesBR left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phmbressan just a few more conversations need to be solved.

The PR looks good btw.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@phmbressan
MNT: Allow for encoding customization of MonteCarlo.
c389519
DEV: fix CHANGELOG

MNT: reposition barometric height as env json output.

MNT: Allow for encoding customization of MonteCarlo.
@phmbressan
phmbressan force-pushed the enh/sim-encoding branch from c79930b to c389519 Compare December 20, 2024 19:02
Gui-FernandesBR
Gui-FernandesBR approved these changes Dec 20, 2024
View reviewed changes

@Gui-FernandesBR Gui-FernandesBR left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, amazing work @phmbressan .

@GabrielBarberini should be interested in this feature. Please notice this is not a part of the public API!!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

GabrielBarberini reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@phmbressan
phmbressan merged commit cbbdb65 into develop Dec 21, 2024
@phmbressan
phmbressan deleted the enh/sim-encoding branch December 21, 2024 09:23
juliomachad0 pushed a commit that referenced this pull request Jan 14, 2025
@phmbressan @juliomachad0
ENH: Expansion of Encoders Implementation for Full Flights. (#679)
6f73dcc
* ENH: expand encoders implementation to support full flights.

MNT: Add encoding feature to CHANGELOG.

BUG: add dill to the requirements file.

* ENH: provide from_dict classmethods for decoding basic classes.

ENH: extend encoding and decoding to Liquid and Hybrid.

MNT: correct decoding of liquid and hybrid motors.

STY: solve pylint remarks.

MNT: adapt encoding to new post merge attributes.

MNT: restore typo to correct values on flight test.

ENH: add option for including outputs on JSON export.

TST: add tests for motor encoding.

DOC: Improve docstrings of encoders signature.

MNT: Make no output encoding the default.

MNT: Standardize include outputs parameter.

DOC: Correct phrasing and typos of encoders docstring.

MNT: Correct json export environment naming.

* MNT: Allow for encoding customization of MonteCarlo.

DEV: fix CHANGELOG

MNT: reposition barometric height as env json output.

MNT: Allow for encoding customization of MonteCarlo.
Gui-FernandesBR pushed a commit that referenced this pull request Jan 19, 2025
@phmbressan @Gui-FernandesBR
ENH: Expansion of Encoders Implementation for Full Flights. (#679)
ce8b26d
* ENH: expand encoders implementation to support full flights.

MNT: Add encoding feature to CHANGELOG.

BUG: add dill to the requirements file.

* ENH: provide from_dict classmethods for decoding basic classes.

ENH: extend encoding and decoding to Liquid and Hybrid.

MNT: correct decoding of liquid and hybrid motors.

STY: solve pylint remarks.

MNT: adapt encoding to new post merge attributes.

MNT: restore typo to correct values on flight test.

ENH: add option for including outputs on JSON export.

TST: add tests for motor encoding.

DOC: Improve docstrings of encoders signature.

MNT: Make no output encoding the default.

MNT: Standardize include outputs parameter.

DOC: Correct phrasing and typos of encoders docstring.

MNT: Correct json export environment naming.

* MNT: Allow for encoding customization of MonteCarlo.

DEV: fix CHANGELOG

MNT: reposition barometric height as env json output.

MNT: Allow for encoding customization of MonteCarlo.
@phmbressan phmbressan mentioned this pull request Apr 21, 2025
BUG: Fix the handling of reference pressure for older rpy files. #808
Merged
4 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@MateusStano MateusStano MateusStano left review comments
@Gui-FernandesBR Gui-FernandesBR Gui-FernandesBR approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@phmbressan phmbressan

Labels

Enhancement New feature or request, including adjustments in current codes

Projects

No open projects
LibDev Roadmap
Status: Closed

Milestone

Release v1.X.0

Development

Successfully merging this pull request may close these issues.

ENH: make rocketpy classes json serializable

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@phmbressan @Gui-FernandesBR @MateusStano
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.