Viktor
09/18/2024, 2:53 PM__init__ file?
e.g. I have a Jupyter Lab cell, that does an
*from* dag_common *import* multiline_cleaning ,
and dag_common.py is merely a single file in the current directory?
I can make *from* dag_common *import* * work, but not the explicit function as above.Viktor
09/18/2024, 2:54 PM* doesn't work.Thierry Jean
09/18/2024, 2:55 PM*from* dag_common *import* multiline_cleaning or import * shouldn't work.
I'll try to repro and investigate! Thanks for submitting the issueThierry Jean
09/18/2024, 4:20 PMfoo in my_module.py
# my_module.py
def foo() -> int:
return 13
2-define notebook this notebook that imports foo and defines bar
%load_ext hamilton.plugins.jupyter_magic
## cell 2
%%cell_to_module
from my_module import foo
def bar(foo: int) -> int:
return foo
3-define my_module2.py that imports foo and defines bar (like the notebook)
from my_module import foo
def bar(foo: int) -> int:
return foo + 1
4-create a Driver that imports my_module2
if __name__ == "__main__":
from hamilton.driver import Builder
import my_module2
dr = Builder().with_modules(my_module2).build()
dr.display_all_functions("my_module2.png")
Both for the notebook and module, I obtain the same visualization / DAGThierry Jean
09/18/2024, 4:22 PMfoo and bar were defined in the same notebook cell (see picture). Maybe I didn't understand the issue properly?Viktor
09/18/2024, 5:23 PMViktor
09/18/2024, 5:24 PMThierry Jean
09/18/2024, 5:24 PM%%cell_to_moduleThierry Jean
09/18/2024, 5:24 PM-m is no longer required, can you try
%%cell_to_module my_module ?Viktor
09/18/2024, 5:25 PMThierry Jean
09/18/2024, 5:25 PMViktor
09/18/2024, 5:30 PM