Skip to content

Commit 8f90c70

Browse files
authored
Support single tag (#144)
* Support single tag
1 parent 0d5d1eb commit 8f90c70

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

mlc/action.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def rm(self, i):
323323
if item_name:
324324
inp['alias'] = item_name
325325
inp['folder_name'] = item_name #we dont know if the user gave the alias or the folder name, we first check for alias and then the folder name
326-
if self.is_uid(item_name):
326+
if utils.is_uid(item_name):
327327
inp['uid'] = item_name
328328
elif item_id:
329329
inp['uid'] = item_id
@@ -479,21 +479,6 @@ def update(self, i):
479479

480480
return {'return': 0, 'message': f"Tags updated successfully for {len(found_items)} item(s).", 'list': found_items }
481481

482-
def is_uid(self, name):
483-
"""
484-
Checks if the given name is a 16-digit hexadecimal UID.
485-
486-
Args:
487-
name (str): The string to check.
488-
489-
Returns:
490-
bool: True if the name is a 16-digit hexadecimal UID, False otherwise.
491-
"""
492-
# Define a regex pattern for a 16-digit hexadecimal UID
493-
hex_uid_pattern = r"^[0-9a-fA-F]{16}$"
494-
495-
# Check if the name matches the pattern
496-
return bool(re.fullmatch(hex_uid_pattern, name))
497482

498483

499484
def cp(self, run_args):
@@ -519,7 +504,7 @@ def cp(self, run_args):
519504
inp['alias'] = src_item
520505
inp['folder_name'] = src_item #we dont know if the user gave the alias or the folder name, we first check for alias and then the folder name
521506

522-
if self.is_uid(src_item):
507+
if utils.is_uid(src_item):
523508
inp['uid'] = src_item
524509
src_id = src_item
525510
else:
@@ -678,7 +663,7 @@ def search(self, i):
678663
alias = details_split[0]
679664
uid = details_split[1]
680665
else:
681-
if self.is_uid(details_split[0]):
666+
if utils.is_uid(details_split[0]):
682667
uid = details_split[0]
683668
else:
684669
alias = details_split[0]

mlc/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def main():
228228
run_args['target'] = 'script' #allowing run to be used for docker run instead of docker script
229229
args.target = "script"
230230

231-
if hasattr(args, 'details') and args.details and "," in args.details and not run_args.get("tags") and args.target in ["script", "cache"]:
231+
if hasattr(args, 'details') and args.details and not utils.is_uid(args.details) and not run_args.get("tags") and args.target in ["script", "cache"]:
232232
run_args['tags'] = args.details
233233

234234
if not run_args.get('details') and args.details:

mlc/repo_action.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def find(self, run_args):
188188
repo_uid = None
189189

190190
# Check if the repo is in the format of a repo UID (alphanumeric string)
191-
if self.is_uid(repo):
191+
if utils.is_uid(repo):
192192
repo_uid = repo
193193
if "," in repo:
194194
repo_split = repo.split(",")
@@ -218,7 +218,7 @@ def find(self, run_args):
218218
lst.append(i)
219219
elif repo_name == i.meta['alias']:
220220
lst.append(i)
221-
elif self.is_uid(repo) and not any(i.meta['uid'] == repo_uid for i in self.repos):
221+
elif utils.is_uid(repo) and not any(i.meta['uid'] == repo_uid for i in self.repos):
222222
return {"return": 1, "error": f"No repository with UID: '{repo_uid}' was found"}
223223
elif "," in repo and not matched_repo_path and not any(i.meta['uid'] == repo_uid for i in self.repos) and not any(i.meta['alias'] == repo_name for i in self.repos):
224224
return {"return": 1, "error": f"No repository with alias: '{repo_name}' and UID: '{repo_uid}' was found"}

mlc/utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,23 @@ def convert_args_to_dictionary(inp):
425425

426426
return {'return': 0, 'args_dict': args_dict}
427427

428+
def is_uid(name):
429+
"""
430+
Checks if the given name is a 16-digit hexadecimal UID.
431+
432+
Args:
433+
name (str): The string to check.
434+
435+
Returns:
436+
bool: True if the name is a 16-digit hexadecimal UID, False otherwise.
437+
"""
438+
# Define a regex pattern for a 16-digit hexadecimal UID
439+
hex_uid_pattern = r"^[0-9a-fA-F]{16}$"
440+
441+
# Check if the name matches the pattern
442+
return bool(re.fullmatch(hex_uid_pattern, name))
443+
444+
428445
def is_valid_url(url):
429446
pattern = re.compile(
430447
r"^(https?|ftp)://" # Protocol (http, https, ftp)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "mlcflow"
7-
version = "1.0.8"
7+
version = "1.0.9"
88

99
description = "An automation interface for ML applications"
1010
authors = [

0 commit comments

Comments
 (0)