Skip to content

Commit

Permalink
CM/CMX V3.4.4 (#1364)
Browse files Browse the repository at this point in the history
- improved error reporting in utils.load_json and utils.load_yaml
- added utils.substitute_template
- enhanced 'cm pull repo' based on user feedback
  • Loading branch information
ctuning-admin authored Nov 28, 2024
2 parents 68e5120 31e6e82 commit 3d6c27e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 57,10 @@ CK consists of several sub-projects:
* Copyright (c) 2021-2024 MLCommons
* Copyright (c) 2014-2021 cTuning foundation

### Author

* [Grigori Fursin](https://cKnowledge.org/gfursin) (FlexAI, cTuning)

### Maintainers

* CM/CM4Research/CM4MLPerf-results: [Grigori Fursin](https://cKnowledge.org/gfursin)
Expand Down
6 changes: 4 additions & 2 deletions cm/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 1,7 @@
## V3.4.3.1
- enhancing 'cm pull repo' based on user feedback
## V3.4.4
- improved error reporting in utils.load_json and utils.load_yaml
- added utils.substitute_template
- enhanced 'cm pull repo' based on user feedback

## V3.4.3
- fixed pyproject.toml
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.4.3.1"
__version__ = "3.4.4"

from cmind.core import access
from cmind.core import x
Expand Down
22 changes: 20 additions & 2 deletions cm/cmind/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 204,7 @@ def load_json(file_name, check_if_exists = False, encoding='utf8'):
try:
meta = json.load(jf)
except Exception as e:
return {'return':4, 'error': format(e)}
return {'return':4, 'error': f'detected problem in {file_name}: {e}'}

return {'return':0, 'meta': meta}

Expand Down Expand Up @@ -274,7 274,7 @@ def load_yaml(file_name, check_if_exists = False, encoding = 'utf8'):
# To support old versions
meta = yaml.safe_load(yf)
except Exception as e:
return {'return':4, 'error': format(e)}
return {'return':4, 'error': f'detected problem in {file_name}: {e}'}

return {'return':0,
'meta': meta}
Expand Down Expand Up @@ -2152,3 2152,21 @@ def digits(s, first = True):
pass

return v

##############################################################################
def substitute_template(template, variables):
"""
Substitutes variables in a template string with values from a dictionary.
Args:
template (str): The template string with placeholders (e.g., "something-{var1}-something-{var2}").
vars (dict): A dictionary containing variable-value pairs (e.g., {'var1': 'a', 'var2': 'b'}).
Returns:
str: The template string with placeholders replaced by the corresponding values.
"""
try:
return template.format(**variables)
except KeyError as e:
return f"Error: Missing value for {e.args[0]} in the vars dictionary."

1 change: 1 addition & 0 deletions cmx4mlops/README.md
Original file line number Diff line number Diff line change
@@ -0,0 1 @@
TBD
8 changes: 8 additions & 0 deletions cmx4mlops/cmr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 1,8 @@
alias: cmx4mlops
uid: 428611a6db02407f

git: true

version: "0.5.1"

author: "Grigori Fursin"

0 comments on commit 3d6c27e

Please sign in to comment.