https://dagster.io/ logo
#ask-ai
Title
# ask-ai
t

Todd de Quincey

02/23/2024, 12:33 PM
I have a
ScheduleDefinition
which uses the
should_execute
argument. How can I raise an alert if the schedule is skipped due to the
should_execute
argument?
s

Scout

02/23/2024, 12:33 PM
The
should_execute
function in a
ScheduleDefinition
is used to determine whether a schedule should execute or skip at the scheduled execution time. If the function returns
False
, the schedule is skipped. However, the documentation does not provide a direct way to raise an alert from within the
should_execute
function itself. To raise an alert when a schedule is skipped, you would typically need to implement an external monitoring or alerting system that can track the execution of your schedules and notify you when a skip occurs. This could involve logging the skip event and having an external system monitor these logs for skip events, then triggering an alert based on that. If you want to implement custom logic within Dagster to handle skips, you could consider using hooks. Hooks in Dagster allow you to perform custom actions in response to different events in the lifecycle of a pipeline run. However, hooks are executed in response to events within pipeline runs, and a skipped schedule does not create a pipeline run, so this approach would not work directly for your use case. For your specific requirement, you might need to look into the following approaches: 1. Monitoring Scheduled Runs: Set up monitoring for your scheduled runs using the Dagster instance's run history. If a scheduled run is expected but does not appear in the run history, this could trigger an alert. 2. Custom Logging: Within the
should_execute
function, you could add custom logging that writes to a log file or sends a message to an external system whenever the function returns
False
. 3. External Scheduler: Use an external scheduler that can handle more complex alerting logic based on the execution status of the scheduled jobs. Remember that any solution would likely involve external systems or additional infrastructure to monitor and alert based on the schedule's behavior. The documentation does not provide a built-in way to raise alerts directly from the
should_execute
function.