Is it possible to write a sensor for an asset, whi...
# ask-community
o
Is it possible to write a sensor for an asset, which has a 2-dimensional MultiPartitionsDef defined, receiving a MultiPartitionKey through its context, to generate a run request with the MultiPartitionKey?
s
hey Oliver - is your sensor targeting an
asset_selection
or a
job
?
I created a Github Discussion to answer this, because I think the answer will be useful for others too: https://github.com/dagster-io/dagster/discussions/12598
o
Hey Sandy,
My sensor is targeting in asset job, created by define_asset_job, which has a selection parameter defined, which should work, as I assume intuitively, as
asset_selection
defined in a sensor decorator. Many thanks for creating this github discussion. I will follow up the helpful example given. Following the source code I was inclined to do just that, (handing over the partitions def to the tags parameter in a RunRequest). So I was on the right way. I was actually hoping for a predefined function like run_request_for_partition which accepts a MultiPartitionKey as a "parition key" and not only a "str". That could be handy, would you agree?
s
MultiPartitionKey
is a subclass of string, so you can provide one to
run_request_for_partition
o
yes, I figuered this out 😉
I was first confused that this is a subclass of str