I have a basic directory strucrure
model_folder
|
|
------- model_modules
| |
| ---- __init__.py
| |
| ---- foo.py
| |
| ---- bar.py
|
|
------- research
| |
| ----- training.ipynb
| |
| ----- eda.ipynb
|
|
------- main.py
Where model_modules
is a folder containing two functions that I use in my model, research
is a folder where I put modeling research, etc., and main.py
is my main script that tests new data.
My question regards how to import a module, ie model_modules
, into a script in a sub-directory. I can import model_modules
into main.py
just fine by doing the following
from model_modules.foo import Foo
from model_modules.bar import Bar
But when I try the same thing in training.ipynb
or eda.ipynb
, I get the error
ModuleNotFoundError: No module named 'model_modules'
I want my directory to be "clean" and don't want all my research scripts in the root directory. Is there a fix for this so that I can import model_modules
into scripts in research
? Or do I need to approach the architecture of this directory differently?