Skip to content

How do I find all the asset materializations for a run? #14613

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

You must be logged in to vote

You'll need a DagsterInstance object to access the Dagster database. You can get a DagsterInstance from any context variable, or via DagsterInstance.get.

Then, you can use get_records_for_run.

from typing import Sequence, cast
from dagster import AssetMaterialization, DagsterEventType, DagsterInstance


def get_assets_materializations_for_run(instance: DagsterInstance, run_id: str) -> Sequence[AssetMaterialization]:
    materialization_records = instance.get_records_for_run(
        run_id=run_id, of_type=DagsterEventType.ASSET_MATERIALIZATION
    ).records
    return [record.asset_materialization for record in materialization_records]

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