Filip Panovski
03/29/2023, 1:56 PM.
├── flow_definitions
│ ├── __init__.py
│ ├── masterdata
│ │ ├── deployment.py
│ │ ├── extract_data.py
│ │ └── __init__.py
│ ├── classification
│ │ ├── deployment.py
│ │ ├── __init__.py
│ │ └── preprocessing.py
│ └── utils
│ ├── date_utils.py
│ ├── __init__.py
├── README.md
├── requirements.txt
└── setup.py
In classification/preprocessing.py
, I am doing a sibling import as follows:
from flows.flow_definitions.utils.date_utils import parse_date
However, this fails:
ModuleNotFoundError: No module named 'flows'
since it seemingly can't find my parent module (.
).
Strictly speaking, this is a Python problem and not a prefect issue. However, I can't seem to find an example detailing this kind of approach. I thought that maybe the Deployment path
parameter might have something to do with this scenario, but it seems that's not the case.
So, is there an example of a project using common functionality? Do I have to install my utils
module, or is there another preferred way to get this to work in my flows?Dominic Tarro
03/29/2023, 2:54 PM# classification/preprocessing.py
from ..utils.date_utils import parse_date
If both a module and script entrypoint
# classification/preprocessing.py
try:
from ..utils.date_utils import parse_date
except ImportError:
from flows.flow_definitions.utils.date_utils import parse_date