Skip to content

Commit

Permalink
change artifact name regex (#398)
Browse files Browse the repository at this point in the history
~Having an issue with tests, but opening this for discussion in the
meantime.~

The PR adds support for uppercase letters and `_`. I decided against
support for `.` because there are some restrictions around how it can be
used in [git refs](https://git-scm.com/docs/git-check-ref-format).

Related: iterative/dvc#9821

TODO:
- [x] Tests
- [ ] DVC PR
- [ ] DVCLive PR to improve
[warning](https://github.com/iterative/dvclive/blob/95000f45638d5126b7d76833050f549167a7449d/src/dvclive/live.py#L462-L466)
- [ ] Docs PR
  • Loading branch information
dberenbaum authored Sep 8, 2023
1 parent d6a1634 commit 3b3dec1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gto/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def tag_to_name(value):


dirname = "[a-z0-9-_./]+" # improve?
name = r"[a-z0-9]([a-z0-9-/]*[a-z0-9])?"
name = r"[a-z0-9]([a-z0-9-/_]*[A-Za-z0-9])?"
semver = r"(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"
counter = "?P<counter>[0-9]+"
name_re = re.compile(f"^{name}$")
Expand Down
4 changes: 3 additions & 1 deletion tests/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"1nn",
"model-prod",
"model-prod-v1",
"model_prod_v1",
"dvclive/model",
],
)
Expand All @@ -33,12 +34,13 @@ def test_check_name_is_valid(name):
"###",
"@@@",
"a model",
"a_model",
"_model",
"-model",
"model-",
"model@1",
"model#1",
"@namespace/model",
"DVCLive/Model",
],
)
def test_check_name_is_invalid(name):
Expand Down

0 comments on commit 3b3dec1

Please sign in to comment.