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

Aleksi Knuutila

05/01/2023, 9:58 AM
Hi, thanks for the amazing software! Is there a straightforward way to list partitions of an asset that are missing? (Ie. haven’t been materialized or don’t have runs that have failed?) I could probably get list of all partition keys, then go through event logs and see which keys don’t have events associated with them. But ideally I wouldn’t want to implement this myself :)
c

claire

05/01/2023, 6:08 PM
Hi Aleksi. I think the most straightforward way is still to fetch the events, though I can provide an (untested) code snippet if it helps:
Copy code
partitions_to_fetch = partitions_def.get_partition_keys(...)
        
partition_materializations = context.instance.get_event_records(
    EventRecordsFilter(
        event_type=DagsterEventType.ASSET_MATERIALIZATION,
        asset_key=asset_key,
        asset_partitions=partitions_to_fetch,
    ),
)

materialized_keys = set(materialization.partition_key for materialization in partition_materializations)
unmaterialized_keys = set(partitions_to_fetch) - set(materialized_keys)
2 Views