Arun Kumar
07/19/2021, 4:48 AMevents_for_asset_key
, but I am still not sure how to get the partition info from the Asset key to pass it in the run request. The returned EventLogEntry
does not have the partition info. Is there any other method that I can use?prha
07/19/2021, 4:51 PMAssetMaterialization
itself. You should be able to access it like this:
events = instance.events_for_asset_key(my_asset_key, limit=1)
if not events:
return
record_id, event = events[0]
materialization = event.dagster_event.step_materialization_data.materialization
partition = materialization.partition
I should also note that as of 0.12.0
the instance method events_for_asset_key
is deprecated in favor of get_event_records
. Using this new API, the above code would look like this:
from dagster import DagsterEventType, EventRecordsFilter
records = instance.get_event_records(
EventRecordsFilter(event_type=DagsterEventType.ASSET_MATERIALIZATION, asset_key=my_asset_key),
limit=1
)
if not records:
return
event = records[0].event_log_entry
materialization = event.dagster_event.step_materialization_data.materialization
partition = materialization.partition
Arun Kumar
07/19/2021, 8:58 PMget_event_records
and thanks again for sharing the code for get_event_records.