Skip to content

Commit

Permalink
Coerce asset_key on AssetIn (#8009)
Browse files Browse the repository at this point in the history
  • Loading branch information
aroig committed May 23, 2022
1 parent f51d7e6 commit 515e194
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python_modules/dagster/dagster/core/asset_defs/asset_in.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Mapping, NamedTuple, Optional, Sequence

import dagster._check as check
from dagster.core.definitions.events import AssetKey
from dagster.core.definitions.events import AssetKey, CoerceableToAssetKey


class AssetIn(
Expand All @@ -16,7 +16,7 @@ class AssetIn(
):
def __new__(
cls,
asset_key: Optional[AssetKey] = None,
asset_key: Optional[CoerceableToAssetKey] = None,
metadata: Optional[Mapping[str, Any]] = None,
namespace: Optional[Sequence[str]] = None,
):
Expand All @@ -30,7 +30,7 @@ def __new__(

return super(AssetIn, cls).__new__(
cls,
asset_key=check.opt_inst_param(asset_key, "asset_key", AssetKey),
asset_key=AssetKey.from_coerceable(asset_key) if asset_key is not None else None,
metadata=check.opt_inst_param(metadata, "metadata", Mapping),
namespace=check.opt_list_param(namespace, "namespace", str),
)
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,9 @@ def my_multi_asset():
description="ablablabl",
),
]


def test_coerced_asset_keys():
@asset(ins={"input1": AssetIn(asset_key=["Asset", "1"])})
def asset1(input1):
assert input1

0 comments on commit 515e194

Please sign in to comment.