powerful-continent-97643
07/30/2024, 5:23 PM__import__()
only loads the top-level module, unlike importlib.import_module()
.
I found https://outerbounds-community.slack.com/archives/C02116BBNTU/p1699048473617079 but the situation described is different than mine. I have the following scription
project_code/
__init__.py
pipeline/
__init__.py
a_raypipeline.py
my_metaflow_flow.py <---- new to repo
It can't be imported for the graph traversal because __import__()
is pulling in the project_code
module instead of <http://project_code.pipeline.my|project_code.pipeline.my>_metaflow_flow
.powerful-continent-97643
07/30/2024, 5:25 PM__import__()
Note howreturns the toplevel module here because this is the object that is bound to a name by the__import__()
statement.https://docs.python.org/3.10/library/functions.html#import__import
square-wire-39606
07/30/2024, 9:03 PMmy_metaflow_flow.py
look like?>powerful-continent-97643
07/30/2024, 9:56 PMclass MyMetaflowFlow(FlowSpec):
@step
public start(self):
self.next(end)
@step
public end(self):
pass
powerful-continent-97643
07/30/2024, 9:57 PMif __main__
checks. that was intended to be in a separate file for reasons specific to the project.powerful-continent-97643
07/30/2024, 9:59 PMMyMetaflowFlow
because the module project_code
is imported instead of the module <http://project_code.pipeline.my|project_code.pipeline.my>_metaflow_flow
.ancient-application-36103
07/31/2024, 1:04 AMpowerful-continent-97643
07/31/2024, 5:51 PMpython project_code/pipeline/run_my_metaflow_flow.py run
which is a different script doing some pre-
processing of config files before invoking MyMetaflowFlow() in the if __main__
blockpowerful-continent-97643
07/31/2024, 6:08 PMpowerful-continent-97643
07/31/2024, 9:04 PMancient-application-36103
08/07/2024, 5:08 PMif __main__
bits are needed for metaflow to be able to successfully parse the flow structurepowerful-continent-97643
08/07/2024, 5:41 PM__import__()
builtin instead of importlib
.powerful-continent-97643
08/12/2024, 3:19 PMif __main__
block is required for the steps to execute. but that does that have to preclude starting a run a different way, like via a different CLI module or script?powerful-continent-97643
08/12/2024, 3:22 PMancient-application-36103
08/12/2024, 3:26 PMpowerful-continent-97643
08/12/2024, 4:50 PMancient-application-36103
08/12/2024, 5:28 PMuse the metaflow CLI not the hydra one (edits are direct to files instead of via CLI overrides)
- maybe i don't have the full understanding here of the issue at handpowerful-continent-97643
08/12/2024, 6:24 PMsys.argv
need to be modified, but @click
seems to read sys.argv
as soon as it's imported, which is when FlowSpec
is imported, which needs to happen before the specifi FlowSpec
can be defined. therefore the pre-processing and manipulation of sys.argv
cannot be in the same file (without doing some weird double if __main__
blocks). this would be fine if the FlowSpec could be imported after the pre-processing and sys.argv
manipulation had finished. it cannot due to the AST checker's use of __import__()
instead of importlib
, as linked at the top of this thread.powerful-continent-97643
08/12/2024, 6:26 PMFlowSpec
class. they have not been using Hydra CLI's config overrides. so they are fine directly editing local files to tweak their runs.