I have a set-up whereby I have a few Jupyter notebooks that are parameterised so I can run them from another notebook.
I'm using the papermill
module to do this which is quite convenient. The simplest way of running looks something like this
path = '/path/to/notebook.ipynb'
pm.execute_notebook(
path,
path,
)
What I would now like is to have the ability of halting execution from within the notebook being run if certain conditions are not met.
Is there a way of doing this with papermill and, if not, is there another module that can do this?
I would just use
assert not failure_condition, "My condition failed"
inside the notebook to force an exception to be raised. This will halt execution and raise an exception that papermill will wrap in aPapermillExecutionError
in the parent process which calledpm.execute_notebook
.