Do plain modules, that are imported inside of a %%...
# hamilton-help
v
Do plain modules, that are imported inside of a %%cell_to_module cell need to be re-loaded in any particular way, after they've been changed?
s
if you have the same kernel running you either need to restart it or do something like:
Copy code
import importlib
importlib.reload(MODULE)
or try using the reload extension magic
Copy code
%load_ext autoreload
%autoreload 2
I haven’t tried the second one with the hamilton jupyter magic though
👍 1
v
ok, I've come up with this scheme
Copy code
%%cell_to_module reload_test_module

import dag_common

import importlib
importlib.reload(dag_common)
from dag_common import commonfunction
It seems to be necessary, to load the module first (not only the actually desired function), so that can be reloaded … and after that, the specified import can happen. Does this exist somewhere in the documentation? I was only able to find the reloading of an entire hamilton dag module on https://hamilton.dagworks.io/en/latest/how-tos/use-in-jupyter-notebook/#step-3-the-basic-process-of-iteration
s
Yeah we haven’t documented that for people iterating on other internal modules + using the hamilton jupyter magic
If you have time for a pull request, that would be great! 🙂