https://prefect.io logo
Title
p

Prasanth Kothuri

12/22/2021, 11:50 AM
can I enforce order of the tasks in the flow ? today I noticed that some tasks were scheduled before even though they are right at the end in my code
a

Anna Geller

12/22/2021, 12:03 PM
yup, you can use
upstream_tasks
as follows:
from prefect import task, Flow

@task
def first_task():
    pass

@task
def second_task():
    pass

@task
def third_task():
    pass

with Flow("ex") as flow:
    a = first_task()
    b = second_task(upstream_tasks=[a])
    c = third_task(upstream_tasks=[b])

flow.visualize()
👍 1
p

Prasanth Kothuri

12/22/2021, 12:23 PM
thanks a ton, let me try it out