-
Question was originally asked in Dagster Slack. Reposting it here for posterity and discoverability. What is the appropriate way to construct a sensor that yields a
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Run status sensors currently don’t support yielding RunRequest. So, I'd recommend to write a custom sensor that listens to the run storage and yields a RunRequest when a Something like: from dagster import RunsFilter, sensor, DagsterRunStatus
@sensor(job=do_the_second_thing)
def thing_sensor(context):
run_records = context.instance.get_run_records(
filters=RunsFilter(
job_name="do_the_first_thing",
statuses=[DagsterRunStatus.SUCCESS],
updated_after=..., # can also filter by timestamp to do more efficient fetching
),
order_by="update_timestamp",
ascending=False,
)
for run_record in run_records:
yield RunRequest(
run_key=run_record.dagster_run.run_id, # avoid double firing for the same run
) |
Beta Was this translation helpful? Give feedback.
-
Hi @yuhan, thanks for the examples. Question: what is the problem with the first approach? Or why the second one is preferred? Thanks! |
Beta Was this translation helpful? Give feedback.
Run status sensors currently don’t support yielding RunRequest. So, I'd recommend to write a custom sensor that listens to the run storage and yields a RunRequest when a
job_1
run finishes.Something like: