= 1 a
Debugging
Example of history call
= 2 b
assert a+b == 3
How to debug last call
Single step
Step-by-step
Get underlying CellProcessor object
= %cell_processor c
If we already called the magic function
, we can get access to the call history as follows:
c.call_history
[('first_data --test --data', 'a = 1\n'),
('second_data --test --data', 'b = 2\n'),
('first_test --test', 'assert a+b == 3\n')]
We need to reset the cell_processor to erase local variables:
c.reset()
If we don’t have called the magic function
before, we won’t have a call history, but we just can indicate it.
= [('first_data --test --data', 'a = 1\n'),
c.call_history 'second_data --test --data', 'b = 2\n'),
('first_test --test', 'assert a+b == 3\n')] (
Now we simulate the calls until the point that we want to debug:
for call in c.call_history[:2]:
*call, add_call=False) c.process_function_call (
We import the ipdb debugger and make the call that we want to debug. In this example, this call is the one in position 2 in the call_history
import ipdb
*c.call_history[2], add_call=False) ipdb.runcall (c.process_function_call,
> /home/jaumeamllo/workspace/mine/nbmodular/nbmodular/core/cell2func.py(316)process_function_call()
315 def process_function_call (self, line, cell, add_call=True):
--> 316 call = (line, cell)
317 if add_call:
ipdb> q