Selene Hines
12/13/2022, 1:12 AM# in some op
context.log_event(
AssetMaterialization(
asset_key=AssetKey("foo"),
description="Persisted result to storage.",
metadata={
"text_metadata": "Text-based metadata for this event",
}
)
)
# in a sensor (or op execution context)
foo_event_records = context.instance.get_event_records(
EventRecordsFilter(
event_type=DagsterEventType.ASSET_MATERIALIZATION,
asset_key=AssetKey(["foo"]),
),
ascending=False,
)
# get text_metadata from return foo_event_records
When I print out the event records, I can see the stored metadata values for each event record, but I don't want to parse that text, if there's an easy helper function that will get me the metadata values easily?jamie
12/13/2022, 5:41 PMget_event_records
is a list of EventLogRecord
s. which in turn have a property asset_materialization
which should reconstruct the materialization with the metadata. so i think something like this would work
foo_event_records = context.instance.get_event_records(
EventRecordsFilter(
event_type=DagsterEventType.ASSET_MATERIALIZATION,
asset_key=AssetKey(["foo"]),
),
ascending=False,
)
for event in foo_event_records:
metadata = event.asset_materialization.metadata
# whatever you want to do with the metadata
Selene Hines
12/13/2022, 9:33 PM