Can I attach metadata to the asset key such as it ...
# ask-community
g
Can I attach metadata to the asset key such as it is accessible during instanciation of dagster/dagit (not for an asset materialization) but rather when constructing a job?
🤖 1
o
hi @geoHeil, the
metadata
field on the
@asset
decorator might be what you're looking for here. under the hood, it attaches this metadata to the corresponding OutputDefinition object, meaning the information is available before the job runs. This metadata will also be represented in Dagit on the definition page (rather than the historical view of materializations)
g
How could I access it during the definition phase? I remember that during asset materialization it was a bit convoluted.
o
unfortunately it's still a bit convoluted at definition time -- if you have:
Copy code
@asset(metadata={"foo": "bar"})
def my_asset():
    ...

my_asset.op.outs["result"].metadata == {"foo": "bar"}
what are you using this metadata for at definition time? it's possible there's a way to avoid this sort of messiness
🎉 1
g
I want to instantiate the asset groups with the super convenient from package method. For the default / standard like assets I want to construct a job and schedule. This works fine. However, for some assets I want to have a configurable schedule or no schedule at all
o
ah I see -- so you want to do something like iterate through the list, looking at some metadata to determine which job / schedule to put them in?
g
correct
o
gotcha makes sense! I think the (admittedly a bit ugly) snippet above is the best way to go about this currently, but let me know if you run into any issues w/ that
🎉 1
✅ 1