Skip to main content
Both @materialize and asset_deps accept either a string referencing an asset key or a full Asset class instance. Using the Asset class is the way to provide additional metadata like names, descriptions, and ownership information beyond just the key.

The Asset class

While you can use simple string keys with the @materialize decorator, the Asset class provides more control over asset properties and metadata. Create Asset instances to add organizational context and improve discoverability.

Asset initialization fields

The Asset class accepts the following parameters:
  • key (required): A valid URI that uniquely identifies your asset. This is the only required field.
  • properties (optional): An AssetProperties instance containing metadata about the asset.
Each of these fields will be displayed alongside the asset in the UI.
Interactive fieldsThe owners field can optionally reference user emails, as well as user and team handles within your Prefect Cloud workspace. The URL field becomes a clickable link when this asset is displayed.
Updates occur at runtimeUpdates to asset metadata are always performed at workflow runtime whenever a materializing task is executed that references the asset.

Using assets in materializations

Once you’ve defined your Asset instances, use them directly with the @materialize decorator:

Adding runtime metadata

Beyond static properties, you can add dynamic metadata during task execution. This is useful for tracking runtime information like row counts, processing times, or data quality metrics.

Using Asset.add_metadata()

The preferred approach is to use the add_metadata() method on your Asset instances. This prevents typos in asset keys and provides better IDE support:

Using add_asset_metadata() utility

Alternatively, you can use the add_asset_metadata() function, which requires specifying the asset key:

Accumulating metadata

You can call metadata methods multiple times to accumulate information:

Explicit asset dependencies

While Prefect automatically infers dependencies from your task graph, you can explicitly declare asset relationships using the asset_deps parameter. This is useful when:
  • The task graph doesn’t fully capture your data dependencies due to dynamic execution rules
  • You need to reference assets that aren’t directly passed between tasks
  • You want to be explicit about critical dependencies for documentation purposes

Hard-coding dependencies

Use asset_deps to explicitly declare which assets your materialization depends on. You can reference assets by key string or by full Asset instance:

Mixing inferred and explicit dependencies

You can combine task graph inference with explicit dependencies:

Best practices for asset_deps references

Use string keys when referencing assets that are materialized by other Prefect workflows. This avoids duplicate metadata definitions and lets the materializing workflow be the source of truth:
Use full Asset instances when referencing assets that are completely external to Prefect. This provides metadata about external systems that Prefect wouldn’t otherwise know about:

Updating asset properties

Asset properties should have one source of truth to avoid conflicts. When you materialize an asset with properties, those properties perform a complete overwrite of all metadata fields for that asset.
ImportantAny Asset instance with properties will completely replace all existing metadata. Partial updates are not supported - you must provide all the metadata you want to preserve.
Best practiceDesignate one workflow as the authoritative source for each asset’s metadata. Other workflows that reference the asset should use string keys only to avoid conflicting metadata definitions.

Further Reading