Skip to content

Commit

Permalink
add to asset spec
Browse files Browse the repository at this point in the history
  • Loading branch information
benpankow committed May 22, 2024
1 parent 2381e0b commit 8ee5f8e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import dagster._check as check
from dagster._annotations import PublicAttr, experimental_param
from dagster._core.definitions.tags import StorageKindTagSet
from dagster._serdes.serdes import whitelist_for_serdes

from .auto_materialize_policy import AutoMaterializePolicy
Expand Down Expand Up @@ -117,12 +118,18 @@ def __new__(
auto_materialize_policy: Optional[AutoMaterializePolicy] = None,
owners: Optional[Sequence[str]] = None,
tags: Optional[Mapping[str, str]] = None,
storage_kind: Optional[str] = None,
):
from dagster._core.definitions.asset_dep import coerce_to_deps_and_check_duplicates

key = AssetKey.from_coercible(key)
asset_deps = coerce_to_deps_and_check_duplicates(deps, key)

all_tags = {
**(tags or {}),
**(StorageKindTagSet(storage_kind=storage_kind) if storage_kind else {}),
} or None

return super().__new__(
cls,
key=key,
Expand All @@ -143,5 +150,5 @@ def __new__(
AutoMaterializePolicy,
),
owners=check.opt_sequence_param(owners, "owners", of_type=str),
tags=validate_tags_strict(tags),
tags=validate_tags_strict(all_tags),
)
Original file line number Diff line number Diff line change
Expand Up @@ -2248,6 +2248,20 @@ def assets2(): ...


def test_multi_assets_asset_spec_with_storage_kind_override() -> None:
@multi_asset(
specs=[
AssetSpec("asset1"),
AssetSpec("asset2", storage_kind="bigquery"),
],
storage_kind="snowflake",
)
def assets2(): ...

assert assets2.tags_by_key[AssetKey("asset1")] == {"dagster/storage_kind": "snowflake"}
assert assets2.tags_by_key[AssetKey("asset2")] == {"dagster/storage_kind": "bigquery"}


def test_multi_assets_asset_spec_with_storage_kind_tag_override() -> None:
@multi_asset(
specs=[
AssetSpec("asset1"),
Expand Down

0 comments on commit 8ee5f8e

Please sign in to comment.