Implementation of the find repo functionality#56
Conversation
|
MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅ |
| try: | ||
| # Get repos_list using the existing method | ||
| repos_list = self.load_repos_and_meta() | ||
| if(run_args.get('item', run_args.get('artifact'))): |
There was a problem hiding this comment.
Do we need an if condition here since repo, item, and artifact are being considered under else?
| lst.append(i) | ||
| try: | ||
| # Get repos_list using the existing method | ||
| repos_list = self.load_repos_and_meta() |
There was a problem hiding this comment.
Won't the load_repos_and_meta be automatically called when initialising the Action class while running mlc? I think it could be accessed through self.repos_list .
| 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): |
There was a problem hiding this comment.
Does this looping create un-necessary complexity as we are already inside a loop which tries to do the same function in more generic way?
| lst.append(i) | ||
| elif self.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): |
There was a problem hiding this comment.
Same here. I think usage of any could reduce the number of lines but with a different logic.
@Sid9993 do you think the code would be more efficient and small if we use the below snippet with revised logic?
matching_repos = [i for i in self.repos if i.meta['uid'] == repo_uid]
| def process_console_output(res, target, action, run_args): | ||
| if action == "find": | ||
| if "list" not in res: | ||
| return # Exit function if there's an error |
There was a problem hiding this comment.
The check for key list is nice to have, while returning, we usually follow the pattern below for error:
return {"return": error-code, "error": detail-of-error}
Implemented the
find repocmd functionality to get the repo path location. The allowed formats for usingfind repoare :