https://prefect.io logo
Title
k

Khuyen Tran

10/31/2022, 3:11 PM
If you want to send an alert when a flow fails by adding only one decorator, use prefect-alert.
from prefect import flow, task 
from prefect.blocks.notifications import SlackWebhook
from prefect_alert import alert_on_failure

@task
def may_fail():
    raise ValueError()

@alert_on_failure(block_type=SlackWebhook, block_name="test")
@flow
def failed_flow():
    res = may_fail()
    return res

if __name__=="__main__":
    failed_flow()
Thanks @Ryan Peden for contributing the collection!
:gratitude-thank-you: 1
👍 1
2
💯 1
🙌 8
🎉 4
🔥 7