From e8493d3807514880afded6cb477cda81504800ba Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Sun, 23 Oct 2022 12:36:06 +0300 Subject: [PATCH] Refactor override configuration to a method --- clearml_agent/backend_config/config.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/clearml_agent/backend_config/config.py b/clearml_agent/backend_config/config.py index 88a53f4..39c4d53 100644 --- a/clearml_agent/backend_config/config.py +++ b/clearml_agent/backend_config/config.py @@ -191,16 +191,20 @@ class Config(object): config, self._read_extra_env_config_values(), copy_trees=True ) - if self._overrides_configs: - config = functools.reduce( - lambda cfg, override: ConfigTree.merge_configs(cfg, override, copy_trees=True), - self._overrides_configs, - config, - ) + config = self.resolve_override_configs(config) config["env"] = env return config + def resolve_override_configs(self, initial=None): + if not self._overrides_configs: + return initial + return functools.reduce( + lambda cfg, override: ConfigTree.merge_configs(cfg, override, copy_trees=True), + self._overrides_configs, + initial or ConfigTree(), + ) + def _read_extra_env_config_values(self) -> ConfigTree: """ Loads extra configuration from environment-injected values """ result = ConfigTree()