Skip to content

Commit dca2328

Browse files
FIX: Fix warning message for missing rail buttons and fins
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.
1 parent 1f828b9 commit dca2328

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

rocketserializer/nb_builder.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,16 +389,14 @@ def build_fins(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
389389
pass
390390
# free form fins
391391
# checking if fins were added
392-
try:
393-
assert fin_counter > 0
392+
if fin_counter > 0:
394393
logger.info(
395394
"[NOTEBOOK BUILDER] %s fins were added to the rocket.", fin_counter
396395
)
397-
except AssertionError:
398-
text = "No fins were added to the rocket. Please add at least one."
396+
else:
397+
text = "# No fins were added to the rocket. Check parameters.json."
399398
nb["cells"].append(nbf.v4.new_code_cell(text))
400-
logger.warning("No fins were added to the rocket. Please add at least one.")
401-
raise Warning("No fins were added to the rocket. Please add at least one.")
399+
logger.warning("No fins were added to the rocket. Check parameters.json")
402400
return nb
403401

404402
def build_tails(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
@@ -437,6 +435,13 @@ def build_rail_buttons(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
437435
# add a markdown cell
438436
text = "### Rail Buttons\n"
439437
nb["cells"].append(nbf.v4.new_markdown_cell(text))
438+
439+
if not self.parameters["rail_buttons"]:
440+
text = "# No rail buttons were added to the rocket."
441+
nb["cells"].append(nbf.v4.new_code_cell(text))
442+
logger.warning("No rail buttons were added to the rocket.")
443+
return nb
444+
440445
rail_button_i = self.parameters["rail_buttons"]
441446
upper_position = rail_button_i["upper_position"]
442447
lower_position = rail_button_i["lower_position"]

0 commit comments

Comments
 (0)