-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Expand file tree
/
Copy pathutil.py
More file actions
23 lines (19 loc) · 917 Bytes
/
Copy pathutil.py
File metadata and controls
23 lines (19 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def validate_modelkit_tag(modelkit_tag: str) -> bool:
"""Validate that ModelKit tag has correct format"""
# Check if modelkit_tag is valid
if not modelkit_tag or not isinstance(modelkit_tag, str):
raise ValueError("ModelKit tag must be a non-empty string")
# Validate ModelKit tag format: registry/namespace/repository:tag
if modelkit_tag.count("/") < 2 or ":" not in modelkit_tag:
raise ValueError(
"ModelKit tag must have format: registry/namespace/repository:tag"
)
# Split the tag to check individual components
path, tag_part = modelkit_tag.rsplit(":", 1)
path_parts = path.split("/")
# Ensure all parts are non-empty
if "" in path_parts or not tag_part:
raise ValueError(
"All components of ModelKit tag (registry, namespace, repository, tag) must be non-empty"
)
return True