Skip to content

Conversation

@Gui-FernandesBR
Copy link
Member

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • 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

See #773

New behavior

Simple message added, I hope this helps future users

Breaking change

  • No

Additional information

Enter text here...

@Gui-FernandesBR Gui-FernandesBR self-assigned this Mar 3, 2025
@Gui-FernandesBR Gui-FernandesBR requested a review from a team as a code owner March 3, 2025 22:47
@Gui-FernandesBR Gui-FernandesBR linked an issue Mar 3, 2025 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Mar 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.10%. Comparing base (83aa20e) to head (ab3320c).
Report is 21 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #776      +/-   ##
===========================================
+ Coverage    76.42%   80.10%   +3.68%     
===========================================
  Files           95       96       +1     
  Lines        11090    11368     +278     
===========================================
+ Hits          8475     9106     +631     
+ Misses        2615     2262     -353     

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +656 to +659
try:
self.static_margin.set_discrete(
lower=0, upper=self.motor.burn_out_time, samples=200
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with the PR since it solves a real and important issue. However, there are a few things I believe it might be worthwhile pointing out:

  • How do we determine whether a method/attribute is important enough to have an explicit exception message? Of course, in this PR the static_margin involves loads of calculations using other parameters, but I find it hard to pinpoint when it should have the exception handling.
  • I like that this exception message points to some potential attributes that are sources of the issue. However, the core of the message (i.e. f"Error in parameter {x}, check inputs.") is almost so generic that it could be applied everywhere in RocketPy. Should we even raise these kinds of exceptions?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe you're "overcomplicating" the situation a little bit.

I like to think this way: Regression! If someone faced an issue while running a simulation, in order to avoid future users to face the same problem, I'm adding a more delicate message suggesting what is probably wrong in the code.

The reason we don't do that for every input? Simple: because no one has complained about other inputs yet.
Try to read #773, you're going to see that the source of the error is quite silent, so a message like this can guide the user to quickly find where to look in the code.
If the input is clearly wrong, for example, someone sets a negative mass to the rocket, I think that would be the case we wouldn't require much effort from our team (or the user) to identify the error source. However the case of this PR is particularly trickly given that everything was properly set in the simulation, but rocketpy only crashed because we couldn't perform a single operation.

Additionally, the try/catch block barely changes the execution time, so I see almost no problem of doing so.

Lemme know ehat you think about it.

@MateusStano
Copy link
Member

In the end, what exactly was causing the computation to break? Simulating with burn time longer then the provided curves should not break things in theory right?

We really have to turn the static margin calculation into something lazy. There is no need to have this calculated for the simulation, it should only be computed when needed

@Gui-FernandesBR
Copy link
Member Author

In the end, what exactly was causing the computation to break? Simulating with burn time longer then the provided curves should not break things in theory right?

We really have to turn the static margin calculation into something lazy. There is no need to have this calculated for the simulation, it should only be computed when needed

@MateusStano the way the user have set the hybrid motor made the center of mass function undefined after ~14s.
I think it is a particular case, it is almost as if he cooked the example to break the static margin on rocketpy

@Gui-FernandesBR
Copy link
Member Author

@phmbressan @MateusStano I'm re-requesting the review on this PR. I believe we are "almost done" here

@github-project-automation github-project-automation bot moved this from Backlog to Closed in LibDev Roadmap Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

Bug Report: Runtime Error in RocketPy's add_motor Function

4 participants