Morten Hauge
11/07/2023, 9:37 PMallow_failure
on all subsequent task?Morten Hauge
11/07/2023, 10:03 PMstate change hooks
concept appears to be exactly what I need!Kevin Grismore
11/07/2023, 10:03 PMMorten Hauge
11/07/2023, 11:03 PMon_failure
hooks should always trigger, even when the returned state is manual, right?
I have a task that returns Failed(message="something")
when a certain condition is triggered. In the Prefect UI this is shown as an ERROR log, but my hook is not ran. However it does seem to run when the Prefect worker encounters an unexpected exception. I've registered the same hook for both on_failure, on_completion and on_crashed to cover all bases.Kevin Grismore
11/07/2023, 11:17 PMfrom prefect import flow, task
from prefect.states import Failed
def hook(task, task_run, state):
print("flow failed")
@flow
def my_flow():
always_fail()
@task(on_failure=[hook])
def always_fail():
return Failed(message="something")
if __name__ == "__main__":
my_flow()
Morten Hauge
11/08/2023, 8:12 AM