https://prefect.io logo
m

Matthias

05/14/2020, 8:05 PM
Hi! Is there an easy way to make a task the last or first task of a flow explicitly?
đź‘€ 1
d

Dylan

05/14/2020, 8:09 PM
Hi @Matthias! Check out: https://docs.prefect.io/api/latest/core/task.html#task-2 and the
set_dependencies
method
You can explicitly set upstream and downstream deps for a given task
I don’t think we have an idiom for saying “this is the first task”
or “this is the last task”
Let me know if I can expand or help further
m

Matthias

05/14/2020, 8:11 PM
Alright, just wanted to make that sure. Thanks!
d

Dylan

05/14/2020, 8:16 PM
Anytime!
j

Jeremiah

05/14/2020, 8:17 PM
If you wanted to make ABSOLUTELY sure, you could do something like:
Copy code
all_other_tasks = flow.tasks.difference([t])
t.set_dependencies(upstream_tasks=all_other_tasks, flow=flow)
This would make
t
a downstream task of every other task, ensuring it runs last
👍 1
m

Matthias

05/14/2020, 8:47 PM
I even got it less messy by using tags and the
get_tasks()
Thanks!
j

Jeremiah

05/14/2020, 8:48 PM
👌