a = 1Debugging
Example of history call
b = 2assert a+b == 3How to debug last call
Single step
Step-by-step
Get underlying CellProcessor object
c = %cell_processorIf 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.
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')]Now we simulate the calls until the point that we want to debug:
for call in c.call_history[:2]:
c.process_function_call (*call, add_call=False)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 ipdbipdb.runcall (c.process_function_call, *c.call_history[2], add_call=False)> /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