Skip to content

Commit

Permalink
Relax run_uuid validation (mlflow#1034)
Browse files Browse the repository at this point in the history
Allow run IDs to be alphanumeric strings of length 1 to 256, instead of requiring them to be strings of 32 hex chars
  • Loading branch information
eddiestudies authored and smurching committed Mar 26, 2019
1 parent c27eacb commit e6ca814
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mlflow/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

_VALID_PARAM_AND_METRIC_NAMES = re.compile(r"^[/\w.\- ]*$")

# Regex for valid run IDs: must be a 32-character hex string.
_RUN_ID_REGEX = re.compile(r"^[0-9a-f]{32}$")
# Regex for valid run IDs: must be an alphanumeric string of length 1 to 256.
_RUN_ID_REGEX = re.compile(r"^[a-zA-Z0-9][\w\-]{0,255}$")

_BAD_CHARACTERS_MESSAGE = (
"Names may only contain alphanumerics, underscores (_), dashes (-), periods (.),"
Expand Down
5 changes: 3 additions & 2 deletions tests/utils/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ def test_validate_tag_name():


def test_validate_run_id():
for good_id in ["a" * 32, "f0" * 16, "abcdef0123456789" * 2]:
for good_id in ["a" * 32, "f0" * 16, "abcdef0123456789" * 2, "a" * 33, "a" * 31,
"a" * 256, "A" * 32, "g" * 32, "a_" * 32, "abcdefghijklmnopqrstuvqxyz"]:
_validate_run_id(good_id)
for bad_id in ["a" * 33, "a" * 31, "A" * 32, "g" * 32, "a/bc" * 8, "_" * 32]:
for bad_id in ["a/bc" * 8, "", "a" * 400, "*" * 5]:
with pytest.raises(MlflowException, match="Invalid run ID") as e:
_validate_run_id(bad_id)
assert e.value.error_code == ErrorCode.Name(INVALID_PARAMETER_VALUE)
Expand Down

0 comments on commit e6ca814

Please sign in to comment.