When I'm working on a notebook using Jupyter Lab, often times, I put code into a local folder so that I can reuse that code in other notebooks. I typically reference that local module by doing the following.
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
So, if I catch a bug or need to enhance the code and modify the *.py files, I cannot get the new code to load by simply re-running the cell. I have to restart the new kernel to get the new changes. This development cycle is pretty bad, especially when parts of the notebook are computationally expensive to run.
Is there any tip on how to more efficiently code and revise module code alongside a Juypter Lab notebook?
The structure of my code looks like the following.
temp/ ├── lib │ ├── __init__.py │ ├── misc.py │ └── utils.py └── notebook.ipynb
The misc.py has the following code.
def say_hi(name):
print(f'hi {name}')
The utils.py has the following code.
def say_bye(name):
print(f'bye bye {name}')
In a cell, I then import a function as follows.
from lib.utils import say_bye
say_bye('john')
Now suppose I change say_bye(), how do I reload the module?