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

zafar mahmood

03/23/2022, 7:06 AM
Hi , I am trying to build sensor for the execution of pipeline/graph. sensor would check on different intervals and executes the job containing different ops. Now the Job requires some resource_defs and config. In the offical documentation I don't see how I can define resource_defs for Job. A small hint would be great Question : where or how do i define resource_defs in sensor ? Do I even have to define it ?
Copy code
### defining Job 
@job(
resource_defs = {"some_API_Module": API_module , "db_Module" : db} ,
 config = {key : value } 
) 
def job_pipeline ():
    op_1 () ## API is used as required resource  
    op_2 () ##  db is used as required resource 

### defining sensor that triggers the Job
@sensor ( Job = job_pipeline) :
    ### some calculation 
    yield RunRequest(run_key = "" config = {key : value} )
https://docs.dagster.io/concepts/partitions-schedules-sensors/sensors
a

Aleksandar Glisovic

03/23/2022, 8:48 AM
You can pass op config in this way, not resource config:
Copy code
yield RunRequest(run_key = "" config = {key : {"ops":{"op_1":{"config":{}}, "op_2":{"config":{}}}}} )
resource_defs
must be defined before sensor is run
z

zafar mahmood

03/23/2022, 8:52 AM
i dont get it , before the definition for sensor ? as a global resources ? would be nice if you can share more
a

Aleksandar Glisovic

03/23/2022, 9:01 AM
in sensor, you can't pass resource config
this line:
Copy code
yield RunRequest(run_key = "" config = {key : value} )
should look like this:
Copy code
yield RunRequest(run_key = "")
z

zafar mahmood

03/23/2022, 9:03 AM
okay thanks
a

Aleksandar Glisovic

03/23/2022, 9:07 AM
resource could be configured like this:
Copy code
@job(
resource_defs = {
    "some_API_Module": API_module.configured({
        "key1": value1,
    }),
    "db_Module" : db.configured({
        "key2": value2,
    })},
)
so, you don't need to configure anything in sensor, but on job level
3 Views