Previously we have been using state handlers to send a customized email when any task fails in 1.0.
but in 2.0 with state handlers gone, we would have to add that logic to ALL of our flow/task definitions:
state1 = my_task1(return_state=True)
if is_failed_state(state1): send_some_custom_email()
state2 = my_task2(return_state=True)
if is_failed_state(state2): send_some_custom_email()
…
This approach seems cumbersome to write and maintain. Is there a way to add this custom notification logic to ALL tasks we create? (Maybe changing the notification feature in 2.0 to support custom email content?)
This is something I was also looking for, thanks for the links! Can I have my own notification block that would call REST API of an internal service instead of calling Slack?
Hi @anna_geller , I tried out the second link above and it appears that the project currently does not plan to supprot task-level alerting.
Is there any updates on task-level custom alerting? Or is the best shot here still custom blocks which offers flow-level alerting?
Also I was scanning through the code base and saw the notification blocks like Slack. How would I register a new notification block like the one here and let Prefect know its existence when running flow_run_notification.py?
Thanks Anna! I was trying to create a notification block that sends email notification on flow/task failure, so it would be really nice if I can register custom notification blocks to the backend (which I assume is running the flow_run_notification.py as a service).