https://dagster.io/ logo
Title
d

Drew You

05/11/2023, 6:45 PM
I have metadata on assets in my graph and I'm trying to query that metadata through the graphql endpoint. However, the
metadataEntries
are empty for all of my asssets. example query:
query RepositoriesQuery {
      repositoriesOrError {
        ... on RepositoryConnection {
          nodes {
            name
            assetNodes{
                assetKey {
                  path
                }
                metadataEntries {
                    label
                    description
                }
     ...
response has
metadataEntires:[]
for all assets despite seeing metadata in dagit.
:dagster-bot-resolve: 1
s

sean

05/11/2023, 6:47 PM
Hi Drew, Are you able to create a minimal repro case? Like a
Definitions
object with one asset with metadata that is displaying this behavior.
d

Drew You

05/11/2023, 6:55 PM
Is there a simple dagster example repo somewhere? All the examples require environment variables and deployments and whatnot
But right now, I add metadata to all of my assets with
context.add_output_metadata()
in the
io-manager
and none of them have
metadataEntries
s

sean

05/11/2023, 7:19 PM
Ah-- that’s because
context.add_output_metadata
does not add metadata to the assets definition. That puts metadata on the
AssetMaterialization
event. The metadata on the definition, which is what you’re querying in that GQL query, is set like this (also an example of a simple example of the kind I’m talking about):
from dagster import asset, Definitions

@asset(metadata={"foo": "bar"})
def foo_asset():
    return 1

defs = Definitions(
    assets=[foo_asset]
)
Put that in a file and run
dagster dev -f path/to/file
and your query should return the correct metadata.
d

Drew You

05/11/2023, 7:59 PM
is there a way to define asset metadata at output time in the io-manager?
s

sean

05/11/2023, 9:29 PM
There is not, but I think if you’re trying to do this you might have a fundamantal misconception of Dagster’s model. Dagster
AssetsDefinition
objects are basically wrappers around ops. They are a unit for buliding your data pipelines. They are defined when you load the code location, along with ops, jobs etc. They are not changed by Dagster runs. What is generated by runs are events. An
AssetMaterialization
is a kind of event, generated every time an asset’s materialization function is run. You modify the materialization generated by the current run when you use
add_output_metadata
.
d

Drew You

05/15/2023, 1:19 PM
So, I'm now doing
assetMaterializations {
              timestamp
              metadataEntries {
                label
                description
              }
              partition
            }
I'm getting the correct labels but all of the
description
fields are
None
in the graphql response despite being populated in the dagit ui?
image.png
And from the
graphql
front-end (as well as from a python gql request):
"path": [
                  "funding_rates_and_info"
                ]
              },
              "assetMaterializations": [
                {
                  "timestamp": "1684156958695",
                  "metadataEntries": [
                    {
                      "label": "uri",
                      "description": null
                    }
                  ],
                  "partition": null
                },
                {
                  "timestamp": "1683830321403",
                  "metadataEntries": [
                    {
                      "label": "path",
                      "description": null
                    }
                  ],
                  "partition": null
                }
              ],