Implementation:PrefectHQ Prefect Asset Constructor
Appearance
| Metadata | |
|---|---|
| Source | Repo: Prefect |
| Domains | Data_Engineering, Orchestration |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Concrete class for defining named data assets with unique keys provided by the Prefect library.
Description
The Asset class from prefect.assets creates named data asset identifiers. Each Asset is initialized with a key parameter using URI format. These Asset instances are then passed to the @materialize decorator to create tracked data products.
Code Reference
- Repository: https://github.com/PrefectHQ/prefect
- File:
src/prefect/assets/core.py(L36) for Asset class,examples/atproto_dashboard_with_prefect_assets.py(L63-65) for usage - Signature:
class Asset:
def __init__(self, key: str):
"""
Args:
key: Unique asset identifier using URI format (e.g., "pipeline://raw_data", "s3://bucket/path")
"""
- Import:
from prefect.assets import Asset
I/O Contract
- Inputs:
key(str, required -- unique asset URI identifier) - Outputs: Asset instance used as argument to
@materialize
Usage Example
from prefect.assets import Asset, materialize
# Define assets with descriptive keys
raw_data_asset = Asset(key="pipeline://raw_data")
processed_data_asset = Asset(key="pipeline://processed_data")
analytics_asset = Asset(key="pipeline://analytics")
# Use with @materialize
@materialize(raw_data_asset)
def fetch_raw_data() -> dict:
return {"items": ["item1", "item2"], "count": 2}
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment