Hello, if defined my asset as follow: ```@asset(gr...
# ask-community
g
Hello, if defined my asset as follow:
Copy code
@asset(group_name='group1',
       metadata={"owner":"Gavin Yang"})
def topstory_ids():
	newstories_url = "<https://hacker-news.firebaseio.com/v0/topstories.json>"
	top_new_story_ids = requests.get(newstories_url).json()[:100]
	return top_new_story_ids
And I want to retrieve the ‘metadata’ field I passed in, how should I do this? Appreciate for any help!
dagster bot responded by community 1
l
The metadata in the decorator is about the decorated function. If you want to use it inside the function you should use config map or a factory function instead.
g
I do not mean using that value inside the function. Instead, I want to create a run_failure_sensor that listen on the failure job. Once a job fail, I want to retrieve which asset the step fails, and then retrieve the ‘owner’ from the asset metadata field. I tried to use instance.get_asset_records(), but it seems like it does not contain the metadata field I passed into the decorator.
l
I'm not at home to check, I'd think run status sensor context or event would get you to the asset/op definition to retrieve the metadata associated with the failed run. Following.
💡 1
g
Hi, I have checked the run_status_sensor as well as RunStatusSensorContext, but still not sure how to retrieve the metadata associated with asset/op definition.
l
Bummer. Maybe some Dagster engineer can chime in. I'd hate having to query the database for such information. Did you by chance check if you can access metadata recorded in the Output?
g
Yes, if the asset return Output at end with a ‘metadata’ field inside, then I see the metadata of each success asset using get_run_records(), but it still does not contain the metadata specified in the asset definition.