Skip to content

Commit 07e3ac5

Browse files
authored
V2.3.8 (#1297)
- added `--skip` and `--url` flags to `cm init` - added support to pull CM repos using --url with "git@"
2 parents 443bd03 + 657db09 commit 07e3ac5

File tree

5 files changed

+48
-22
lines changed

5 files changed

+48
-22
lines changed

cm/CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## V2.3.8
2+
- added `--skip` and `--url` flags to `cm init`
3+
- added support to pull CM repos using --url with "git@"
4+
15
## V2.3.7
26
- added cmind.core.debug to make it easier to debug CM automations
37
- added env CM_CORE_SKIP_FIX_REPO_PATH to skip fixing non-existent repo paths

cm/COPYRIGHT.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
Copyright (c) 2022-2024 MLCommons
2+

cm/cmind/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Written by Grigori Fursin
44

5-
__version__ = "2.3.7"
5+
__version__ = "2.3.8"
66

77
from cmind.core import access
88
from cmind.core import error

cm/cmind/repo/automation/core/module.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class CMInit():
1717
###############################################################
18-
def run(self, quiet = False, repo_name = 'mlcommons@cm4mlops', repo_branch = ''):
18+
def run(self, quiet = False, skip = False, repo_name = 'mlcommons@cm4mlops', repo_url = '', repo_branch = ''):
1919
import cmind
2020

2121
print ('Checking platform information ...')
@@ -27,19 +27,29 @@ def run(self, quiet = False, repo_name = 'mlcommons@cm4mlops', repo_branch = '')
2727
if r['return']>0 or r.get('warning','') !='' :
2828
return r
2929

30-
print ('')
31-
print ('Obtaining default automation repository ...')
30+
rr = {'return':0}
3231

33-
print ('')
34-
ii = {'action':'pull',
35-
'automation':'repo',
36-
'artifact':repo_name,
37-
'out':'con'}
32+
if not skip:
33+
34+
print ('')
35+
print ('Pulling default automation repository ...')
36+
37+
print ('')
38+
ii = {'action':'pull',
39+
'automation':'repo',
40+
'out':'con'}
41+
42+
if repo_url != '':
43+
ii['url'] = repo_url
44+
elif repo_name != '':
45+
ii['artifact'] = repo_name
46+
47+
if repo_branch !='':
48+
ii['branch'] = repo_branch
3849

39-
if repo_branch !='':
40-
ii['branch'] = repo_branch
50+
rr = cmind.access(ii)
4151

42-
return cmind.access(ii)
52+
return rr
4353

4454
###############################################################
4555
def install_system_packages(self, quiet):
@@ -215,9 +225,10 @@ def init(self, i):
215225
(CM input dict):
216226
217227
(quiet) (bool): if True, skip asking questions about sudo, etc
218-
(repo) (str): automation repository to pull ('mlcommons@cm4mlops' by default)
228+
(repo) (str): main automation repository to pull ('mlcommons@cm4mlops' by default)
229+
(url) (str): main automation repository to pull via url (can use git@ instead of https)
219230
(branch) (str): branch to use ('' by default)
220-
231+
(skip) (bool): skip pulling main automation repository
221232
222233
Returns:
223234
(CM return dict):
@@ -230,12 +241,16 @@ def init(self, i):
230241

231242
quiet = i.get('quiet', False)
232243

233-
repo_name = i.get('repo', '')
234-
if repo_name == '': repo_name = 'mlcommons@cm4mlops'
244+
skip = i.get('skip', False)
245+
246+
repo_name = i.get('repo', '').strip()
247+
repo_url = i.get('url', '').strip()
248+
if repo_url == '' and repo_name == '':
249+
repo_name = 'mlcommons@cm4mlops'
235250

236251
repo_branch = i.get('branch', '')
237252

238-
r = cm_init.run(quiet = quiet, repo_name = repo_name, repo_branch = repo_branch)
253+
r = cm_init.run(quiet = quiet, skip = skip, repo_name = repo_name, repo_url = repo_url, repo_branch = repo_branch)
239254
if r['return']>0: return r
240255

241256
warning = r.get('warning', '')

cm/cmind/repo/automation/repo/module.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,17 @@ def pull(self, i):
8383
else:
8484
if alias.endswith('.git'): alias=alias[:-4]
8585

86-
j = alias.find('//')
87-
if j>=0:
88-
j1 = alias.find('/', j+2)
89-
if j1>=0:
90-
alias = alias[j1+1:].replace('/','@')
86+
if alias.startswith('git@'):
87+
j = alias.find(':')
88+
if j>=0:
89+
alias = alias[j+1:].replace('/','@')
90+
else:
91+
j = alias.find('//')
92+
if j>=0:
93+
j1 = alias.find('/', j+2)
94+
if j1>=0:
95+
alias = alias[j1+1:].replace('/','@')
96+
9197

9298
if url == '':
9399
pull_repos = []

0 commit comments

Comments
 (0)