Make sure configuration path loaded from an environment variable name is lower-case

This commit is contained in:
allegroai 2020-06-01 11:40:34 +03:00
parent c43ce3a17b
commit b125a56f86

View File

@ -57,7 +57,7 @@ class BasicConfig:
keys = sorted(k for k in os.environ if k.startswith(prefix)) keys = sorted(k for k in os.environ if k.startswith(prefix))
for key in keys: for key in keys:
path = key[len(prefix) :].replace(EXTRA_CONFIG_VALUES_ENV_KEY_SEP, ".") path = key[len(prefix) :].replace(EXTRA_CONFIG_VALUES_ENV_KEY_SEP, ".").lower()
result = ConfigTree.merge_configs( result = ConfigTree.merge_configs(
result, ConfigFactory.parse_string(f"{path}: {os.environ[key]}") result, ConfigFactory.parse_string(f"{path}: {os.environ[key]}")
) )
@ -77,7 +77,7 @@ class BasicConfig:
if not path.is_dir() and str(path) != DEFAULT_EXTRA_CONFIG_PATH if not path.is_dir() and str(path) != DEFAULT_EXTRA_CONFIG_PATH
] ]
if invalid: if invalid:
print(f"WARNING: Invalid paths in {key} env var: {' '.join(invalid)}") print(f"WARNING: Invalid paths in {key} env var: {' '.join(map(str, invalid))}")
return [path for path in paths if path.is_dir()] return [path for path in paths if path.is_dir()]
def _load(self, verbose=True): def _load(self, verbose=True):