Question - in a simple local flow run, no parallel...
# prefect-community
m
Question - in a simple local flow run, no parallelism involved, is there a way to make sure the flow run will always execute in some order ? (this helps for an ML reproducibility use-case I am thinking of … )
n
Hi @Marwan Sarieddine - yes, you can explicitly set the ordering of tasks using the
upstream_tasks
kwarg to a copy of the Task instance. You can read more about
upstream tasks
here: https://docs.prefect.io/api/latest/core/task.html#task-2
m
Hi @nicholas - thanks for the quick response - will take a look
ok so upstream_tasks by default is a set, but if I set it as a list then order is maintained (thanks!)… follow up question:
Copy code
with Flow("test-flow"):
    f1 = task1a()
    task1b(f1)
    
    g1 = task2a()
    task2b(g1)
task1a
will always be executed before
task2a
in the simple local non-parallel run - correct ?
n
@Marwan Sarieddine - theoretically, yes, but you can ensure this by including
upstream_tasks=[f1]
in the constructor for
task2a
like this:
Copy code
with Flow("test-flow") as flow:
    f1 = task1a()
    task1b(f1)
    g1 = task2a(upstream_tasks=[f1])
    task2b(g1)
m
oh ok - gotcha
n
You can see this in the flow DAG
m
yep - thank you !