hi all, while using dynamic partitions, are sensor...
# ask-community
b
hi all, while using dynamic partitions, are sensors the only way to populate them? if yes, i have an asset_sensor, i.e. i want to populate the partition values based on an asset. how do i access contents of the asset within the asset_sensor?
🤖 1
g
No, you can populate them pretty much anywhere afaik. I'm not sure if this is a recommended practice, but you can do it from within an asset for example:
Copy code
if not context.instance.has_dynamic_partition(
    dynamic_partition_defs.name, candidate_partition
):
    context.instance.add_dynamic_partitions(
        dynamic_partition_defs.name, [candidate_partition]
    )
b
aye, i figured if i would use a sensor i would have to load the data manually as i can't see anything in the implementation of the sensor context to offer direct access to the asset that triggered it. i guess, populating it from within the asset itself (speaking of the upstream asset) makes more sense - was just not sure about the best practice.
g
Yeah I had the same issue and went with populating in the upstream asset code. Obviously not as tolerant to failure as a sensor, would be interested to hear if someone has a better solution 😅
b
haha aye :))