Thanks for taking the time to do these videos @slawekbiel I found them instructive and will be recommending them to my team as a quick intro to python debugging!
@Antoine.C I watched the whole video on 2x speed, stopping here and there for taking notes. Great stuff and totally worth it.
As a best practice, itās good to install the editable version of both fastai2 and fastcore, and update them at the same time in order to have both packages aligned.
@slawekbiel, Thank you for sharing your videos. Iām a heavy user of VS Code in both windows and Linux, I find it super useful despite the fact that its Jupyter notebook version is not on par with the official one. As a matter of fact, I wrote the entire timeseries package (see description here) using VS Code and the Python extension. I find it more practical to both be able working on a Jupyter notebook and easily navigate the source code. I have a fastai2 workspace that I always keep open so I can easily jump from my package to the fastai2 one.
Iād like to hijack the thread and ask if anyone knows of a way to achieve what I think of as the āholy grailā of debugging in datascienceā¦ attaching the VSCode debugger onto a running jupyter/IPython kernel and following the call stack down for any particular RunCell.
To do this I have to copy a notebookās content into a .py file and then launch in debug mode in vscode. This is suboptimal when Iāve run cells out of order, or there is some object, like a learn.fit(), that takes a long time to run before reaching the breakpoint of interest.
I agree with you. Unfortunately, it looks like that option doesnāt exist yet based on my recent search: I hope Iām wrong because I canāt wait to see that happen: That will be a game changer.
HI. Do we have a way to put an pdb.set_trace() to fastai library without modifying its source code (the lib is not installed by pip -e). I find in fastcore the trace() function and its source code as below.
def trace(f):
"Add `set_trace` to an existing function `f`"
def _inner(*args,**kwargs):
set_trace()
return f(*args,**kwargs)
return _inner
So Iām thinking about kind of monkey-patching the original source code by putting trace as a decorator.
With that you can just do: ImageDataLoaders.from_dblock = trace(ImageDataLoaders.from_dblock)
and now this will break inside the function I substituted.
Alternatively you can invoke pdb earlier and then set a breakpoint with the b command. Like this:
(Pdb) b ImageDataLoaders.from_dblock
Breakpoint 1 at /notebooks/fastai2/fastai2/data/core.py:157
(Pdb) c
> /notebooks/fastai2/fastai2/data/core.py(159)from_dblock()
I specially registered an account to clike a like! Thanks for the video, it really helps me a lot and improve me to debug deeper! Almost Iām just ready to give upļ¼ but find someone try a lot to do the same thing and do better.