Does anyone know if there is a way to have a senso...
# ask-community
n
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
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
@Zach Thanks for the guidance. I was able to get a sensor working exactly as I wanted.