Ivan G
03/04/2024, 3:18 PMScout
03/04/2024, 3:18 PMmonitored_jobs
parameter in a sensor definition to specify the jobs that the sensor should monitor. This parameter accepts a list of job definitions, but it can also work with job names if the jobs are in the current code location or in external repositories when using RepositorySelector
or JobSelector
. Here's an example from the documentation that shows how you might define a sensor with the monitored_jobs
parameter: python from dagster import sensor, DefaultSensorStatus, RunRequest, SensorExecutionContext @sensor(monitored_jobs=[my_job_name], default_status=DefaultSensorStatus.RUNNING) def my_sensor(context: SensorExecutionContext): # logic to determine whether to trigger a run based on the job's status ...
In this example, my_job_name
is a string that refers to the name of the job you want to monitor. The sensor will be triggered based on the status of the job with that name. This allows you to create sensors that react to the status of jobs without needing to import the job definitions directly into your sensor code.