John Cenzano-Fong
02/15/2023, 8:06 AMdepends_on_past
so you can prevent a job schedule from executing if the last run of the same job failed. Is there an analog to this for Dagster? I'm seeing execution_fn and should_execute that leverage ScheduleEvaluationContext
but that context seems to only have information about the current run. Any best practice suggestions for this situation?owen
02/15/2023, 5:59 PMshould_execute
bit. The ScheduleEvaluationContext
has an instance
property, which gives you access to the DagsterInstance
(which hold information on past runs and all that good stuff). So within the body of your should_execute function, you can query for the last run of your job with something like
last_run = list(context.instance.get_runs(filters=RunsFilter(job_name="my_job"), limit=1))[0]
if last_run.status == DagsterRunStatus.FAILURE:
...
(you can do from dagster import RunsFilter, DagsterRunStatus
)John Cenzano-Fong
02/15/2023, 11:55 PM