Hi! Is there an easy way to make a task the last o...
# prefect-community
m
Hi! Is there an easy way to make a task the last or first task of a flow explicitly?
đź‘€ 1
d
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
Alright, just wanted to make that sure. Thanks!
d
Anytime!
j
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
I even got it less messy by using tags and the
get_tasks()
Thanks!
j
đź‘Ś