https://dagster.io/ logo
#ask-ai
Title
# ask-ai
j

Joshua Greenhalgh

02/23/2024, 9:58 PM
How can I create a sensor that is turned on by default
s

Scout

02/23/2024, 9:58 PM
To create a sensor that is turned on by default, you can use the
default_status
parameter when defining your sensor with the
@sensor
decorator. Set this parameter to
DefaultSensorStatus.RUNNING
to have the sensor start in a running state as soon as it is loaded into your workspace. Here is an example from the documentation:
Copy code
python from dagster import sensor, DefaultSensorStatus  @sensor(job=my_job, default_status=DefaultSensorStatus.RUNNING) def my_running_sensor():     ...
In this example,
my_job
is the job that the sensor is associated with, and the sensor
my_running_sensor
will be started by default when it is added to your Dagster instance. If you manually start or stop a sensor in the UI, that action will override any default status set in the code.
2 Views