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

oliver zaufke

02/28/2023, 9:47 AM
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

sandy

02/28/2023, 7:05 PM
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

oliver zaufke

03/01/2023, 8:55 AM
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

sandy

03/01/2023, 4:28 PM
MultiPartitionKey
is a subclass of string, so you can provide one to
run_request_for_partition
o

oliver zaufke

03/01/2023, 4:33 PM
yes, I figuered this out 😉
I was first confused that this is a subclass of str