https://dagster.io/ logo
#ask-community
Title
# ask-community
c

Casper Weiss Bang

01/02/2023, 8:16 AM
Can i get access to the metadata of an asset/job/op in a sensor? based on meta data i'd prefer to do different things, if possible.
🤖 1
it was possible by getting the asset definition and using
metadata_by_key
for the static metadata, and a attribute on the event for the run-time metadata
m

Martin Peak

03/13/2023, 7:48 AM
id like to be able to do this - how did you get the asset definition in the sensor?
c

Casper Weiss Bang

03/13/2023, 7:49 AM
I'll have to look through our git history. gimme a sec
metadata = asset.metadata_by_key.get(asset_key)
and i got the asset via
asset = context.assets_defs_by_key[asset_key]
(remember to assert that these things are not None). And the asset key, for completion sake:
Copy code
for (
            asset_key,
            materialization,
        ) in context.latest_materialization_records_by_key().items():
m

Martin Peak

03/13/2023, 7:54 AM
wow great thanks! will give that a go
6 Views