Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating docs #1327

Merged
merged 5 commits into from
Oct 16, 2024
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions cm/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 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
and used subprocess.check_output)

## V3.2.2
- fixed action `help` and flag `-h` to work with all automations:
https://github.com/mlcommons/ck/issues/1325
Expand Down
2 changes: 1 addition & 1 deletion cm/cmind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Written by Grigori Fursin

__version__ = "3.2.2"
__version__ = "3.2.3"

from cmind.core import access
from cmind.core import x
Expand Down
58 changes: 39 additions & 19 deletions cm/cmind/repo/automation/repo/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}})
Expand All @@ -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', '')}]

Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -349,34 +359,44 @@ 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:
url = ''
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))
Expand Down
16 changes: 15 additions & 1 deletion cm/cmind/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,15 @@ 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

Args:
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
Expand Down Expand Up @@ -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'

Expand Down
Loading