https://dagster.io/ logo
#announcements
Title
# announcements
j

John Mav

03/18/2020, 5:25 AM
Hey Y'all I'm wondering if there is a way to point a
ScheduleDefinition
's
should_execute
filter to another pipeline having completed. I'm wondering if there is a way to set dependencies like Pipeline B executes at scheduled time if and only if the last run of Pipeline A successfully ran.
s

sashank

03/18/2020, 6:13 AM
Hey @John Mav, this is definitely possible. The
should_execute
function is passed a
context
which an instance of
ScheduleExecutionContext
. On this we can access
context.instance
which lets us query the run storage using the
get_runs
method
To do what you’re describing:
Copy code
def should_execute(context):
    run_filter = PipelineRunsFilter(pipeline_name="Pipeline A")
    runs = context.instance.get_runs(run_filter, limit=1)
    if not len(runs):
        return False

    latest_run = runs[0]
    if latest_run.status == PipelineRunStatus.SUCCESS:
        return True

    return False
Does this work for you?
j

John Mav

03/19/2020, 3:05 AM
Oh this is amazing! Thank you @sashank 😄
4 Views