Skip to content

Commit

Permalink
fix raise_exception
Browse files Browse the repository at this point in the history
  • Loading branch information
HollowPrincess committed Aug 25, 2023
1 parent f8c9e6e commit 3c6dcb9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions nbtools/run_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,6 @@ def run_notebook(path, inputs=None, outputs=None, inputs_pos=1, replace_inputs_p
if outputs is not None:
executor.kc = kernel_manager.client() # For compatibility with 5.x.x version of `nbconvert`
executor.preprocess_cell(output_cell, {'metadata': {'path': working_dir}}, -1)

if raise_exception:
raise
finally:
# Shutdown kernel
kernel_manager.cleanup_resources()
Expand All @@ -337,6 +334,10 @@ def run_notebook(path, inputs=None, outputs=None, inputs_pos=1, replace_inputs_p
for path_ in db_paths:
os.remove(path_)

# Re-raise exception if needed
if failed and raise_exception:
raise Exception(traceback_message)

# Prepare execution results: execution state, notebook outputs and error info (if exists)
if failed:
exec_res = {'failed': failed, 'failed cell number': error_cell_num, 'traceback': traceback_message}
Expand Down

0 comments on commit 3c6dcb9

Please sign in to comment.