https://dagster.io/ logo
#dagster-support
Title
# dagster-support
a

Archie Kennedy

05/15/2023, 5:42 PM
Hello all! I have 2 op-based jobs (no software-defined assets): •
deploy_models
use_models
The
deploy_models
job contains an op that materializes an asset:
Copy code
context.log_event(
    AssetMaterialization(
        asset_key="my_cool_model",
        description=f"Deployed ML model for code inference",
        metadata={
            "target_uri": "<s3://bucket/model.tar.gz>",
        },
    )
)
This adds the
my_cool_model
asset to the catalog, nice! Now, from inside the
use_models
job, I want to load the metadata (“target_uri”) of the latest materialization of the
my_cool_model
asset. Is this possible?
j

jamie

05/15/2023, 5:52 PM
hey @Archie Kennedy you should be able to do this by querying the dagster instance. It’s a bit burried, but I think this should work
Copy code
@op 
def use_models(context):
        context.instance.get_latest_materialization_event(AssetKey(["my_cool_model"])).dagster_event.event_specific_data.materialization.metadata
🙏 1
🌈 1
a

Archie Kennedy

05/15/2023, 6:00 PM
Wow, that works perfectly. You saved my bacon!
2 Views