Send Slack message based on job success retry sensor #17736
-
Is there a way to create a sensor that sends a Slack message if the retry of a job was successful? I've looked at the standard <https://docs.dagster.io/_apidocs/libraries/dagster-slack|dagster-slack sensor >and <https://docs.dagster.io/concepts/partitions-schedules-sensors/sensors#run-status-sensors|run status sensor> but didn't see how to check for the tag of retry_number. The question was originally asked in Dagster Slack. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Inside of a run status sensor, you have access to a @run_status_sensor(run_status=DagsterRunStatus.SUCCESS)
def send_slack_on_successful_retry(context):
tags = context.dagster_run.tags
# if retry tag in tags, then use SlackResource to send a message |
Beta Was this translation helpful? Give feedback.
-
Thanks @jamiedemaria for the answer. I eventually figured it out. Here's the full code that worked in my case for future folks.
|
Beta Was this translation helpful? Give feedback.
Inside of a run status sensor, you have access to a
context
. Thecontext
has an attribute calleddagster_run
that in turn contains the tags for a run. You could check those tags and then send a slack message if it was a retry