-
Notifications
You must be signed in to change notification settings - Fork 1
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
Require semantic version for model parameter version string #1103
Changes from all commits
0ac0386
ed492ef
8476e2c
ea08df3
608f9f5
6a7dbd9
386f858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/usr/bin/python3 | ||
|
||
import logging | ||
import re | ||
import shutil | ||
import sys | ||
from importlib.resources import files | ||
|
@@ -695,3 +696,41 @@ def test_prepare_model_parameter(): | |
data_validator.data_dict["type"] = "int64" | ||
data_validator._prepare_model_parameter() | ||
assert isinstance(data_validator.data_dict["value"][0], int) | ||
|
||
|
||
def test_check_version_string(caplog): | ||
data_validator = validate_data.DataValidator() | ||
|
||
valid_versions = [ | ||
"1.0.0", | ||
"0.1.0", | ||
"2.3.4", | ||
"1.0.0-alpha", | ||
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. Related to above question. So we really want to allow this kind of version structure? 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. This is how semantic versioning is defined, see https://semver.org/ 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. Ok all good then. |
||
"1.0.0-alpha.1", | ||
"1.0.0-0.3.7", | ||
"1.0.0-x.7.z.92", | ||
"1.0.0-alpha+001", | ||
"1.0.0+20130313144700", | ||
"1.0.0-beta+exp.sha.5114f85", | ||
] | ||
|
||
for version in valid_versions: | ||
with caplog.at_level("DEBUG"): | ||
data_validator._check_version_string(version) | ||
assert f"Valid version string '{version}'" in caplog.text | ||
caplog.clear() | ||
|
||
invalid_versions = [ | ||
"1.0", | ||
"1.0.0.0", | ||
"1.0.a", | ||
"1.0.0-", | ||
"1.0.0+", | ||
"a.b.c", | ||
] | ||
|
||
for version in invalid_versions: | ||
with pytest.raises(ValueError, match=f"Invalid version string '{re.escape(version)}'"): | ||
data_validator._check_version_string(version) | ||
|
||
assert data_validator._check_version_string(None) is None |
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.
Not perfectly familiar with regex. Does this here allow also number.number.number-(additional expression)?
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.
Yes - but see also #1115