mammoth-twilight-79890
11/03/2023, 9:54 PMpackage_dir/
__init__.py
flows.py
shared_code.py
And say that flows.py looks something like
from metaflow import FlowSpec, step
from package_dir import shared_code
class ExampleFlow(FlowSpec):
...
if __name__ == "__main__":
ExampleFlow()
if I try to run this like this:
python -m package_dir.flows run
I get a ModuleNotFoundError when trying to import the shared_code module, but that import works when I comment out the ExampleFlow() call and replace it with something like print("Hello world!"),mammoth-twilight-79890
11/03/2023, 9:59 PMflaky-plumber-70709
11/03/2023, 11:44 PMmammoth-twilight-79890
11/03/2023, 11:45 PM-m helps it figure out the importsmammoth-twilight-79890
11/03/2023, 11:46 PMpython package_dir/flows.py run leads to the same ModuleNotFoundErrorflaky-plumber-70709
11/03/2023, 11:46 PMflaky-plumber-70709
11/03/2023, 11:48 PMmammoth-twilight-79890
11/03/2023, 11:48 PMmammoth-twilight-79890
11/03/2023, 11:48 PMflaky-plumber-70709
11/03/2023, 11:49 PMmammoth-twilight-79890
11/03/2023, 11:50 PMmammoth-twilight-79890
11/03/2023, 11:51 PMrun_flow.py with the following code:
from package_dir.flows import ExampleFLow
if __name__ == "__main__":
ExampleFlow()mammoth-twilight-79890
11/03/2023, 11:52 PMpython run_flow.py run it causes this:
OSError: could not get source codeflaky-plumber-70709
11/03/2023, 11:52 PM./
flows/
flow_1.py
other_flow.py
common/
__init__.py
utils.py
infra/
src/
stack.ts
...mammoth-twilight-79890
11/03/2023, 11:53 PMmammoth-twilight-79890
11/03/2023, 11:53 PMflows whenever you want to run one?flaky-plumber-70709
11/03/2023, 11:53 PMflaky-plumber-70709
11/03/2023, 11:53 PMflaky-plumber-70709
11/03/2023, 11:54 PMflaky-plumber-70709
11/03/2023, 11:54 PMmammoth-twilight-79890
11/03/2023, 11:58 PMproject_code/
__init__.py
subpackage/
__init__.py
functions.py
submodule.py
flows/
__init__.py
flow1.py
flow2.py
as in my head, I tend to think of these flows as "this is how I want to orchestrate my code" and the stuff under project_code as "this is the business logic that drives the pipelines".
This is a minor point, but it also helps having these in separate directories because then in a file explorer or whatever I can separately collapse the flows directory or the project_code directories if I want to limit my focus to a certain set of filesflaky-plumber-70709
11/04/2023, 12:00 AMmammoth-twilight-79890
11/04/2023, 12:00 AMproject_code and all the stuff under flows can treat it like any other package in site-packages?flaky-plumber-70709
11/04/2023, 12:01 AMmammoth-twilight-79890
11/04/2023, 12:01 AMmammoth-twilight-79890
11/04/2023, 12:02 AM