https://prefect.io logo
Title
t

Tibs

11/18/2022, 6:05 PM
Hi everyone, is there an example of how to manually set the state of a flow or task to failed in prefect 2?
1
z

Zanie

11/18/2022, 6:05 PM
Hi! From where? 🙂
• The UI • The CLI • From another flow or task • From within the flow or task
t

Tibs

11/18/2022, 6:08 PM
From within the flow or task, both would be useful
z

Zanie

11/18/2022, 6:13 PM
import prefect
from prefect.states import Failed


@prefect.flow
def foo():
    bar()


@prefect.task
def bar():
    return Failed(message="Oh no!")


foo()
Works the same for flows as well.
t

Tibs

11/18/2022, 6:15 PM
Thank you very much!