From 3e6187ece70697029fee252f349cff6b06391fe2 Mon Sep 17 00:00:00 2001 From: Grigori Fursin Date: Tue, 16 Apr 2024 19:53:57 +0200 Subject: [PATCH] CM v2.1.1 release --- cm/CHANGES.md | 5 +++++ cm/cmind/__init__.py | 2 +- cm/cmind/repo/automation/repo/module.py | 6 +++++- cm/cmind/repos.py | 17 +++++++++++++++-- cm/setup.py | 2 +- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/cm/CHANGES.md b/cm/CHANGES.md index bc1a327be4..a9957d40fa 100644 --- a/cm/CHANGES.md +++ b/cm/CHANGES.md @@ -1,3 +1,8 @@ +## V2.1.1 + - added --skip-zip-parent-dir to "cm pull repo --url=..." to support downloading + of stable CM-MLOps repositories from https://github.com/mlcommons/cm4mlops/releases . + + ## V2.1.0 - changed outdated version of CM in requirements when creating new repos - fixed minor bug in `cm add automation {name}` diff --git a/cm/cmind/__init__.py b/cm/cmind/__init__.py index 410530b47c..97d8ef25a0 100644 --- a/cm/cmind/__init__.py +++ b/cm/cmind/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.1.0" +__version__ = "2.1.1" from cmind.core import access from cmind.core import error diff --git a/cm/cmind/repo/automation/repo/module.py b/cm/cmind/repo/automation/repo/module.py index ef856ba3dc..e73e1f5d67 100644 --- a/cm/cmind/repo/automation/repo/module.py +++ b/cm/cmind/repo/automation/repo/module.py @@ -31,6 +31,8 @@ def pull(self, i): (depth) (int): Git depth (desc) (str): brief repository description (1 line) (prefix) (str): extra directory to keep CM artifacts + (skip_zip_parent_dir) (bool): skip parent dir in CM ZIP repo (useful when + downloading CM repo archives from GitHub) Returns: (CM return dict): @@ -50,6 +52,7 @@ def pull(self, i): pat = i.get('pat','') checkout_only = i.get('checkout_only', False) + skip_zip_parent_dir = i.get('skip_zip_parent_dir', False) if url == '': if alias != '': @@ -140,7 +143,8 @@ def pull(self, i): prefix=prefix, depth=depth, path_to_repo=path_to_repo, - checkout_only=checkout_only) + checkout_only=checkout_only, + skip_zip_parent_dir=skip_zip_parent_dir) if r['return']>0: return r repo_meta = r['meta'] diff --git a/cm/cmind/repos.py b/cm/cmind/repos.py index 601f99e01c..8a93a49456 100644 --- a/cm/cmind/repos.py +++ b/cm/cmind/repos.py @@ -252,7 +252,8 @@ def process(self, repo_path, mode='add'): return {'return':0} ############################################################ - def pull(self, alias, url = '', branch = '', checkout = '', console = False, desc = '', prefix = '', depth = None, path_to_repo = None, checkout_only = False): + 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): """ Clone or pull CM repository @@ -267,6 +268,9 @@ def pull(self, alias, url = '', branch = '', checkout = '', console = False, des (desc) (str): optional repository description (prefix) (str): sub-directory to be used inside this CM repository to store artifacts (path_to_repo) (str): force path to repo (useful to pull imported repos with non-standard path) + (checkout_only) (bool): only checkout Git repository but don't pull + (skip_zip_parent_dir) (bool): skip parent dir in CM ZIP repo (useful when + downloading CM repo archives from GitHub) Returns: (CM return dict): @@ -370,10 +374,19 @@ def pull(self, alias, url = '', branch = '', checkout = '', console = False, des if console: print ('Unpacking {} to {} ...'.format(pack_file, repo_path)) + parent_dir = '' + # Unpacking zip for f in files: if not f.startswith('..') and not f.startswith('/') and not f.startswith('\\'): - file_path = os.path.join(repo_path, f) + + if skip_zip_parent_dir and parent_dir == '': + parent_dir = f + + ff = f[len(parent_dir):] if parent_dir != '' else f + + file_path = os.path.join(repo_path, ff) + if f.endswith('/'): # create directory if not os.path.exists(file_path): diff --git a/cm/setup.py b/cm/setup.py index b24225ca38..0031a5d527 100644 --- a/cm/setup.py +++ b/cm/setup.py @@ -94,7 +94,7 @@ def run(self): 'install': custom_install }, - install_requires=['pyyaml', 'requests'], + install_requires=['pyyaml', 'requests', 'setuptools', 'giturlparse'], entry_points={"console_scripts": [ "cmind = cmind.cli:run",