From 96c6d9de6c61aa6fa40e98c1df27f204f3bf28be Mon Sep 17 00:00:00 2001 From: tapadipti <32855442+tapadipti@users.noreply.github.com> Date: Thu, 26 Oct 2023 08:22:22 +0545 Subject: [PATCH] Validate full model name in the deprecate model flow (#427) Earlier, the model name was not being validated for the deprecate model action. It was getting validated for all other actions including the unassign and deregister actions (which are variations of the deprecate action). Resolves https://github.com/iterative/dvc/issues/9821#issuecomment-1755122434 --- gto/constants.py | 4 ++-- gto/registry.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gto/constants.py b/gto/constants.py index e51915cd..c0a391f2 100644 --- a/gto/constants.py +++ b/gto/constants.py @@ -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." ) @@ -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." ) diff --git a/gto/registry.py b/gto/registry.py index ba1ff944..380d491b 100644 --- a/gto/registry.py +++ b/gto/registry.py @@ -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'")