Jason Motley
10/03/2023, 2:39 PMNate
10/03/2023, 5:57 PM@flow
-decorated functions from other @flow
-decorated functions, for example
from prefect import flow
@flow
def foo():
pass
@flow
def bar():
for _ in range(3):
foo()
if __name__ == "__main__":
bar()
# deploy this flow with bar.serve(__file__)
will run 3 subflowsNate
10/03/2023, 5:57 PMJason Motley
10/03/2023, 5:58 PMJason Motley
10/03/2023, 5:58 PMmain_flow
? @flow(name="test.test", persist_result=True, log_prints=True)
def main_flow(msg="Flow body"):Jason Motley
10/03/2023, 5:59 PMNate
10/03/2023, 6:01 PMfrom my_module import main_flow as this_specific_main_flow
@flow(name="some unique name")
def main_flow():
this_specific_main_flow()
is this what you mean? prefect doesn't really care what the __name__
of your flow function is, but if you're re-using names then I would pass a unique name
to the decorator of each flowJason Motley
10/03/2023, 6:01 PMJason Motley
10/03/2023, 6:02 PMNate
10/03/2023, 6:03 PMfrom my_package.module.submodule import some_defined_flow
# or
from local_file import some_other_defined_flow
and as for the name
kwarg to your flow decorator, its entirely up to you what you call your flows, but flows should have unique namesJason Motley
10/03/2023, 6:37 PMlocal_file
the flow name from the file or the actual name (name="my_name"
)?Nate
10/03/2023, 6:41 PMlocal_file
is a hypothetical file name in which some_other_defined_flow
would be defined, like
# local_file.py
from prefect import flow
@flow(name="whatever")
def some_other_defined_flow():
pass
Jason Motley
10/03/2023, 7:22 PMNate
10/03/2023, 9:16 PM