is there a way to use resources in a run_status_se...
# ask-community
d
is there a way to use resources in a run_status_sensor? we'd like to have a sensor that monitors a job and only kicks off a RunRequest if the job had succeeded AND a query that we run against one of our databases has a certain condition. I figured the ease of run_status_sensor would help here with monitoring my job, but there doesn't seem a way to specify certain resource keys in the definition.
c
Hi Danny. I believe in 1.2.2 we added experimental support to allow resource requirements for schedules and sensors when using a
Definitions
object:
Copy code
@sensor(job=my_job, required_resource_keys={"my_resource"})
def my_sensor(context):
    files_to_process = context.my_resource.get_files()
		...

@sensor(job=my_job)
def my_sensor(context, my_resource: MyResource):
    files_to_process = my_resource.get_files()
		...
Ah, apologies, I think this is currently not enabled for run status sensors yet. I'd recommend filing an issue for tracking purposes if this is a functionality you want
👍 3
a
Hello. I'm using resources, built with build_resources func inside run status sensors.
m
Hi, just found this post as I want to do a similar thing - ie. query a database table and check for new data and if there is, trigger a sensor to run a job. Is this possible yet?
And if so, is it possible to supply
run_config
to a sensor with a resource as the config file will contain the database connection details required to connect to and query the database and then trigger the sensor run if a certain condition in the database is met?
d
I worked around it by just using a plain
@sensor
and then adding the
required_resource_keys
to that, and in the body of the sensor I'm using
context.instance.get_runs
to filter for the specific job run that I'm looking for