Thread
#prefect-community
    Daniel Nilsen

    Daniel Nilsen

    7 months ago
    Hi is there any best practice for looping through tasks?
    t1 = task1()
    t2 = task2(t2)
    while condition:
      t3 = task3(a)
      t4 = task4(t3)
      t5 = task5(t4)
    Kevin Kho

    Kevin Kho

    7 months ago
    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
    @task
    def mytask():
        while condition:
            create_flow_run(...)
            wait_for_flow_run(...)