Skip to content

Commit

Permalink
fix --inner_config
Browse files Browse the repository at this point in the history
  • Loading branch information
wayyoungboy committed Jul 31, 2024
1 parent 454f803 commit 90697d9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,15 @@ def __init__(self, stdio=None, inner_config_change_map=None):
super().__init__(inner_config_abs_path, stdio=stdio)
self.config = self.load_config_with_defaults(DEFAULT_INNER_CONFIG)
if inner_config_change_map != {}:
self.config.update(inner_config_change_map)
self.config = self._change_inner_config(self.config, inner_config_change_map)

def _change_inner_config(self, conf_map, change_conf_map):
for key, value in change_conf_map.items():
if key in conf_map:
if isinstance(value, dict):
self._change_inner_config(conf_map[key], value)
else:
conf_map[key] = value
else:
conf_map[key] = value
return conf_map
14 changes: 13 additions & 1 deletion diag_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,19 @@ def _inner_config_change(self, option, opt_str, value, parser):
if key is None or key == "":
return
m = self._inner_config_change_set(key, val)
self.inner_config_change_map.update(m)

def _change_inner_config(conf_map, change_conf_map):
for change_conf_map_key, change_conf_map_value in change_conf_map.items():
if change_conf_map_key in conf_map:
if isinstance(change_conf_map_value, dict):
_change_inner_config(conf_map[change_conf_map_key], change_conf_map_value)
else:
conf_map[change_conf_map_key] = change_conf_map_value
else:
conf_map[change_conf_map_key] = change_conf_map_value
return conf_map

self.inner_config_change_map = _change_inner_config(self.inner_config_change_map, m)
except Exception as e:
raise Exception("Key or val ({1}) is illegal: {0}".format(e, value))

Expand Down

0 comments on commit 90697d9

Please sign in to comment.