[Configuration] Better logging (#545)

* [Config] improve logging

* finish
This commit is contained in:
Patrick von Platen 2022-09-17 14:09:13 +02:00 committed by GitHub
parent d7dcba4a13
commit 429dace10a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -289,11 +289,20 @@ class ConfigMixin:
# use value from config dict
init_dict[key] = config_dict.pop(key)
unused_kwargs = config_dict.update(kwargs)
config_dict = {k: v for k, v in config_dict.items() if not k.startswith("_")}
if len(config_dict) > 0:
logger.warning(
f"The config attributes {config_dict} were passed to {cls.__name__}, "
"but are not expected and will be ignored. Please verify your "
f"{cls.config_name} configuration file."
)
unused_kwargs = {**config_dict, **kwargs}
passed_keys = set(init_dict.keys())
if len(expected_keys - passed_keys) > 0:
logger.warning(
logger.info(
f"{expected_keys - passed_keys} was not found in config. Values will be initialized to default values."
)