Hi everyone, is there an example of how to manuall...
# ask-community
t
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
Hi! From where? 🙂
• The UI • The CLI • From another flow or task • From within the flow or task
t
From within the flow or task, both would be useful
z
Copy code
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
Thank you very much!