https://dagster.io/ logo
#ask-community
Title
# ask-community
n

Noam Jacobson

03/11/2024, 3:19 PM
Does anyone know if there is a way to have a sensor check the status of a job and execute whether the status ends up either a success or a failure? run_status_sensor seems to only check for success or failure. Not both.
z

Zach

03/11/2024, 3:27 PM
You can create a sensor that queries the Dagster instance for runs and then yields a RunRequest for runs that have succeeded or failed.
Copy code
@sensor
def my_sensor(context:SensorEvaluationContext):
  if context.instance.get_runs(filters=[RunFilter(statuses=[DagsterRunStatus.SUCCESS, DagsterRunStatus.FAILURE]:
    ...
👀 1
The DagsterInstance is very useful whenever you want to query state about your Dagster instance
n

Noam Jacobson

03/13/2024, 2:57 PM
@Zach Thanks for the guidance. I was able to get a sensor working exactly as I wanted.