Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions mlc/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def rm(self, i):
if item_name:
inp['alias'] = item_name
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
if self.is_uid(item_name):
if utils.is_uid(item_name):
inp['uid'] = item_name
elif item_id:
inp['uid'] = item_id
Expand Down Expand Up @@ -479,21 +479,6 @@ def update(self, i):

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

def is_uid(self, name):
"""
Checks if the given name is a 16-digit hexadecimal UID.

Args:
name (str): The string to check.

Returns:
bool: True if the name is a 16-digit hexadecimal UID, False otherwise.
"""
# Define a regex pattern for a 16-digit hexadecimal UID
hex_uid_pattern = r"^[0-9a-fA-F]{16}$"

# Check if the name matches the pattern
return bool(re.fullmatch(hex_uid_pattern, name))


def cp(self, run_args):
Expand All @@ -519,7 +504,7 @@ def cp(self, run_args):
inp['alias'] = src_item
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

if self.is_uid(src_item):
if utils.is_uid(src_item):
inp['uid'] = src_item
src_id = src_item
else:
Expand Down Expand Up @@ -678,7 +663,7 @@ def search(self, i):
alias = details_split[0]
uid = details_split[1]
else:
if self.is_uid(details_split[0]):
if utils.is_uid(details_split[0]):
uid = details_split[0]
else:
alias = details_split[0]
Expand Down
2 changes: 1 addition & 1 deletion mlc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def main():
run_args['target'] = 'script' #allowing run to be used for docker run instead of docker script
args.target = "script"

if hasattr(args, 'details') and args.details and "," in args.details and not run_args.get("tags") and args.target in ["script", "cache"]:
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"]:
run_args['tags'] = args.details

if not run_args.get('details') and args.details:
Expand Down
4 changes: 2 additions & 2 deletions mlc/repo_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def find(self, run_args):
repo_uid = None

# Check if the repo is in the format of a repo UID (alphanumeric string)
if self.is_uid(repo):
if utils.is_uid(repo):
repo_uid = repo
if "," in repo:
repo_split = repo.split(",")
Expand Down Expand Up @@ -218,7 +218,7 @@ def find(self, run_args):
lst.append(i)
elif repo_name == i.meta['alias']:
lst.append(i)
elif self.is_uid(repo) and not any(i.meta['uid'] == repo_uid for i in self.repos):
elif utils.is_uid(repo) and not any(i.meta['uid'] == repo_uid for i in self.repos):
return {"return": 1, "error": f"No repository with UID: '{repo_uid}' was found"}
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):
return {"return": 1, "error": f"No repository with alias: '{repo_name}' and UID: '{repo_uid}' was found"}
Expand Down
17 changes: 17 additions & 0 deletions mlc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,23 @@ def convert_args_to_dictionary(inp):

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

def is_uid(name):
"""
Checks if the given name is a 16-digit hexadecimal UID.

Args:
name (str): The string to check.

Returns:
bool: True if the name is a 16-digit hexadecimal UID, False otherwise.
"""
# Define a regex pattern for a 16-digit hexadecimal UID
hex_uid_pattern = r"^[0-9a-fA-F]{16}$"

# Check if the name matches the pattern
return bool(re.fullmatch(hex_uid_pattern, name))


def is_valid_url(url):
pattern = re.compile(
r"^(https?|ftp)://" # Protocol (http, https, ftp)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "mlcflow"
version = "1.0.8"
version = "1.0.9"

description = "An automation interface for ML applications"
authors = [
Expand Down
Loading