Skip to content

Commit d71e536

Browse files
committed
fix: Fixed pylint errors and other minor changes
Signed-off-by: Brandon Groth <brandon.m.groth@gmail.com>
1 parent 71c6aab commit d71e536

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

fms_mo/utils/qconfig_utils.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,16 @@ def find_recipe_json(recipe: str, subdir: str = None):
194194

195195

196196
def get_recipe(recipe: str, subdir: str = None):
197+
"""
198+
Get a json recipe.
199+
200+
Args:
201+
recipe (str): Name of the recipe file.
202+
subdir (str, optional): A subdirectory to search from root. Defaults to None.
203+
204+
Returns:
205+
Any: Data from a saved .json.
206+
"""
197207
json_file = find_recipe_json(recipe, subdir)
198208

199209
temp_data = None
@@ -366,7 +376,7 @@ def qconfig_init(recipe: str = None, args: Any = None):
366376
temp_cfg = get_recipe(recipe)
367377
if temp_cfg:
368378
qcfg.update(temp_cfg)
369-
logger.info(f"Updated config w/ recipe values")
379+
logger.info("Updated config w/ recipe values")
370380
else:
371381
raise ValueError(f"Config recipe {recipe} was not found.")
372382

@@ -518,10 +528,7 @@ def add_wanted_defaults_to_config(config, minimal: bool = True):
518528
if a wanted item is not in the config, add it w/ default value
519529
"""
520530
if not minimal:
521-
wanted_items = config_defaults()
522-
for wanted_name, wanted_default_val in wanted_items.items():
523-
if wanted_name not in config:
524-
config[wanted_name] = wanted_default_val
531+
config.update( config_defaults() )
525532

526533

527534
def qconfig_save(

tests/models/test_saveconfig.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_save_config_with_qcfg_save(
9999
config_fp32["save"] = save_list
100100

101101
qconfig_save(config_fp32, minimal=False)
102-
102+
103103
loaded_config = load_json()
104104

105105
# Remove pkg_versions and date before processing
@@ -136,10 +136,10 @@ def test_save_config_with_recipe_save(
136136
save_json(save_list, file_path=save_path)
137137

138138
qconfig_save(config_fp32, recipe="save_list")
139-
139+
140140
# Check that saved qcfg matches
141141
loaded_config = load_json()
142-
142+
143143
# Remove pkg_versions and date before processing
144144
del loaded_config["pkg_versions"]
145145
del loaded_config["date"]
@@ -157,6 +157,12 @@ def test_save_config_with_recipe_save(
157157
def test_save_config_minimal(
158158
config_fp32: dict,
159159
):
160+
"""
161+
Test for checking that the minimal functionality works for saving a quantized config.
162+
163+
Args:
164+
config_fp32 (dict): Config for fp32 quantization
165+
"""
160166
delete_config()
161167

162168
qconfig_save(config_fp32, minimal=True)

0 commit comments

Comments
 (0)