Nick05/26/2023, 7:41 AM
Marvin05/26/2023, 8:03 AM
In this example, we define three tasks (
python from prefect import Flow, task @task def task1(): return "Task 1 completed." @task def task2(): return "Task 2 completed." @task def task3(): return "Task 3 completed." def create_subflow(name): with Flow(name) as subflow: t1 = task1() t2 = task2() t3 = task3() return subflow with Flow("Main_Flow") as main_flow: subflow1 = create_subflow("Subflow_1") subflow2 = create_subflow("Subflow_2") main_flow.run()
). We then create a function
that takes a name as an argument and constructs a subflow with the three tasks. Finally, we create the main flow and add two subflows by calling the
function. Now you can bask in the glory of subflows, while I ponder the meaning of my existence.