3

Papermill throws exception if I need to finish the code earlier. For example with quit():

nbclient.exceptions.DeadKernelError: Kernel died

I would like to know if there is a way to instruct the code exit without papermill throwing the exception.

Example:

# check conditions if all met then run full notebook
# if not, then just finish

condition1=True

if condition1:
    quit() # if condition is not met then finish here

print('continue the logic')
Luis R. Gonzalez
  • 358
  • 3
  • 16
  • Are you running papermill inside the Notebook using Python ? Why don't you catch the exception with try/except? – gogasca Sep 17 '20 at 20:44
  • I am running the notebook with papermill in a shell; the difference here is the notebook might need to finish earlier the execution, not going to complete the entire notebook; when that happens papermill throws exception described in the question. Want the notebook execution to stop if condition not met and papermill to do not throw exception. – Luis R. Gonzalez Sep 18 '20 at 22:12
  • You can try this: https://stackoverflow.com/questions/55478353/bash-script-with-multiple-papermill-commands-does-not-fail-on-notebook-errors. Basically papermill will return a non-zero exit code which you can catch with shell $? – gogasca Sep 19 '20 at 06:18

0 Answers0