Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate full model name in the deprecate model flow #427

Merged
merged 22 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gto/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def assert_name_is_valid(value):
if not check_string_is_valid(value, regex=name_re):
raise ValidationError(
f"Invalid value '{value}'. Only letters, numbers, '_', '-', '/' are allowed."
"Value must be of len >= 2 and must start and end with a letter or a number."
" Value must be of len >= 2 and must start and end with a letter or a number."
)


Expand All @@ -81,7 +81,7 @@ def assert_fullname_is_valid(value):
# fix error message to be regex-specific
raise ValidationError(
f"Invalid value '{value}'. Only letters, numbers, '_', '-', '/' are allowed."
"Value must be of len >= 2 and must start and end with a letter or a number."
" Value must be of len >= 2 and must start and end with a letter or a number."
)


Expand Down
2 changes: 2 additions & 0 deletions gto/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ def deprecate(
author: Optional[str] = None,
author_email: Optional[str] = None,
) -> Optional[Deprecation]:
"""Deprecate artifact"""
assert_fullname_is_valid(name)
if force:
if simple:
raise WrongArgs("Can't use 'force' with 'simple=True'")
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ def test_assign(repo_with_commit: str):
)


def test_deprecate_artifact(repo_with_commit: str):
_check_failing_cmd(
"deprecate",
["-r", repo_with_commit, "a4!"],
"❌ Invalid value 'a4!'."
" Only letters, numbers, '_', '-', '/' are allowed."
" Value must be of len >= 2 and must start and end with a letter or a number.\n",
)


GTO_EXCEPTION_MESSAGE = "Test GTOException Message"


Expand Down
Loading