Skip to content

Commit baf3402

Browse files
CM v2.1.2 (#1212)
2 parents 572fb00 + 2f6ba56 commit baf3402

File tree

8 files changed

+120
-33
lines changed

8 files changed

+120
-33
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ and Modular Inference Library) or participate in collaborative developments.
2222

2323
Thank you for your support and looking forward to collaborating with you!
2424

25-
## Authors and project coordinators
25+
## Project coordinators
2626

27-
* [Grigori Fursin](https://cKnowledge.org/gfursin) (MLCommons.org, cTuning.org, cKnowledge.org)
28-
* [Arjun Suresh](https://www.linkedin.com/in/arjunsuresh) (MLCommons.org, cTuning.org, cKnowledge.org)
27+
* [Grigori Fursin](https://cKnowledge.org/gfursin)
28+
* [Arjun Suresh](https://www.linkedin.com/in/arjunsuresh)
2929

3030
## Contributors to MLCommons' Collective Mind (aka Collective Knowledge v3) in alphabetical order
3131

cm-mlops/script/print-hello-world/run.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ echo CM_ENV_TEST3 = %CM_ENV_TEST3%
55

66
echo.
77
echo HELLO WORLD!
8+
9+
echo.

cm-mlops/script/print-hello-world/run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ echo "CM_ENV_TEST3 = ${CM_ENV_TEST3}"
77

88
echo ""
99
echo "HELLO WORLD!"
10+
11+
echo ""

cm/CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## V2.1.2
2+
- added support for deps on other CM repos
3+
(if conflict = True - then fail if this repo is already installed
4+
otherwise print that repo is missing)
5+
16
## V2.1.1
27
- added --skip-zip-parent-dir to "cm pull repo --url=..." to support downloading
38
of stable CM-MLOps repositories from https://github.com/mlcommons/cm4mlops/releases .

cm/cmind/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.1.1"
1+
__version__ = "2.1.2"
22

33
from cmind.core import access
44
from cmind.core import error

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ def pull(self, i):
110110
repo_meta = {}
111111
repo_metas = {}
112112

113+
warnings = []
114+
113115
for repo in pull_repos:
114116
alias = repo['alias']
115117
url = repo.get('url', '')
@@ -151,13 +153,18 @@ def pull(self, i):
151153

152154
repo_metas[alias] = repo_meta
153155

156+
if len(r.get('warnings', []))>0:
157+
warnings += r['warnings']
158+
154159
if len(pull_repos)>0 and self.cmind.use_index:
155160
if console:
156161
print (self.cmind.cfg['line'])
157162

158163
ii = {'out':'con'} if console else {}
159164
rx = self.reindex(ii)
160165

166+
print_warnings(warnings)
167+
161168
return {'return':0, 'meta':repo_meta, 'metas': repo_metas}
162169

163170

@@ -581,6 +588,9 @@ def init(self, i):
581588
ii = {'out':'con'} if console else {}
582589
rx = self.reindex(ii)
583590

591+
warnings = r.get('warnings', [])
592+
print_warnings(warnings)
593+
584594
return r
585595

586596
############################################################
@@ -1196,3 +1206,14 @@ def convert_ck_dir_to_cm(rpath):
11961206
if r['return']>0: return r
11971207

11981208
return {'return':0}
1209+
1210+
def print_warnings(warnings):
1211+
1212+
if len(warnings)>0:
1213+
print ('')
1214+
print ('WARNINGS:')
1215+
print ('')
1216+
for w in warnings:
1217+
print (' {}'.format(w))
1218+
1219+
return

cm/cmind/repos.py

Lines changed: 81 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ def process(self, repo_path, mode='add'):
183183
* return (int): return code == 0 if no error and >0 if error
184184
* (error) (str): error string if return>0
185185
186+
* (warnings) (list of str): warnings to install more CM repositories
187+
186188
"""
187189

188190
# Load clean file with repo paths
@@ -193,43 +195,71 @@ def process(self, repo_path, mode='add'):
193195

194196
modified = False
195197

198+
warnings = []
199+
196200
if mode == 'add':
197201
if repo_path not in paths:
198-
if len(paths)>0:
199-
# Load meta of the current repo
200-
path_to_repo_desc = os.path.join(repo_path, self.cfg['file_meta_repo'])
201-
r=utils.load_yaml_and_json(file_name_without_ext=path_to_repo_desc)
202+
# Load meta of the current repo
203+
path_to_repo_desc = os.path.join(repo_path, self.cfg['file_meta_repo'])
204+
205+
r=utils.load_yaml_and_json(file_name_without_ext=path_to_repo_desc)
206+
if r['return']>0: return r
207+
208+
meta = r['meta']
209+
210+
alias = meta.get('alias', '')
211+
uid = meta.get('uid', '')
212+
213+
deps_on_other_repos = meta.get('deps', {})
214+
215+
# Check that no repos exist with the same alias and/or uid
216+
# (to avoid adding forks and original repos)
217+
218+
for path in paths:
219+
path_to_existing_repo_desc = os.path.join(path, self.cfg['file_meta_repo'])
220+
r=utils.load_yaml_and_json(file_name_without_ext=path_to_existing_repo_desc)
202221
if r['return']>0: return r
203222

204-
meta = r['meta']
223+
existing_meta = r['meta']
205224

206-
alias = meta.get('alias', '')
207-
uid = meta.get('uid', '')
225+
existing_alias = existing_meta.get('alias', '')
226+
existing_uid = existing_meta.get('uid', '')
208227

209-
# Check that no repos exist with the same alias and/or uid
210-
# (to avoid adding forks and original repos)
228+
# Check if repository already exists under different name
229+
exist = False
230+
if alias != '' and existing_alias !='' and alias == existing_alias:
231+
exist = True
211232

212-
for path in paths:
213-
path_to_existing_repo_desc = os.path.join(path, self.cfg['file_meta_repo'])
214-
r=utils.load_yaml_and_json(file_name_without_ext=path_to_existing_repo_desc)
215-
if r['return']>0: return r
233+
if not exist and uid !='' and existing_uid !='' and uid == existing_uid:
234+
exist = True
216235

217-
existing_meta = r['meta']
236+
if exist:
237+
return {'return':1, 'error':'CM repository with the same alias "{}" and/or uid "{}" already exists in {}'.format(alias, uid, path)}
218238

219-
existing_alias = existing_meta.get('alias', '')
220-
existing_uid = existing_meta.get('uid', '')
239+
# Check if there is a conflict
240+
if len(deps_on_other_repos)>0:
241+
for d in deps_on_other_repos:
242+
d_alias = d.get('alias', '')
243+
d_uid = d.get('uid', '')
221244

222-
exist = False
223-
if alias != '' and existing_alias !='' and alias == existing_alias:
224-
exist = True
245+
r = utils.match_objects(existing_uid, existing_alias, d_uid, d_alias)
246+
if r['return']>0: return r
247+
match = r['match']
225248

226-
if not exist and uid !='' and existing_uid !='' and uid == existing_uid:
227-
exist = True
249+
if match:
250+
if d.get('conflict', False):
251+
return {'return':1, 'error':'Can\'t install this repository because it conflicts with the already installed one ({}) - you may need to remove it to proceed (cm rm repo {} --all)'.format(d_alias,d_alias)}
228252

229-
if exist:
230-
return {'return':1, 'error':'CM repository with the same alias "{}" and/or uid "{}" already exists in {}'.format(alias, uid, path)}
253+
d['matched'] = True
231254

255+
break
232256

257+
258+
# Check if has missing deps on other CM repos
259+
for d in deps_on_other_repos:
260+
if not d.get('conflict', False) and not d.get('matched', False):
261+
warnings.append('You must install extra CM repository: cm pull repo {}'.format(d['alias']))
262+
233263
paths.append(repo_path)
234264
modified = True
235265

@@ -249,7 +279,12 @@ def process(self, repo_path, mode='add'):
249279
# Reload repos
250280
self.load(init=True)
251281

252-
return {'return':0}
282+
rr = {'return':0}
283+
284+
if len(warnings)>0:
285+
rr['warnings'] = warnings
286+
287+
return rr
253288

254289
############################################################
255290
def pull(self, alias, url = '', branch = '', checkout = '', console = False, desc = '', prefix = '', depth = None,
@@ -280,6 +315,8 @@ def pull(self, alias, url = '', branch = '', checkout = '', console = False, des
280315
281316
* (meta) (dict): meta of the CM repository
282317
318+
* (warnings) (list of str): warnings to install more CM repositories
319+
283320
"""
284321

285322
# Prepare path
@@ -500,14 +537,21 @@ def pull(self, alias, url = '', branch = '', checkout = '', console = False, des
500537
r = self.process(path_to_repo, 'add')
501538
if r['return']>0: return r
502539

540+
warnings = r.get('warnings', [])
541+
503542
# Go back to original directory
504543
os.chdir(cur_dir)
505544

506545
if console:
507546
print ('')
508547
print ('CM alias for this repository: {}'.format(alias))
509548

510-
return {'return':0, 'meta':meta}
549+
rr = {'return':0, 'meta':meta}
550+
551+
if len(warnings)>0: rr['warnings'] = warnings
552+
553+
return rr
554+
511555

512556
############################################################
513557
def init(self, alias, uid, path = '', console = False, desc = '', prefix = '', only_register = False):
@@ -534,6 +578,8 @@ def init(self, alias, uid, path = '', console = False, desc = '', prefix = '', o
534578
* path_to_repo_desc (str): path to repository description
535579
* path_to_repo_with_prefix (str): path to repository with prefix (== path_to_repo if prefix == "")
536580
581+
* (warnings) (list of str): warnings to install more CM repositories
582+
537583
"""
538584

539585
# Prepare path
@@ -612,10 +658,16 @@ def init(self, alias, uid, path = '', console = False, desc = '', prefix = '', o
612658
r = self.process(path_to_repo, 'add')
613659
if r['return']>0: return r
614660

615-
return {'return':0, 'meta':meta,
616-
'path_to_repo': path_to_repo,
617-
'path_to_repo_desc': path_to_repo_desc,
618-
'path_to_repo_with_prefix': path_to_repo_with_prefix}
661+
warnings = r.get('warnings', [])
662+
663+
rr = {'return':0, 'meta':meta,
664+
'path_to_repo': path_to_repo,
665+
'path_to_repo_desc': path_to_repo_desc,
666+
'path_to_repo_with_prefix': path_to_repo_with_prefix}
667+
668+
if len(warnings)>0: rr['warnings'] = warnings
669+
670+
return rr
619671

620672
############################################################
621673
def delete(self, lst, remove_all = False, console = False, force = False):

cmr.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ git: true
66
prefix: cm-mlops
77

88
version: 2.0.4
9+
10+
deps:
11+
- alias: mlcommons@cm4mlops
12+
uid: 9e97bb72b0474657
13+
conflict: True

0 commit comments

Comments
 (0)