Charlie Bini
05/12/2022, 9:01 PMyuhan
05/12/2022, 9:13 PMcontext.instance.get_runs
and filter it down to the last run to find the timestamp. for example, this is how we do it internally: https://github.com/dagster-io/dagster/blob/master/python_modules/dagster/dagster/core/execution/backfill.py#L290Charlie Bini
05/12/2022, 9:14 PMyuhan
05/18/2022, 11:18 PMCharlie Bini
05/18/2022, 11:18 PMyuhan
05/18/2022, 11:22 PMcontext.instance.get_run_records
instead https://github.com/dagster-io/dagster/blob/master/python_modules/dagster/dagster/core/instance/__init__.py#L1252
it returns a list of RunRecord which has the create_timestamp
and other info like start/end time of the runCharlie Bini
05/18/2022, 11:35 PMlimit: 1
yield the most recent run?yuhan
05/18/2022, 11:37 PMCharlie Bini
05/19/2022, 12:08 AMdef gql_last_schedule_run(context):
runs = context.instance.get_run_records(
filters=RunsFilter(
statuses=[DagsterRunStatus.SUCCESS],
job_name=context.job_name,
tags={
"dagster/schedule_name": context.get_tag(key="dagster/schedule_name")
},
),
limit=1,
)
last_run = runs[0] if runs else None
if last_run:
return last_run.create_timestamp.astimezone(LOCAL_TIMEZONE)
else:
return TODAY
yuhan
05/19/2022, 12:10 AM