Now printing a warning message when a config has an unknown key (#3428)

* Now printing a warning message when unknown keys present
This commit is contained in:
tofarr 2024-08-17 10:54:38 -06:00 committed by GitHub
parent 92b1a2da5c
commit b2221f135f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -514,7 +514,7 @@ def load_from_toml(cfg: AppConfig, toml_file: str = 'config.toml'):
)
agent_config = AgentConfig(**nested_value)
cfg.set_agent_config(agent_config, nested_key)
if key is not None and key.lower() == 'llm':
elif key is not None and key.lower() == 'llm':
logger.opendevin_logger.info(
'Attempt to load default LLM config from config toml'
)
@ -530,11 +530,17 @@ def load_from_toml(cfg: AppConfig, toml_file: str = 'config.toml'):
)
llm_config = LLMConfig(**nested_value)
cfg.set_llm_config(llm_config, nested_key)
elif not key.startswith('sandbox') and key.lower() != 'core':
logger.opendevin_logger.warning(
f'Unknown key in {toml_file}: "{key}"'
)
except (TypeError, KeyError) as e:
logger.opendevin_logger.warning(
f'Cannot parse config from toml, toml values have not been applied.\n Error: {e}',
exc_info=False,
)
else:
logger.opendevin_logger.warning(f'Unknown key in {toml_file}: "{key}')
try:
# set sandbox config from the toml file

View File

@ -1,5 +1,5 @@
import dataclasses
from opendevin.core import logger
class Singleton(type):
_instances: dict = {}
@ -13,7 +13,10 @@ class Singleton(type):
# useful for pre-defined groups of settings
instance = cls._instances[cls]
for key, value in kwargs.items():
setattr(instance, key, value)
if hasattr(instance, key):
setattr(instance, key, value)
else:
logger.opendevin_logger.warning(f'Unknown key for {cls.__name__}: "{key}"')
return cls._instances[cls]
@classmethod