Skip to content

How to: fetch asset materializations from the instance database #7429

Answered by sryza
sryza asked this question in Q&A
Discussion options

You must be logged in to vote

Note that the APIs mentioned here are not guaranteed to be stable across releases

If you're inside a sensor, schedule, or op, you can get the instance from the context:

instance = context.instance

If not, you can get the instance using the approach described here: #7427.

Once you have the instance, you can query the events:

from dagster.core.storage.event_log.base import EventRecordsFilter
from dagster.core.events import DagsterEventType

for record in instance.get_event_records(
    EventRecordsFilter(event_type=DagsterEventType.ASSET_MATERIALIZATION), limit=5
):
    materialization = record.asset_materialization
    asset_key = materialization.asset_key
    metadata = materialization.me…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sryza
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant