Ask AI

Op job metadata#

Metadata allows you to attach information to op jobs and the runs launched from those jobs. By the end of this guide, you'll understand what metadata is, how to attach it to an op job, and how to view the job metadata in the Dagster UI.


How it works#

Attaching metadata to a job is done using the metadata argument and a dictionary of key/value pairs. Keys must be a string, but values can:

  • Be any of the MetadataValue classes provided by Dagster
  • Primitive Python types, which Dagster will convert to the appropriate MetadataValue

The information you provide can be whatever you want, but possible cases include:

  • Keeping track of the team responsible for maintaining a job
  • Linking to documentation or other resources
  • Displaying the git hash corresponding to the current job definition

Note: If you are running Dagster using separate webserver and user code installations (more info here), then your dagster-webserver installation must be >=0.14.18 to use metadata on jobs.


Specifying op job metadata#

Using the @job decorator#

@op
def my_op():
    return "Hello World!"


@job(
    metadata={
        "owner": "data team",  # will be converted to MetadataValue.text
        "docs": MetadataValue.url("https://docs.dagster.io"),
    }
)
def my_job_with_metadata():
    my_op()

Using the to_job method#

In addition to adding metadata on the @job decorator, you can also add metadata using the GraphDefinition.to_job method:

@graph
def my_graph():
    my_op()


my_second_job_with_metadata = my_graph.to_job(
    metadata={"owner": "api team", "docs": MetadataValue.url("https://docs.dagster.io")}
)

Applying tags#

Tags can also be used to attach information to jobs. Refer to the Tags documentation for more information.


Viewing op job metadata in the Dagster UI#

After attaching metadata to a job, you can view it in the Dagster UI by navigating to the Job overview page. Metadata will be displayed in the right pane.

job-metadata.png