Cris
06/12/2020, 8:33 PMalex
06/12/2020, 8:51 PMCris
06/12/2020, 8:59 PMalex
06/12/2020, 9:08 PMDagsterInstance.get().delete_run(run_id)
from dagster import DagsterInstance
def clean_old_runs():
# get access to instance DBs - assumes locally configred with
# $DAGSTER_HOME/dagster.yaml
instance = DagsterInstance.get()
runs = instance.get_runs() # can take limit & cursor if you want to go in batches
for pipeline_run in runs:
stats = instance.get_run_stats(pipeline_run.run_id)
stats.end_time # unix time stamp
# do your date math
if too_old:
instance.delete_run(pipeline_run.run_id)
Cris
06/12/2020, 10:08 PMalex
06/13/2020, 1:44 AM