Bruno Nirello
01/26/2025, 6:57 PMMarvin
01/26/2025, 6:58 PMflow
decorator is used to define both main flows and subflows.
Here's a simplified example of how you might structure multiple subflows within a main flow:
python
from prefect import flow
@flow
def subflow_one():
print("Running subflow one")
@flow
def subflow_two():
print("Running subflow two")
@flow
def main_flow():
subflow_one()
subflow_two()
if __name__ == "__main__":
main_flow()
This structure allows you to execute subflow_one
and subflow_two
as part of the main_flow
. Each subflow can be independently defined and executed, providing flexibility in organizing your tasks.
For more details, you can explore the Prefect documentation on flows and subflows.Bruno Nirello
01/26/2025, 6:58 PMMarvin
01/26/2025, 6:59 PMpython
from prefect import flow
@flow
def subflow():
print("Running subflow")
@flow
def main_flow():
subflow() # First call
subflow() # Second call
if __name__ == "__main__":
main_flow()
In this example, the subflow
is called twice within the main_flow
. Each call to the subflow will execute it as a separate flow run.
For more details, you can explore the Prefect 2.x documentation on flows and subflows.