-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Update the client to allow for retrieving the latest
alias
#12342
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
latest
alias
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4729,5 +4729,5 @@ def print_model_version_info(mv): | |
Aliases: ["test-alias"] | ||
""" | ||
_validate_model_name(name) | ||
_validate_model_alias_name(alias) | ||
_validate_model_alias_name(alias, perform_latest_check=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does make sense to remove validation from this client codepath (and in |
||
return self._get_registry_client().get_model_version_by_alias(name, alias) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -397,7 +397,7 @@ def _validate_model_version(model_version): | |
) | ||
|
||
|
||
def _validate_model_alias_name(model_alias_name): | ||
def _validate_model_alias_name(model_alias_name, perform_latest_check=True): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can probably get rid of this boolean / |
||
if model_alias_name is None or model_alias_name == "": | ||
raise MlflowException( | ||
"Registered model alias name cannot be empty.", INVALID_PARAMETER_VALUE | ||
|
@@ -410,7 +410,7 @@ def _validate_model_alias_name(model_alias_name): | |
_validate_length_limit( | ||
"Registered model alias name", MAX_REGISTERED_MODEL_ALIAS_LENGTH, model_alias_name | ||
) | ||
if model_alias_name.lower() == "latest": | ||
if perform_latest_check and model_alias_name.lower() == "latest": | ||
raise MlflowException( | ||
"'latest' alias name (case insensitive) is reserved.", INVALID_PARAMETER_VALUE | ||
) | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||
import copy | ||||||
|
||||||
import pytest | ||||||
|
||||||
|
@@ -59,7 +59,7 @@ | |||||
"temp_V123", | ||||||
] | ||||||
|
||||||
BAD_ALIAS_NAMES = [ | ||||||
BAD_ALIAS_NAMES_WITHOUT_LATEST = [ | ||||||
"", | ||||||
".", | ||||||
"/", | ||||||
|
@@ -76,12 +76,14 @@ | |||||
"a" * 256, | ||||||
None, | ||||||
"$dgs", | ||||||
"latest", | ||||||
"Latest", | ||||||
"v123", | ||||||
"V1", | ||||||
] | ||||||
|
||||||
LATEST_TESTS = ["latest", "Latest"] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want all caps as well?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. I can add. |
||||||
|
||||||
BAD_ALIAS_NAMES = BAD_ALIAS_NAMES_WITHOUT_LATEST + LATEST_TESTS | ||||||
|
||||||
|
||||||
@pytest.mark.parametrize( | ||||||
("path", "expected"), | ||||||
|
@@ -165,6 +167,14 @@ | |||||
_validate_model_alias_name(alias_name) | ||||||
assert e.value.error_code == ErrorCode.Name(INVALID_PARAMETER_VALUE) | ||||||
|
||||||
@pytest.mark.parametrize("alias_name", BAD_ALIAS_NAMES_WITHOUT_LATEST) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update this to just be BAD_ALIAS_NAMES |
||||||
def test_validate_model_alias_name_bad_but_allow_latest(alias_name): | ||||||
if alias_name not in LATEST_TESTS: | ||||||
with pytest.raises(MlflowException, match="alias name") as e: | ||||||
_validate_model_alias_name(alias_name, perform_latest_check=False) | ||||||
assert e.value.error_code == ErrorCode.Name(INVALID_PARAMETER_VALUE) | ||||||
else: | ||||||
_validate_model_alias_name(alias_name) | ||||||
|
||||||
@pytest.mark.parametrize( | ||||||
"run_id", | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From offline discussion, we don't want to remove validation from the OSS storage backends (file/SQL store)