From 14f15044fa7cece381507011fd928258d6cbe0a1 Mon Sep 17 00:00:00 2001 From: Grigori Fursin Date: Wed, 16 Oct 2024 10:38:22 +0200 Subject: [PATCH 1/4] updating docs --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 217e764de..7b747720a 100755 --- a/README.md +++ b/README.md @@ -34,6 +34,10 @@ CK consists of several sub-projects: * [CM4ABTF](https://github.com/mlcommons/cm4abtf) - a unified CM interface and automation recipes to run automotive benchmark across different models, data sets, software and hardware from different vendors. +* [CMX (the next generation of CM)](cm/docs/cmx) - we are developing the next generation of CM + to make it simpler and more flexible based on user feedback. Please follow + this project [here](https://github.com/orgs/mlcommons/projects/46). + * [Collective Knowledge Playground](https://access.cKnowledge.org) - a unified platform to list CM scripts similar to PYPI, aggregate AI/ML Systems benchmarking results in a reproducible format with CM workflows, and organize [public optimization challenges and reproducibility initiatives](https://access.cknowledge.org/playground/?action=challenges) From f00be10853912ac252d2f73e8c523b72da49463f Mon Sep 17 00:00:00 2001 From: Grigori Fursin Date: Wed, 16 Oct 2024 10:39:17 +0200 Subject: [PATCH 2/4] new dev version --- cm/cmind/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cm/cmind/__init__.py b/cm/cmind/__init__.py index 57fbbe910..f402fa4b7 100644 --- a/cm/cmind/__init__.py +++ b/cm/cmind/__init__.py @@ -2,7 +2,7 @@ # # Written by Grigori Fursin -__version__ = "3.2.2" +__version__ = "3.2.2.1" from cmind.core import access from cmind.core import x From 0060d6b18f122668e1781b7b5949b924f4abfe75 Mon Sep 17 00:00:00 2001 From: Grigori Fursin Date: Wed, 16 Oct 2024 11:31:08 +0200 Subject: [PATCH 3/4] V3.2.3: - added --new_branch to `cm pull repo` and `cm checkout repo` - fixed a bug in `cm show repo` (removed dependency on cm4mlops) --- cm/CHANGES.md | 4 ++ cm/cmind/__init__.py | 2 +- cm/cmind/repo/automation/repo/module.py | 58 +++++++++++++++++-------- cm/cmind/repos.py | 16 ++++++- 4 files changed, 59 insertions(+), 21 deletions(-) diff --git a/cm/CHANGES.md b/cm/CHANGES.md index bb45d23e0..bebe32726 100644 --- a/cm/CHANGES.md +++ b/cm/CHANGES.md @@ -1,3 +1,7 @@ +## V3.2.3 + - added --new_branch to `cm pull repo` and `cm checkout repo` + - fixed a bug in `cm show repo` (removed dependency on cm4mlops) + ## V3.2.2 - fixed action `help` and flag `-h` to work with all automations: https://github.com/mlcommons/ck/issues/1325 diff --git a/cm/cmind/__init__.py b/cm/cmind/__init__.py index f402fa4b7..d1f4e1a27 100644 --- a/cm/cmind/__init__.py +++ b/cm/cmind/__init__.py @@ -2,7 +2,7 @@ # # Written by Grigori Fursin -__version__ = "3.2.2.1" +__version__ = "3.2.3" from cmind.core import access from cmind.core import x diff --git a/cm/cmind/repo/automation/repo/module.py b/cm/cmind/repo/automation/repo/module.py index 48c4bec5e..6446e4559 100644 --- a/cm/cmind/repo/automation/repo/module.py +++ b/cm/cmind/repo/automation/repo/module.py @@ -31,6 +31,7 @@ def pull(self, i): (url) (str): URL of a repository (pat) (str): Personal Access Token (if supported and url=='') (branch) (str): Git branch + (new_branch) (str): Create new Git branch (checkout) (str): Git checkout (checkout_only) (bool): only checkout existing repo (depth) (int): Git depth @@ -123,6 +124,7 @@ def pull(self, i): # for backwards compatibility and reproducibility branch = i.get('branch', '') + new_branch = i.get('new_branch', '') checkout = i.get('checkout', '') r = net.request({'get': {'action': 'check-migration-repo-notes', 'repo': url, 'branch': branch, 'checkout': checkout}}) @@ -143,6 +145,7 @@ def pull(self, i): pull_repos = [{'alias':alias, 'url':url, 'branch': branch, + 'new_branch': new_branch, 'checkout': checkout, 'depth': i.get('depth', '')}] @@ -152,26 +155,32 @@ def pull(self, i): repo_metas = {} warnings = [] + + if not self.cmind.logger == None: + self.cmind.log(f"x repo log: {pull_repos}", "debug") for repo in pull_repos: alias = repo['alias'] url = repo.get('url', '') branch = repo.get('branch','') + new_branch = repo.get('new_branch','') checkout = repo.get('checkout','') depth = repo.get('depth','') path_to_repo = repo.get('path_to_repo', None) if console: print (self.cmind.cfg['line']) - print ('Alias: {}'.format(alias)) + print ('Alias: {}'.format(alias)) if url!='': - print ('URL: {}'.format(url)) + print ('URL: {}'.format(url)) if branch!='': - print ('Branch: {}'.format(branch)) + print ('Branch: {}'.format(branch)) + if new_branch!='': + print ('New branch: {}'.format(new_branch)) if checkout!='': - print ('Checkout: {}'.format(checkout)) + print ('Checkout: {}'.format(checkout)) if depth!='' and depth!=None: - print ('Depth: {}'.format(str(depth))) + print ('Depth: {}'.format(str(depth))) print ('') # Prepare path to repo @@ -180,6 +189,7 @@ def pull(self, i): r = repos.pull(alias = alias, url = url, branch = branch, + new_branch = new_branch, checkout = checkout, console = console, desc=desc, @@ -349,8 +359,10 @@ def search(self, i): print (' Alias: {}'.format(alias)) print (' UID: {}'.format(uid)) + if desc != '': print ('Description: {}'.format(desc)) + print ('Git: {}'.format(str(git))) if git: @@ -358,25 +370,33 @@ def search(self, i): branch = '' checkout = '' - r = self.cmind.access({'action':'system', 'automation':'utils', 'path':path, 'cmd':'git config --get remote.origin.url'}) - if r['return'] == 0 and r['ret'] == 0: - url = r['stdout'] - - r = self.cmind.access({'action':'system', 'automation':'utils', 'path':path, 'cmd':'git rev-parse --abbrev-ref HEAD'}) - if r['return'] == 0 and r['ret'] == 0: - branch = r['stdout'] - - r = self.cmind.access({'action':'system', 'automation':'utils', 'path':path, 'cmd':'git rev-parse HEAD'}) - if r['return'] == 0 and r['ret'] == 0: - checkout = r['stdout'] + import subprocess + + cur_dir = os.getcwd() + + os.chdir(path) + + try: + url = subprocess.check_output('git config --get remote.origin.url', shell=True).decode("utf-8").strip() + except subprocess.CalledProcessError as e: + url = '' + + try: + branch = subprocess.check_output('git rev-parse --abbrev-ref HEAD', shell=True).decode("utf-8").strip() + except subprocess.CalledProcessError as e: + branch = '' + try: + checkout = subprocess.check_output('git rev-parse HEAD', shell=True).decode("utf-8").strip() + except subprocess.CalledProcessError as e: + checkout = '' if url!='': - print (' URL: {}'.format(url)) + print (f' URL: {url}') if branch!='': - print (' Branch: {}'.format(branch)) + print (f' Branch: {branch}') if checkout!='': - print (' Checkout: {}'.format(checkout)) + print (f' Checkout: {checkout}') else: print ('{},{} = {}'.format(alias, uid, path)) diff --git a/cm/cmind/repos.py b/cm/cmind/repos.py index d25e757b8..cfe6baf3e 100644 --- a/cm/cmind/repos.py +++ b/cm/cmind/repos.py @@ -296,7 +296,7 @@ def process(self, repo_path, mode='add'): ############################################################ def pull(self, alias, url = '', branch = '', checkout = '', console = False, desc = '', prefix = '', depth = None, path_to_repo = None, checkout_only = False, skip_zip_parent_dir = False, - extra_cmd_git = '', extra_cmd_pip = ''): + extra_cmd_git = '', extra_cmd_pip = '', new_branch = ''): """ Clone or pull CM repository @@ -304,6 +304,7 @@ def pull(self, alias, url = '', branch = '', checkout = '', console = False, des alias (str): CM repository alias (url) (str): Git repository URL (branch) (str): Git repository branch + (new_branch) (str): Create new branch (checkout) (str): Git repository checkout (checkout_only) (bool): only checkout existing repo (depth) (int): Git repository depth @@ -462,6 +463,19 @@ def pull(self, alias, url = '', branch = '', checkout = '', console = False, des os.remove(pack_file) # Check if branch + if new_branch != '': + cmd = 'git checkout -b ' + new_branch + + if console: + print ('') + print (cmd) + print ('') + + r = os.system(cmd) + + if r>0: + return {'return':1, 'error':'creating new git branch failed'} + if branch != '' or checkout != '': cmd = 'git checkout' From 46a67ed76d38e2ce34b2f273b19986a9d1dd889a Mon Sep 17 00:00:00 2001 From: Grigori Fursin Date: Wed, 16 Oct 2024 11:33:51 +0200 Subject: [PATCH 4/4] clean up --- cm/CHANGES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cm/CHANGES.md b/cm/CHANGES.md index bebe32726..f39ad0dc2 100644 --- a/cm/CHANGES.md +++ b/cm/CHANGES.md @@ -1,6 +1,7 @@ ## V3.2.3 - added --new_branch to `cm pull repo` and `cm checkout repo` - - fixed a bug in `cm show repo` (removed dependency on cm4mlops) + - fixed a bug in `cm show repo` (removed dependency on cm4mlops + and used subprocess.check_output) ## V3.2.2 - fixed action `help` and flag `-h` to work with all automations: