Skip to content

Commit

Permalink
remove validate_asset_key_string (#7811)
Browse files Browse the repository at this point in the history
  • Loading branch information
sryza committed May 11, 2022
1 parent bb75f3b commit d60c3c8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
9 changes: 0 additions & 9 deletions python_modules/dagster/dagster/core/definitions/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import dagster._check as check
import dagster.seven as seven
from dagster.core.errors import DagsterInvalidAssetKey
from dagster.serdes import DefaultNamedTupleSerializer, whitelist_for_serdes
from dagster.utils.backcompat import experimental_class_param_warning

Expand All @@ -37,18 +36,10 @@
if TYPE_CHECKING:
from dagster.core.execution.context.output import OutputContext

ASSET_KEY_REGEX = re.compile("^[a-zA-Z0-9_.-]+$") # alphanumeric, _, -, .
ASSET_KEY_SPLIT_REGEX = re.compile("[^a-zA-Z0-9_]")
ASSET_KEY_STRUCTURED_DELIMITER = "."


def validate_asset_key_string(s: Optional[str]) -> str:
if not s or not ASSET_KEY_REGEX.match(s):
raise DagsterInvalidAssetKey()

return s


def parse_asset_key_string(s: str) -> List[str]:
return list(filter(lambda x: x, re.split(ASSET_KEY_SPLIT_REGEX, s)))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
import pytest

from dagster import AssetKey, AssetMaterialization, Output, job, op
from dagster.core.definitions.events import parse_asset_key_string, validate_asset_key_string
from dagster.core.errors import DagsterInvalidAssetKey
from dagster.core.definitions.events import parse_asset_key_string
from dagster.core.events.log import EventLogEntry
from dagster.core.instance import DagsterInstance, InstanceRef
from dagster.core.storage.event_log.migration import ASSET_KEY_INDEX_COLS
from dagster.utils import file_relative_path
from dagster.utils.test import copy_directory


def test_validate_asset_key_string():
assert validate_asset_key_string("H3_lL0.h-1") == "H3_lL0.h-1"
with pytest.raises(DagsterInvalidAssetKey):
validate_asset_key_string("(Hello)")


def test_structured_asset_key():
asset_parsed = AssetKey(parse_asset_key_string("(Hello)"))
assert len(asset_parsed.path) == 1
Expand Down

0 comments on commit d60c3c8

Please sign in to comment.