Ask AI

You are viewing an unreleased or outdated version of the documentation

Tags#

Over time, your Dagster project may grow to include a large number of Dagster definitions. Using tags to label assets, ops, jobs, and job runs can make them easier to find.


Benefits#

Using tags helps you:

  • Organize definitions in your Dagster project
  • Improve filtering in the Dagster UI, making it easier to focus on specific items
  • Customize run execution, including run concurrency and priority

How it works#

Tags are key/value pairs of strings that can be applied to assets, ops, jobs, and job runs using the tags argument. For example:

@asset(tags={"domain": "marketing", "pii": "true"})
def leads(): ...

Tags are helpful when you need to find specific items in your Dagster project. For example, tags can be used as a filter when looking at the Asset catalog in the Dagster UI, allowing you to only see specific assets.

Tag keys#

Valid tag keys have two segments: an optional prefix and name, separated by a slash (/). Prefixes are typically expected to be Python package names. For example: dagster/priority

Prefixes and name segments must each:

  • Be 63 characters or less
  • Contain only alphanumeric characters, dashes (-), underscores (_), and dots (.)

Tag values#

Tag values must:

  • Be 63 characters or less
  • Contain only alphanumeric characters, dashes (-), underscores (_), and dots (.)
  • Be a string or JSON that is serializable to a string

Specifying tags#

Assets#

Tags are useful for organizing assets in non-hierarchical ways. Unlike asset groups, where each asset belongs to a single group, each asset can have many tags. For example:

@asset(tags={"domain": "marketing", "pii": "true"})
def leads(): ...

Other APIs that define assets can also accept tag arguments, such as AssetSpec, AssetOut, and the @graph_asset.

Jobs#

Adding tags to a job will attach them to every run executed by the job.

In some cases, Dagster will automatically add tags to runs. Refer to the System run tags reference for a list of tags.

Asset jobs#

Tags can be applied to asset jobs, which are defined using define_asset_job:

asset_job = define_asset_job(
    name="marketing_job", selection="*", tags={"dagster/max_runtime": 10}
)

Customizing run execution#

While tags are primarily used for labeling and organization, some run execution features are controlled using run tags:


Viewing tags in the Dagster UI#

View tags attached to runs by navigating to the Runs page in the UI:

tags-viewer.png

When executing a job, use the Launchpad to add tags to the run:

tag-adder.png

References#

System asset tags#

The following table lists tags which Dagster may automatically add to assets.

TagDescription
dagster/kind/{kind}A tag identifying that an asset has a specific kind. For more information, see Kind tags

System run tags#

The following table lists the tags Dagster will, on occasion, automatically add to runs.

TagDescription
dagster/op_selectionThe op selection for the run
dagster/partitionThe partition of the run
dagster/schedule_nameThe schedule that triggered the run
dagster/sensor_nameThe sensor that triggered the run
dagster/backfillThe backfill ID
dagster/parent_run_idThe parent run of a re-executed run
dagster/imageThe Docker image tag