Changes in module not visible in index.ipynb

I was trying out nbdev, following the tutorial on nbdev.fast.ai
When I came to the point, edit index.ipynb, I wanted to try the function I created in 00_core.ipynb but no method was visible.

My problem was, that I was running the build command, then importing the module, then changing the module and rebuilding. I expected that the changes would be visible if I just rebuilt and reimported in a running notebook. It took me some time to figure this out and I would have loved to add this note to the nbdev docs directly, but I am not able to contribute to that repo yet (don’t know where to find the file and not familiar with the nb stripping). So I am leaving this here, in case somebody has the same problem, or wants to add this to the docs.

Hint: Re-importing a modified module after building with nb_build_lib might not reflect any changes, until restarting the kernel of the Jupyter notebook.

Cheers!

#hide
%load_ext autoreload
%autoreload 2

It’s in the tutorial video, and common knowledge with jupyter notebooks, that you need those lines of code at the top of a notebook if you want it to automatically reload external modules when they change. Otherwise yes, you’ve got to restart your kernel.

You should have that at the top of index.ipynb, and any other notebooks which import from things elsewhere in your lib.

1 Like

Some feedback here. Perhaps we can avoid this kind of language. Letting someone know that something is common knowledge is not constructive and has the effect of telling the person that you think they are ignorant.

I’m sure you didn’t mean it this way, but this how I felt when I read the message. Again, I assume you don’t have any bad intent, and thanks for helping out on these forums as I have seen you have been answering questions, and have been generally very helpful to the community. Thanks so much for understanding!

5 Likes

Thank you for the answer, these commands are very helpful. There is a lot of jupyter magic going on. As a beginner, there is a lot to learn, beside the course content. Most of what one has to know comes from experience, I guess. For making progress quickly and effectively, hints and tutorials are extremely valuable.

Point taken, what I meant was that it’s not really something which (imo at least) needs adding to the docs, but I can see why it might not come across that way.

2 Likes