I'm facing issues when making changes to a custom module and using it in a Jupyter session. The changes to my module do not take effect until I restart the server. Not the kernel. The server. Restarting the kernel does not work, for mysterious reasons.
I am aware that there are some caveats and non-intuitive things when changing modules and trying to import them in a Jupyter session. Normally, I would use the magic command
%load_ext autoreload
%autoreload 2
Or when necessary the explicit
from importlib import reload
reload(module)
import module
Neither of these work. Restarting the kernel does not work. I keep getting:
ile /gpfs/soma_fs/scratch/meulemeester/project_src/in_silico_framework/visualize/vtk.py:226, in write_vtk_skeleton_file()
222 return diameter_string
224 sections = lookup_table['sec_n'].unique()
--> 226 soma = lookup_table[lookup_table['sec_n'] == 0].groupby['sec_n'].mean().reset_index()
227 lookup_table = pd.concat(soma, lookup_table[lookup_table['sec_n'] != 0])
228 for dataname, data in point_scalar_data.items():
AssertionError: Length of point scalar data "Vm" does not match number of points. Scalar data: 13919. Amount of points: 13962
This assertion error used to be on line 226 before I changed it. Now it's on line 229. After restarting the kernel, this error persists.
I'm guessing (but this is just guessing, and I'm very uncertain) that my jupyter server is using some cached versions of these modules, and reloading them in the notebook does not actually do anything. Or the PATH has been adapted in a weird way, but then I would expect to get blatant import errors, and not this... I don't know what's happening here, and would very much appreciate some help!
If it is of any use, I launch my Jupyter server from a Python script as such:
command = [
'jupyter-lab',
"--ip='*'",
'--no-browser',
'--port={}'.format(lab_port),
"--NotebookApp.allow_origin='*'"
]
log = open(os.path.join(management_dir, "jupyter.txt"), 'a')
subprocess.Popen(command, stdout=log, stderr=log)