https://dagster.io/ logo
Title
q

Qwame

11/22/2022, 8:25 PM
Hello friends, If I add metadata to my materialization using
context.add_input_metadata
, how do I access the metadata in another run. I currently use this to get metadata that was added using
context.add_output_metadata
latest_materialization_event = self.init_context.instance.get_latest_materialization_events(
            [asset_key]
        ).get(asset_key)

        <http://context.log.info|context.log.info>(latest_materialization_event)
        if latest_materialization_event:
            materialization = (
                latest_materialization_event.dagster_event.event_specific_data.materialization
            )
            metadata = {entry.label: entry.entry_data for entry in materialization.metadata_entries}
Wondering if there is a way to get
context.add_input_metadata
metadata?
:dagster-bot-resolve: 1
s

sandy

11/22/2022, 10:20 PM
@claire - do we have straightforward ways to fetch the
AssetObservation
events that get created?
c

claire

11/22/2022, 10:25 PM
Currently the only way to fetch the created asset observation events is to query the instance:
instance.get_event_records(
        EventRecordsFilter(
            event_type=DagsterEventType.ASSET_OBSERVATION,
            asset_key=asset_key,
        ),
        limit=limit,
    )
q

Qwame

11/23/2022, 9:46 PM
Thanks @claire, this works perfectly!