<@ULVA73B9P>, is it possible to create a notificat...
# ask-marvin
b
@Marvin, is it possible to create a notification in Prefect when a flow run has a warning?
m
It is possible to create a notification in Prefect when a flow run has a warning. Prefect 2.0’s new notifications system allows you to alert your team when any flow enters any state you specify. To do this, you need to go to the new Notifications page in Prefect and select "Create Notification." Then you can specify the criteria for your notification, including the state that will trigger the notification, such as a warning. For instance, if you want a Slack message when your flow encounters a warning, you would set up a notification that reads something like:
If a run of any flow with any tag enters a warning state, send a notification to my-slack-webhook.
Notifications can be configured to send messages through various channels such as email, Slack, Microsoft Teams, and others. For more details, you can check the Release Notes and the Prefect documentation.
b
@Marvin, I don't see a mention of flow-run having a state of warning in the documentation. If it does, can you provide me a link to it?
m
According to the Prefect documentation, the specific states mentioned for flow runs are
FAILED
and
CANCELLED
. The state of a flow run is determined by its return value and the states of the tasks and subflows within it. - If an exception is raised directly in the flow function, the flow run is marked as
FAILED
. - If the flow does not return a value, or returns
None
, and any task run or subflow run has failed, the final flow run state is marked as
FAILED
. - If any task run was canceled, then the flow run state is marked as
CANCELLED
. There is no mention of a
WARNING
state for flow runs in the documentation that I've searched so far. The states for flow runs seem to be primarily focused on either successful completion, failure, or cancellation. If you require more detailed information on Prefect's flow run states, please refer to the Flow Concepts documentation.
b
@Marvin based on your last response, wouldn't that mean that it's not possible to setup a Prefect automation to send a notification when there is a flow run warning?
m
Yes, based on the information provided in the Prefect documentation, there is no explicit
WARNING
state for flow runs. Therefore, it would not be possible to set up an automation to send a notification specifically when there is a flow run warning, simply because that state is not defined or recognized in Prefect Core's flow run state machine. Flow run states in Prefect are typically binary in the sense that a flow run either succeeds, fails, or gets canceled. However, you might be able to work around this by customizing task states or using logs to identify situations that could be considered as warnings, and then creating notifications based on these custom conditions. If you have a specific scenario in mind, consider reaching out to the Prefect community or checking the documentation for more detailed strategies on handling such cases.
n
what exactly do you mean by
flow run warning?
ahh nevermind I see your other thread with kevin, +1 to emit_event
👍 1
b
Missed your reply earlier. Yeah, Kevin got me straightened out. Thanks for the reply @Nate!
@Nate, maybe you know the answer to the question I posed to Kevin late yesterday? Do you mind taking a look at this question related to this topic?
n
i am ooo for the week but no you can’t currently match on the payload body, but you’re free to add labels to the resource and match on those