mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
Fix type and default value of the code_execution_config parameter in UserProxyAgent (#1996)
* fix type and default value of the code_execution_config of UserProxAgent * fix type and default value of the code_execution_config of UserProxAgent * set default value of llm_config in UserProxyAgent to None * fixed tests * revert llm_config to False --------- Co-authored-by: Chi Wang <wang.chi@microsoft.com>
This commit is contained in:
@@ -16,17 +16,6 @@ else:
|
||||
skip = False or skip_openai
|
||||
|
||||
|
||||
def get_current_autogen_env_var():
|
||||
return os.environ.get("AUTOGEN_USE_DOCKER", None)
|
||||
|
||||
|
||||
def restore_autogen_env_var(current_env_value):
|
||||
if current_env_value is None:
|
||||
del os.environ["AUTOGEN_USE_DOCKER"]
|
||||
else:
|
||||
os.environ["AUTOGEN_USE_DOCKER"] = current_env_value
|
||||
|
||||
|
||||
def docker_running():
|
||||
return is_docker_running() or in_docker_container()
|
||||
|
||||
@@ -54,10 +43,9 @@ def test_agent_setup_with_use_docker_false():
|
||||
|
||||
|
||||
@pytest.mark.skipif(skip, reason="openai not installed")
|
||||
def test_agent_setup_with_env_variable_false_and_docker_running():
|
||||
current_env_value = get_current_autogen_env_var()
|
||||
def test_agent_setup_with_env_variable_false_and_docker_running(monkeypatch):
|
||||
monkeypatch.setenv("AUTOGEN_USE_DOCKER", "False")
|
||||
|
||||
os.environ["AUTOGEN_USE_DOCKER"] = "False"
|
||||
user_proxy = UserProxyAgent(
|
||||
name="test_agent",
|
||||
human_input_mode="NEVER",
|
||||
@@ -65,21 +53,26 @@ def test_agent_setup_with_env_variable_false_and_docker_running():
|
||||
|
||||
assert user_proxy._code_execution_config["use_docker"] is False
|
||||
|
||||
restore_autogen_env_var(current_env_value)
|
||||
|
||||
|
||||
@pytest.mark.skipif(skip or (not docker_running()), reason="openai not installed OR docker not running")
|
||||
def test_agent_setup_with_default_and_docker_running():
|
||||
def test_agent_setup_with_default_and_docker_running(monkeypatch):
|
||||
monkeypatch.delenv("AUTOGEN_USE_DOCKER", raising=False)
|
||||
|
||||
assert os.getenv("AUTOGEN_USE_DOCKER") is None
|
||||
|
||||
user_proxy = UserProxyAgent(
|
||||
name="test_agent",
|
||||
human_input_mode="NEVER",
|
||||
)
|
||||
|
||||
assert os.getenv("AUTOGEN_USE_DOCKER") is None
|
||||
|
||||
assert user_proxy._code_execution_config["use_docker"] is True
|
||||
|
||||
|
||||
@pytest.mark.skipif(skip or (docker_running()), reason="openai not installed OR docker running")
|
||||
def test_raises_error_agent_setup_with_default_and_docker_not_running():
|
||||
def test_raises_error_agent_setup_with_default_and_docker_not_running(monkeypatch):
|
||||
monkeypatch.delenv("AUTOGEN_USE_DOCKER", raising=False)
|
||||
with pytest.raises(RuntimeError):
|
||||
UserProxyAgent(
|
||||
name="test_agent",
|
||||
@@ -88,10 +81,8 @@ def test_raises_error_agent_setup_with_default_and_docker_not_running():
|
||||
|
||||
|
||||
@pytest.mark.skipif(skip or (docker_running()), reason="openai not installed OR docker running")
|
||||
def test_raises_error_agent_setup_with_env_variable_true_and_docker_not_running():
|
||||
current_env_value = get_current_autogen_env_var()
|
||||
|
||||
os.environ["AUTOGEN_USE_DOCKER"] = "True"
|
||||
def test_raises_error_agent_setup_with_env_variable_true_and_docker_not_running(monkeypatch):
|
||||
monkeypatch.setenv("AUTOGEN_USE_DOCKER", "True")
|
||||
|
||||
with pytest.raises(RuntimeError):
|
||||
UserProxyAgent(
|
||||
@@ -99,14 +90,10 @@ def test_raises_error_agent_setup_with_env_variable_true_and_docker_not_running(
|
||||
human_input_mode="NEVER",
|
||||
)
|
||||
|
||||
restore_autogen_env_var(current_env_value)
|
||||
|
||||
|
||||
@pytest.mark.skipif(skip or (not docker_running()), reason="openai not installed OR docker not running")
|
||||
def test_agent_setup_with_env_variable_true_and_docker_running():
|
||||
current_env_value = get_current_autogen_env_var()
|
||||
|
||||
os.environ["AUTOGEN_USE_DOCKER"] = "True"
|
||||
def test_agent_setup_with_env_variable_true_and_docker_running(monkeypatch):
|
||||
monkeypatch.setenv("AUTOGEN_USE_DOCKER", "True")
|
||||
|
||||
user_proxy = UserProxyAgent(
|
||||
name="test_agent",
|
||||
@@ -114,5 +101,3 @@ def test_agent_setup_with_env_variable_true_and_docker_running():
|
||||
)
|
||||
|
||||
assert user_proxy._code_execution_config["use_docker"] is True
|
||||
|
||||
restore_autogen_env_var(current_env_value)
|
||||
|
||||
Reference in New Issue
Block a user