https://prefect.io logo
d

Daniel Nilsen

02/18/2022, 4:44 PM
Hi is there any best practice for looping through tasks?
Copy code
t1 = task1()
t2 = task2(t2)
while condition:
  t3 = task3(a)
  t4 = task4(t3)
  t5 = task5(t4)
k

Kevin Kho

02/18/2022, 4:46 PM
This is not a DAG so it can’t be done in Prefect 1.0, but it can be done in Prefect 2.0. Your options are task looping (1 task). Or splitting this into a subflow and then you invoke it from inside a task
Copy code
@task
def mytask():
    while condition:
        create_flow_run(...)
        wait_for_flow_run(...)
3 Views