mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
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:
parent
92b1a2da5c
commit
b2221f135f
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user