Do asset and run status sensors not support partit...
# ask-community
s
Do asset and run status sensors not support partitions? I don't see anything about partitions in their API docs
s
Hey Simon - the
asset_sensor
decorator currently doesn't support partitions, but here's an example of of a custom partition-based asset sensor: https://github.com/dagster-io/dagster/discussions/7306. The example uses software-defined assets, but the sensor implementation in it doesn't depend on software-defined assets to function. I'm curious to hear when you'd want your asset sensor to trigger, with respect to partitions.
s
👍 That sounds perfect, I'll give that a try tomorrow.
I think we're still trying to get a better feeling for the interaction between sensors and partitions and what would be our ideal combination. I'll definitely let you know.
👍 1
d
Hey guys, any updates on this topic? I assume partitions aren't supported yet?
s
Hey Daniel - no updates yet
d
Thanks! Is the snippet above still the recommended way to check if a partition has been materialized? Lets say I have a job that materializes daily partitions of data on schedule. I want to inference an ML model as soon as the latest partition is materialized. Would a sensor be a correct way to do it? I don't want to make a complete job for data materialization + model inference since it will unnecessarily trigger the data part. As I understand, I need to make 2 separate jobs (actually even 3 with another one being model training) and bind them together with a sensor.
s
Is the snippet above still the recommended way to check if a partition has been materialized?
It is (though I just made a small edit). Let me know if it doesn't work for you.
I don't want to make a complete job for data materialization + model inference since it will unnecessarily trigger the data part. As I understand, I need to make 2 separate jobs (actually even 3 with another one being model training) and bind them together with a sensor.
Exactly
d
Looks like I need a way to use
PartitionsMapping
inside sensors. I'm not sure how to achieve this with the example above since the
AssetKey
doesn't have this information. What would be a good way to do this?
s
if you have an
AssetsDefinition
object, you can call its
get_partition_mapping
method: https://github.com/dagster-io/dagster/blob/master/python_modules/dagster/dagster/core/definitions/assets.py#L491. Would that work for you?
d
damn, thank you!