Skip to content

Commit

Permalink
FIX: Fix warning message for missing rail buttons and fins
Browse files Browse the repository at this point in the history
This commit adds a warning message to the `NotebookBuilder` class in `nb_builder.py` to handle cases where no rail buttons or fins are added to the rocket. The warning message is displayed in the notebook and logged to provide feedback to the user.

The commit message follows the established convention of using a prefix to indicate the type of change (`chore` for a chore or maintenance task) and provides a clear and concise description of the purpose of the code changes.
  • Loading branch information
Gui-FernandesBR committed Jun 15, 2024
1 parent 1f828b9 commit dca2328
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions rocketserializer/nb_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,14 @@ def build_fins(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
pass
# free form fins
# checking if fins were added
try:
assert fin_counter > 0
if fin_counter > 0:
logger.info(
"[NOTEBOOK BUILDER] %s fins were added to the rocket.", fin_counter
)
except AssertionError:
text = "No fins were added to the rocket. Please add at least one."
else:
text = "# No fins were added to the rocket. Check parameters.json."
nb["cells"].append(nbf.v4.new_code_cell(text))
logger.warning("No fins were added to the rocket. Please add at least one.")
raise Warning("No fins were added to the rocket. Please add at least one.")
logger.warning("No fins were added to the rocket. Check parameters.json")
return nb

def build_tails(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
Expand Down Expand Up @@ -437,6 +435,13 @@ def build_rail_buttons(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
# add a markdown cell
text = "### Rail Buttons\n"
nb["cells"].append(nbf.v4.new_markdown_cell(text))

if not self.parameters["rail_buttons"]:
text = "# No rail buttons were added to the rocket."
nb["cells"].append(nbf.v4.new_code_cell(text))
logger.warning("No rail buttons were added to the rocket.")
return nb

rail_button_i = self.parameters["rail_buttons"]
upper_position = rail_button_i["upper_position"]
lower_position = rail_button_i["lower_position"]
Expand Down

0 comments on commit dca2328

Please sign in to comment.