a python debugger for jupyter notebooks
Project description
jupydebug
This package provides easy access to all objects throughout an Exception traceback stack. It mimics the behavior of the post_mortem function in Python's built-in debugger (pdb), but let's the user interact with traceback object directly within a jupyter notebook as opposed to the pdb interpreter. Following an exception, run post_mortem() to inspect frames from the traceback stack. For example:
a_failing_test()
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-14-ac3ec94daf8d> in <module>()
----> 1 a_failing_test()
/home/dan/Documents/jupydebug/tests/conftest.py in nested_test()
28 def nested_test():
29 nf_local_var = "nested_test's_local_var"
---> 30 return parent_test(failing_test)
31
32
/home/dan/Documents/jupydebug/tests/conftest.py in parent_test(func, *args, **kwargs)
23 def parent_test(func, *args, **kwargs):
24 pf_local_var = "parent test's local var"
---> 25 return func(*args, **kwargs)
26
27
/home/dan/Documents/jupydebug/tests/conftest.py in failing_test()
10 a_local_var = "failing_test's local var"
11 x = range(3)
---> 12 y = x[3] # this will raise an exception
13 return y
14
IndexError: range object index out of range
get access to the traceback stack with jupydebug's post_mortem function:
frames = jpdb.post_mortem()
inspect the stack:
frames
| file | line | calling | locals | |
|---|---|---|---|---|
| 0 | /home/dan/Documents/jupydebug/tests/conftest.py | 12 | failing_test | (a_local_var, x) |
| 1 | /home/dan/Documents/jupydebug/tests/conftest.py | 25 | parent_test | (func, args, kwargs, pf_local_var) |
| 2 | /home/dan/Documents/jupydebug/tests/conftest.py | 30 | nested_test | (nf_local_var) |
| 3 | <ipython-input-12-ac3ec94daf8d> | 1 | <module> | (__name__, __doc__, __package__, __loader__, __spec__, __builtin__, __builtins__, _ih, _oh, _dh, _sh, In, Out, get_ipython, exit, quit, _, __, ___, sys, _i, _ii, _iii, _i1, context, jpdb, conftest, _i2, contexts, _i3, _3, _i4, _i5, _i6, _6, _i7, debugger, _7, _i8, _8, _i9, _i10, _i11, a_failing_test, _i12, _i13, _13, _i14, df, _i15, _15, _i16) |
| 4 | /home/dan/miniconda3/envs/jupydebug/lib/python3.7/site-packages/IPython/core/interactiveshell.py | 2898 | run_code | (self, code_obj, result, old_excepthook, outflag) |
and access the local or global variables in each frame with e.g.
frames[0].locals
{'a_local_var': "failing_test's local var", 'x': range(0, 3)}
frames[0].globals
{'__name__': 'conftest',
'__doc__': None,
'__package__': '',
'__loader__': <_frozen_importlib_external.SourceFileLoader at 0x7fac7027d990>,
'__spec__': ModuleSpec(name='conftest', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fac7027d990>, origin='/home/dan/Documents/jupydebug/tests/conftest.py'),
'__file__': '/home/dan/Documents/jupydebug/tests/conftest.py',
'__cached__': '/home/dan/Documents/jupydebug/tests/__pycache__/conftest.cpython-37.pyc',
'__builtins__': {'__name__': 'builtins',
'__doc__': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.",
'__package__': '',...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupydebug-0.0.1-py3-none-any.whl.
File metadata
- Download URL: jupydebug-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35b35c202ef9a188f3e7be31c0b04eac3a0df3c968bb7267418f9138e784733c
|
|
| MD5 |
a732e4bf3ccb0650059a6f29a87e3677
|
|
| BLAKE2b-256 |
653645982dc18b85f6b9fecda3255757ba6c40076929a1d6dcf8482096daceea
|