|
@@ -6,7 +6,6 @@ from openhands.core.config import (
|
|
|
AgentConfig,
|
|
AgentConfig,
|
|
|
AppConfig,
|
|
AppConfig,
|
|
|
LLMConfig,
|
|
LLMConfig,
|
|
|
- UndefinedString,
|
|
|
|
|
finalize_config,
|
|
finalize_config,
|
|
|
get_llm_config_arg,
|
|
get_llm_config_arg,
|
|
|
load_from_env,
|
|
load_from_env,
|
|
@@ -82,12 +81,8 @@ def test_load_from_old_style_env(monkeypatch, default_config):
|
|
|
assert default_config.get_agent_config().memory_enabled is True
|
|
assert default_config.get_agent_config().memory_enabled is True
|
|
|
assert default_config.default_agent == 'PlannerAgent'
|
|
assert default_config.default_agent == 'PlannerAgent'
|
|
|
assert default_config.workspace_base == '/opt/files/workspace'
|
|
assert default_config.workspace_base == '/opt/files/workspace'
|
|
|
- assert (
|
|
|
|
|
- default_config.workspace_mount_path is UndefinedString.UNDEFINED
|
|
|
|
|
- ) # before finalize_config
|
|
|
|
|
- assert (
|
|
|
|
|
- default_config.workspace_mount_path_in_sandbox is not UndefinedString.UNDEFINED
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ assert default_config.workspace_mount_path is None # before finalize_config
|
|
|
|
|
+ assert default_config.workspace_mount_path_in_sandbox is not None
|
|
|
assert default_config.sandbox.base_container_image == 'custom_image'
|
|
assert default_config.sandbox.base_container_image == 'custom_image'
|
|
|
|
|
|
|
|
|
|
|
|
@@ -148,11 +143,8 @@ default_agent = "TestAgent"
|
|
|
assert default_config.workspace_base == '/opt/files2/workspace'
|
|
assert default_config.workspace_base == '/opt/files2/workspace'
|
|
|
assert default_config.sandbox.timeout == 1
|
|
assert default_config.sandbox.timeout == 1
|
|
|
|
|
|
|
|
- # before finalize_config, workspace_mount_path is UndefinedString.UNDEFINED if it was not set
|
|
|
|
|
- assert default_config.workspace_mount_path is UndefinedString.UNDEFINED
|
|
|
|
|
- assert (
|
|
|
|
|
- default_config.workspace_mount_path_in_sandbox is not UndefinedString.UNDEFINED
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ assert default_config.workspace_mount_path is None
|
|
|
|
|
+ assert default_config.workspace_mount_path_in_sandbox is not None
|
|
|
assert default_config.workspace_mount_path_in_sandbox == '/workspace'
|
|
assert default_config.workspace_mount_path_in_sandbox == '/workspace'
|
|
|
|
|
|
|
|
finalize_config(default_config)
|
|
finalize_config(default_config)
|
|
@@ -231,8 +223,7 @@ sandbox_user_id = 1001
|
|
|
|
|
|
|
|
load_from_toml(default_config, temp_toml_file)
|
|
load_from_toml(default_config, temp_toml_file)
|
|
|
|
|
|
|
|
- # before finalize_config, workspace_mount_path is UndefinedString.UNDEFINED if it was not set
|
|
|
|
|
- assert default_config.workspace_mount_path is UndefinedString.UNDEFINED
|
|
|
|
|
|
|
+ assert default_config.workspace_mount_path is None
|
|
|
|
|
|
|
|
load_from_env(default_config, os.environ)
|
|
load_from_env(default_config, os.environ)
|
|
|
|
|
|
|
@@ -244,11 +235,9 @@ sandbox_user_id = 1001
|
|
|
|
|
|
|
|
# after we set workspace_base to 'UNDEFINED' in the environment,
|
|
# after we set workspace_base to 'UNDEFINED' in the environment,
|
|
|
# workspace_base should be set to that
|
|
# workspace_base should be set to that
|
|
|
- # workspace_mount path is still UndefinedString.UNDEFINED
|
|
|
|
|
- assert default_config.workspace_base is not UndefinedString.UNDEFINED
|
|
|
|
|
|
|
+ assert default_config.workspace_base is not None
|
|
|
assert default_config.workspace_base == 'UNDEFINED'
|
|
assert default_config.workspace_base == 'UNDEFINED'
|
|
|
- assert default_config.workspace_mount_path is UndefinedString.UNDEFINED
|
|
|
|
|
- assert default_config.workspace_mount_path == 'UNDEFINED'
|
|
|
|
|
|
|
+ assert default_config.workspace_mount_path is None
|
|
|
|
|
|
|
|
assert default_config.disable_color is True
|
|
assert default_config.disable_color is True
|
|
|
assert default_config.sandbox.timeout == 1000
|
|
assert default_config.sandbox.timeout == 1000
|
|
@@ -284,8 +273,7 @@ user_id = 1001
|
|
|
|
|
|
|
|
load_from_toml(default_config, temp_toml_file)
|
|
load_from_toml(default_config, temp_toml_file)
|
|
|
|
|
|
|
|
- # before finalize_config, workspace_mount_path is UndefinedString.UNDEFINED if it was not set
|
|
|
|
|
- assert default_config.workspace_mount_path is UndefinedString.UNDEFINED
|
|
|
|
|
|
|
+ assert default_config.workspace_mount_path is None
|
|
|
|
|
|
|
|
# before load_from_env, values are set to the values from the toml file
|
|
# before load_from_env, values are set to the values from the toml file
|
|
|
assert default_config.get_llm_config().api_key == 'toml-api-key'
|
|
assert default_config.get_llm_config().api_key == 'toml-api-key'
|
|
@@ -338,9 +326,7 @@ user_id = 1001
|
|
|
def test_defaults_dict_after_updates(default_config):
|
|
def test_defaults_dict_after_updates(default_config):
|
|
|
# Test that `defaults_dict` retains initial values after updates.
|
|
# Test that `defaults_dict` retains initial values after updates.
|
|
|
initial_defaults = default_config.defaults_dict
|
|
initial_defaults = default_config.defaults_dict
|
|
|
- assert (
|
|
|
|
|
- initial_defaults['workspace_mount_path']['default'] is UndefinedString.UNDEFINED
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ assert initial_defaults['workspace_mount_path']['default'] is None
|
|
|
assert initial_defaults['default_agent']['default'] == 'CodeActAgent'
|
|
assert initial_defaults['default_agent']['default'] == 'CodeActAgent'
|
|
|
|
|
|
|
|
updated_config = AppConfig()
|
|
updated_config = AppConfig()
|
|
@@ -352,10 +338,7 @@ def test_defaults_dict_after_updates(default_config):
|
|
|
|
|
|
|
|
defaults_after_updates = updated_config.defaults_dict
|
|
defaults_after_updates = updated_config.defaults_dict
|
|
|
assert defaults_after_updates['default_agent']['default'] == 'CodeActAgent'
|
|
assert defaults_after_updates['default_agent']['default'] == 'CodeActAgent'
|
|
|
- assert (
|
|
|
|
|
- defaults_after_updates['workspace_mount_path']['default']
|
|
|
|
|
- is UndefinedString.UNDEFINED
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ assert defaults_after_updates['workspace_mount_path']['default'] is None
|
|
|
assert defaults_after_updates['sandbox']['timeout']['default'] == 120
|
|
assert defaults_after_updates['sandbox']['timeout']['default'] == 120
|
|
|
assert (
|
|
assert (
|
|
|
defaults_after_updates['sandbox']['base_container_image']['default']
|
|
defaults_after_updates['sandbox']['base_container_image']['default']
|
|
@@ -384,17 +367,16 @@ def test_invalid_toml_format(monkeypatch, temp_toml_file, default_config):
|
|
|
|
|
|
|
|
def test_finalize_config(default_config):
|
|
def test_finalize_config(default_config):
|
|
|
# Test finalize config
|
|
# Test finalize config
|
|
|
- assert default_config.workspace_mount_path is UndefinedString.UNDEFINED
|
|
|
|
|
|
|
+ assert default_config.workspace_mount_path is None
|
|
|
|
|
+ default_config.workspace_base = None
|
|
|
finalize_config(default_config)
|
|
finalize_config(default_config)
|
|
|
|
|
|
|
|
- assert default_config.workspace_mount_path == os.path.abspath(
|
|
|
|
|
- default_config.workspace_base
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ assert default_config.workspace_mount_path is None
|
|
|
|
|
|
|
|
|
|
|
|
|
-# tests for workspace, mount path, path in sandbox, cache dir
|
|
|
|
|
def test_workspace_mount_path_default(default_config):
|
|
def test_workspace_mount_path_default(default_config):
|
|
|
- assert default_config.workspace_mount_path is UndefinedString.UNDEFINED
|
|
|
|
|
|
|
+ assert default_config.workspace_mount_path is None
|
|
|
|
|
+ default_config.workspace_base = '/home/user/project'
|
|
|
finalize_config(default_config)
|
|
finalize_config(default_config)
|
|
|
assert default_config.workspace_mount_path == os.path.abspath(
|
|
assert default_config.workspace_mount_path == os.path.abspath(
|
|
|
default_config.workspace_base
|
|
default_config.workspace_base
|