https://prefect.io logo
s

scott

12/14/2022, 4:52 PM
What is the prefect 2 equivalent to
trigger = all_finished
in prefect 1? This thread suggests that it’s using
.submit()
https://discourse.prefect.io/t/how-can-i-trigger-downstream-tasks-based-on-upstream-task-s-state/106 on the task that you want to always run regardless of upstream task failures?
1
I’d imagine this info is in the docs somewhere, but I don’t see it. Can someone point me to it?
b

Bianca Hoch

12/14/2022, 9:29 PM
Hey Scott, we don't really have an equivalent for
trigger = all_finished
, it's handled pythonically now. You can use conditional statements within the flow run itself in 2.0, which previously wasn't available in 1.0 (which is why we had these triggers as a workaround). Within the example that Anna provided, she is using conditional logic to determine which tasks should run given upstream conditions. The `always_run`task in the example falls outside of the if/else statement, so it runs regardless of the states of the upstream tasks.
You also don't need to necessarily use
.submit()
, but that depends on what you want to do in your code. If you want to reference the contents of a PrefectFuture (state and result of a task) at some point in your code, you can use
.submit()
. If not, and you want to base the code logic on something else, you don't need to reference
.submit()
.
Here are some discourse articles on conditional logic and a bit more context in the docs for you.
s

scott

12/15/2022, 12:14 AM
Thanks @Bianca Hoch !
1
🚀 1
3 Views