https://prefect.io logo
Title
j

Jared Robbins

03/17/2022, 9:16 PM
What's the meta way to run one task if another task fails in 2.0? pass the task as a parameter to the dependent task and check if the state is failed there? From what I can tell, the wait_for keyword will only check if it is Finished, not whether it is completed or failed
k

Kevin Kho

03/17/2022, 9:17 PM
You can check the state by calling
.get_state()
in the
@flow
block and comparing it
See the example here under “Using results from tasks”
j

Jared Robbins

03/17/2022, 9:22 PM
Shoot I guess that was simpler than I expected... I'll also add that in the documentation here get_state() and wait() have the same desc https://orion-docs.prefect.io/api-ref/prefect/futures/#prefect.futures.PrefectFuture.result
simple is a good thing though!
k

Kevin Kho

03/17/2022, 9:27 PM
Yeah you can check the value of a result also and then execute another task if not the state