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

Charles Lariviere

05/04/2022, 5:42 PM
Hey 👋 I’m wondering how to pass metadata known only at runtime for software-defied assets. The docs seem to indicate that yielding an
AssetMaterialization
within an
@asset
decorated function is not expected (see Software-defined assets vs. Asset Materializations) — is that correct? I would like, for instance, to pass the execution time in seconds and the number of items materialized by my asset.
p

prha

05/04/2022, 5:45 PM
cc @owen I think you can emit an
Output
event instead of just returning your value, which will allow you to specify metadata on it.
a

alex

05/04/2022, 5:45 PM
I think
context.add_output_metadata
may also be an option
themoreyouknow 1
c

Charles Lariviere

05/04/2022, 5:46 PM
Ah interesting! I explicitly yielded a
AssetMaterialization
, but then 2 materialization events get logged since the asset itself logs one by default. I will give that a try — thanks! 🙏
p

prha

05/04/2022, 5:48 PM
context.add_output_metadata
is probably the preferred approach
c

Charles Lariviere

05/04/2022, 5:49 PM
Very cool — indeed
context.add_output_metadata
works as expected! 🙌
2 Views