I am running a python cli tool, Papermill. I am running jupyter notebooks and want to be able to detect assertionErrors when the notebook are ran. When I run papermill from a bash script I always get a 0 exit code, even when there is a python error in the notebook.
I've found methods for detecting the exit code which work, but python errors are not throwing any codes
For example: in my nbTest.sh I am running the notebook and looking for an error
papermill python_notebooks/testing/$d python_notebooks/testing/results/$d.results.ipynb || True
if [ $? -eq 0 ]
then
echo "Successfully executed script"
else
# Redirect stdout from echo command to stderr.
echo "Script exited with error."
fi
done
and as output I am getting:
.
.
.
Input Notebook: python_notebooks/testing/paperTest.ipynb
Output Notebook: python_notebooks/testing/results/paperTest.ipynb.results.ipynb
83%|████████▎ | 5/6 [00:00<00:00, 1.97it/s]
Traceback (most recent call last):
...
---------------------------------------------------------------------------
Exception encountered at "In [5]":
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-5-d941c6663321> in <module>()
----> 1 assert passed == False
AssertionError:
Successfully executed script
I would expect an exit code of 1 but python failures aren't handled