Skip to content

Commit

Permalink
update apidoc examples for AssetKey to not use ops (#20607)
Browse files Browse the repository at this point in the history
## Summary & Motivation

Most uses of AssetKey nowadays don't involve ops.

## How I Tested These Changes
  • Loading branch information
sryza authored and PedramNavid committed Mar 28, 2024
1 parent 43380f3 commit 33f4ed2
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions python_modules/dagster/dagster/_core/definitions/asset_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,19 @@ class AssetKey(NamedTuple("_AssetKey", [("path", PublicAttr[Sequence[str]])])):
.. code-block:: python
from dagster import op
@op
def emit_metadata(context, df):
yield AssetMaterialization(
asset_key=AssetKey('flat_asset_key'),
metadata={"text_metadata": "Text-based metadata for this event"},
)
@op
def structured_asset_key(context, df):
yield AssetMaterialization(
asset_key=AssetKey(['parent', 'child', 'grandchild']),
metadata={"text_metadata": "Text-based metadata for this event"},
)
@op
def structured_asset_key_2(context, df):
yield AssetMaterialization(
asset_key=AssetKey(('parent', 'child', 'grandchild')),
metadata={"text_metadata": "Text-based metadata for this event"},
)
from dagster import AssetKey
AssetKey("asset1")
AssetKey(["asset1"]) # same as the above
AssetKey(["prefix", "asset1"])
AssetKey(["prefix", "subprefix", "asset1"])
Args:
path (Sequence[str]): String, list of strings, or tuple of strings. A list of strings
represent the hierarchical structure of the asset_key.
path (Union[str, Sequence[str]]): String, list of strings, or tuple of strings. A list of
strings represent the hierarchical structure of the asset_key.
"""

def __new__(cls, path: Sequence[str]):
def __new__(cls, path: Union[str, Sequence[str]]):
if isinstance(path, str):
path = [path]
else:
Expand Down

0 comments on commit 33f4ed2

Please sign in to comment.