Debug#
ploomber-engine allows you to start a debugging session right after your notebook crashes.
Example#
Install requirements:
%pip install ploomber-engine papermill ipykernel --quiet
Note: you may need to restart the kernel to use updated packages.
Download sample notebook:
%%sh
curl https://raw.githubusercontent.com/ploomber/ploomber-engine/main/tests/assets/crash.ipynb --output debug-demo.ipynb
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 2376 100 2376 0 0 13807 0 --:--:-- --:--:-- --:--:-- 13813
Run the notebook with the --engine debug
option to enable debugging. Upon crashing, a debugging session will start:
papermill crash.ipynb tmp.ipynb --engine debug
Note
Currently, the debug
engine is only available via papermill
, in a future release, it’ll be possible to use it without it.
Sample debugging session:
Input Notebook: crash.ipynb
Output Notebook: tmp.ipynb
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
Input In [2], in <cell line: 3>()
1 x = 1
2 y = 0
----> 3 x/y
ZeroDivisionError: division by zero
> /var/folders/3h/_lvh_w_x5g30rrjzb_xnn2j80000gq/T/ipykernel_64532/3136424576.py(3)<cell line: 3>()
1 x = 1
2 y = 0
----> 3 x/y
ipdb>