Skip to content

Commit 73693ba

Browse files
authored
Mentioned LLM logs directory (OpenHands#1587)
* Update bug_template.yml * Pythonized * updated configs type * updated opendevin_logger * fixed bool config * fixed bool config
1 parent ae7f208 commit 73693ba

8 files changed

Lines changed: 38 additions & 13 deletions

File tree

.github/ISSUE_TEMPLATE/bug_template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ body:
6666
id: additional-context
6767
attributes:
6868
label: Logs, Errors, Screenshots, and Additional Context
69-
description: Please add any additional context about the problem here.
69+
description: If you set DEBUG = 1 in config or env, LLM logs will be stored in the `logs/llm` folder. Please add any additional context about the problem here.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,5 @@ cache
202202

203203
# configuration
204204
config.toml
205+
206+
test_results*

opendevin/core/config.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
ConfigType.CACHE_DIR: '/tmp/cache', # '/tmp/cache' is the default cache directory
3434
ConfigType.LLM_MODEL: 'gpt-3.5-turbo-1106',
3535
ConfigType.SANDBOX_CONTAINER_IMAGE: DEFAULT_CONTAINER_IMAGE,
36-
ConfigType.RUN_AS_DEVIN: 'true',
36+
ConfigType.RUN_AS_DEVIN: True,
3737
ConfigType.LLM_EMBEDDING_MODEL: 'local',
3838
ConfigType.LLM_EMBEDDING_BASE_URL: None,
3939
ConfigType.LLM_EMBEDDING_DEPLOYMENT_NAME: None,
@@ -56,13 +56,14 @@
5656
ConfigType.AGENT: 'CodeActAgent',
5757
ConfigType.E2B_API_KEY: '',
5858
ConfigType.SANDBOX_TYPE: 'ssh', # Can be 'ssh', 'exec', or 'e2b'
59-
ConfigType.USE_HOST_NETWORK: 'false',
59+
ConfigType.USE_HOST_NETWORK: False,
6060
ConfigType.SSH_HOSTNAME: 'localhost',
61-
ConfigType.DISABLE_COLOR: 'false',
61+
ConfigType.DISABLE_COLOR: False,
6262
ConfigType.SANDBOX_USER_ID: os.getuid() if hasattr(os, 'getuid') else None,
6363
ConfigType.SANDBOX_TIMEOUT: 120,
6464
ConfigType.GITHUB_TOKEN: None,
6565
ConfigType.SANDBOX_USER_ID: None,
66+
ConfigType.DEBUG: False,
6667
}
6768

6869
config_str = ''
@@ -71,6 +72,15 @@
7172
config_str = f.read().decode('utf-8')
7273

7374

75+
def str_to_bool(value):
76+
if isinstance(value, bool):
77+
return value
78+
return value.lower() in [
79+
'true',
80+
'1',
81+
]
82+
83+
7484
def int_value(value, default, config_key):
7585
# FIXME use a library
7686
try:
@@ -89,13 +99,22 @@ def int_value(value, default, config_key):
8999
config[k] = os.environ[k]
90100
elif k in tomlConfig:
91101
config[k] = tomlConfig[k]
102+
92103
if k in [
93104
ConfigType.LLM_NUM_RETRIES,
94105
ConfigType.LLM_RETRY_MIN_WAIT,
95106
ConfigType.LLM_RETRY_MAX_WAIT,
96107
]:
97108
config[k] = int_value(config[k], v, config_key=k)
98109

110+
if k in [
111+
ConfigType.RUN_AS_DEVIN,
112+
ConfigType.USE_HOST_NETWORK,
113+
ConfigType.AGENT_MEMORY_ENABLED,
114+
ConfigType.DISABLE_COLOR,
115+
ConfigType.DEBUG,
116+
]:
117+
config[k] = str_to_bool(config[k])
99118
# In local there is no sandbox, the workspace will have the same pwd as the host
100119
if config[ConfigType.SANDBOX_TYPE] == 'local':
101120
config[ConfigType.WORKSPACE_MOUNT_PATH_IN_SANDBOX] = config[
@@ -179,7 +198,7 @@ def finalize_config():
179198
if config.get(ConfigType.LLM_EMBEDDING_BASE_URL) is None:
180199
config[ConfigType.LLM_EMBEDDING_BASE_URL] = config.get(ConfigType.LLM_BASE_URL)
181200

182-
USE_HOST_NETWORK = config[ConfigType.USE_HOST_NETWORK].lower() != 'false'
201+
USE_HOST_NETWORK = config[ConfigType.USE_HOST_NETWORK]
183202
if USE_HOST_NETWORK and platform.system() == 'Darwin':
184203
logger.warning(
185204
'Please upgrade to Docker Desktop 4.29.0 or later to use host network mode on macOS. '

opendevin/core/logger.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from opendevin.core import config
1111
from opendevin.core.schema.config import ConfigType
1212

13-
DISABLE_COLOR_PRINTING = config.get(ConfigType.DISABLE_COLOR).lower() == 'true'
13+
DISABLE_COLOR_PRINTING = config.get(ConfigType.DISABLE_COLOR)
1414

1515
ColorType = Literal[
1616
'red',
@@ -91,7 +91,8 @@ def get_file_handler():
9191
timestamp = datetime.now().strftime('%Y-%m-%d')
9292
file_name = f'opendevin_{timestamp}.log'
9393
file_handler = logging.FileHandler(os.path.join(log_dir, file_name))
94-
file_handler.setLevel(logging.DEBUG)
94+
if config.get(ConfigType.DEBUG):
95+
file_handler.setLevel(logging.DEBUG)
9596
file_handler.setFormatter(file_formatter)
9697
return file_handler
9798

@@ -196,10 +197,12 @@ def get_llm_response_file_handler():
196197

197198
llm_prompt_logger = logging.getLogger('prompt')
198199
llm_prompt_logger.propagate = False
199-
llm_prompt_logger.setLevel(logging.DEBUG)
200+
if config.get(ConfigType.DEBUG):
201+
llm_prompt_logger.setLevel(logging.DEBUG)
200202
llm_prompt_logger.addHandler(get_llm_prompt_file_handler())
201203

202204
llm_response_logger = logging.getLogger('response')
203205
llm_response_logger.propagate = False
204-
llm_response_logger.setLevel(logging.DEBUG)
206+
if config.get(ConfigType.DEBUG):
207+
llm_response_logger.setLevel(logging.DEBUG)
205208
llm_response_logger.addHandler(get_llm_response_file_handler())

opendevin/core/schema/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ class ConfigType(str, Enum):
4141
SSH_HOSTNAME = 'SSH_HOSTNAME'
4242
DISABLE_COLOR = 'DISABLE_COLOR'
4343
GITHUB_TOKEN = 'GITHUB_TOKEN'
44+
DEBUG = 'DEBUG'

opendevin/runtime/docker/exec_box.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# FIXME: On some containers, the devin user doesn't have enough permission, e.g. to install packages
2929
# How do we make this more flexible?
30-
RUN_AS_DEVIN = config.get(ConfigType.RUN_AS_DEVIN).lower() != 'false'
30+
RUN_AS_DEVIN = config.get(ConfigType.RUN_AS_DEVIN)
3131
USER_ID = 1000
3232
if SANDBOX_USER_ID := config.get(ConfigType.SANDBOX_USER_ID):
3333
USER_ID = int(SANDBOX_USER_ID)

opendevin/runtime/docker/ssh_box.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# FIXME: On some containers, the devin user doesn't have enough permission, e.g. to install packages
4040
# How do we make this more flexible?
41-
RUN_AS_DEVIN = config.get(ConfigType.RUN_AS_DEVIN).lower() != 'false'
41+
RUN_AS_DEVIN = config.get(ConfigType.RUN_AS_DEVIN)
4242
USER_ID = 1000
4343
if SANDBOX_USER_ID := config.get(ConfigType.SANDBOX_USER_ID):
4444
USER_ID = int(SANDBOX_USER_ID)

opendevin/runtime/plugins/jupyter/execute_server

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class JupyterKernel:
175175
if parent_msg_id != msg_id:
176176
continue
177177

178-
if os.environ.get('DEBUG', False):
178+
if os.environ.get('DEBUG'):
179179
logging.info(
180180
f"MSG TYPE: {msg_type.upper()} DONE:{execution_done}\nCONTENT: {msg['content']}"
181181
)
@@ -221,7 +221,7 @@ class JupyterKernel:
221221
# Remove ANSI
222222
ret = strip_ansi(ret)
223223

224-
if os.environ.get('DEBUG', False):
224+
if os.environ.get('DEBUG'):
225225
logging.info(f'OUTPUT:\n{ret}')
226226
return ret
227227

0 commit comments

Comments
 (0)