SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
CI: Fix unittests after introducing registry bundle
Kilian Liereta2fcd6ee9d66
diff --git a/tests/test_data/trajectories/gpt4__swe-agent-test-repo__default_from_url__t-0.00__p-0.95__c-3.00__install-1/6e44b9__sweagenttestrepo-1c2844.traj b/tests/test_data/trajectories/gpt4__swe-agent-test-repo__default_from_url__t-0.00__p-0.95__c-3.00__install-1/6e44b9__sweagenttestrepo-1c2844.trajindex 70990c20..1f6ab09d 100644--- a/tests/test_data/trajectories/gpt4__swe-agent-test-repo__default_from_url__t-0.00__p-0.95__c-3.00__install-1/6e44b9__sweagenttestrepo-1c2844.traj+++ b/tests/test_data/trajectories/gpt4__swe-agent-test-repo__default_from_url__t-0.00__p-0.95__c-3.00__install-1/6e44b9__sweagenttestrepo-1c2844.traj@@ -260,6 +260,10 @@}},"bundles": [+ {+ "path": "tools/registry",+ "hidden_tools": []+ },{"path": "tools/defaults","hidden_tools": []diff --git a/tests/test_run_single.py b/tests/test_run_single.pyindex bb30317f..76bf45c0 100644--- a/tests/test_run_single.py+++ b/tests/test_run_single.py@@ -33,6 +33,7 @@ def test_run_single_raises_exception():def agent_config_with_commands():ac = AgentConfig(model=InstantEmptySubmitModelConfig())ac.tools.bundles = [+ Bundle(path=TOOLS_DIR / "registry"),Bundle(path=TOOLS_DIR / "defaults"),Bundle(path=TOOLS_DIR / "submit"),]@@ -48,6 +49,7 @@ def test_hidden_tools(tmpdir):ac = AgentConfig(model=InstantEmptySubmitModelConfig())ac.tools.env_variables = {"WINDOW": 100}ac.tools.bundles = [+ Bundle(path=TOOLS_DIR / "registry"),Bundle(path=TOOLS_DIR / "defaults", hidden_tools=["scroll_up"]),Bundle(path=TOOLS_DIR / "submit"),]diff --git a/tests/tools/test_default_utils.py b/tests/tools/test_default_utils.pyindex 619d8754..4dfc54e2 100644--- a/tests/tools/test_default_utils.py+++ b/tests/tools/test_default_utils.py@@ -10,9 +10,9 @@ from tests.utils import make_python_tool_importableDEFAULT_TOOLS_DIR = TOOLS_DIR / "defaults"DEFAULT_TOOLS_BIN = DEFAULT_TOOLS_DIR / "bin"-make_python_tool_importable(DEFAULT_TOOLS_DIR / "lib/default_utils.py", "default_utils")-import default_utils # type: ignore-from windowed_file import WindowedFile # type: ignore+make_python_tool_importable(DEFAULT_TOOLS_DIR / "lib/windowed_file.py", "windowed_file")+import windowed_file # type: ignore+from windowed_file import TextNotFound, WindowedFile # type: ignoredef test_env_file_override(with_tmp_env_file):@@ -59,7 +59,7 @@ def test_windowed_file(windowed_file):wfile.print_window()# Line 50 is now the 2nd line of the new windowassert wfile.line_range == (47, 56)- with pytest.raises(default_utils.TextNotFound):+ with pytest.raises(TextNotFound):wfile.replace_in_window("asdf", "Hello, world!")diff --git a/tools/defaults/lib/flake8_utils.py b/tools/defaults/lib/flake8_utils.pyindex 441e2a20..3be17cad 100644--- a/tools/defaults/lib/flake8_utils.py+++ b/tools/defaults/lib/flake8_utils.py@@ -18,6 +18,7 @@ else:default_lib = TOOLS_DIR / "defaults" / "lib"assert default_lib.is_dir()sys.path.append(str(default_lib))+ sys.path.append(str(TOOLS_DIR / "registry" / "lib"))from registry import registrydiff --git a/tools/defaults/lib/windowed_file.py b/tools/defaults/lib/windowed_file.pyindex 9a570023..fcff90aa 100644--- a/tools/defaults/lib/windowed_file.py+++ b/tools/defaults/lib/windowed_file.py@@ -2,6 +2,16 @@ import jsonimport osfrom pathlib import Pathfrom typing import Any, List, Optional, Tuple, Union++try:+ from sweagent import TOOLS_DIR+except ImportError:+ pass+else:+ import sys++ sys.path.append(str(TOOLS_DIR / "registry" / "lib"))+from registry import registrydiff --git a/tools/edit_linting/bin/edit b/tools/edit_linting/bin/editindex 80c476ad..115ad31a 100644--- a/tools/edit_linting/bin/edit+++ b/tools/edit_linting/bin/edit@@ -12,6 +12,7 @@ else:default_lib = TOOLS_DIR / "defaults" / "lib"assert default_lib.is_dir()sys.path.append(str(default_lib))+ sys.path.append(str(TOOLS_DIR / "registry" / "lib"))from windowed_file import FileNotOpened, WindowedFile # type: ignorefrom flake8_utils import flake8, format_flake8_output # type: ignorediff --git a/tools/edit_replace/bin/edit b/tools/edit_replace/bin/editindex 3a5ab391..2613457a 100644--- a/tools/edit_replace/bin/edit+++ b/tools/edit_replace/bin/edit@@ -12,6 +12,7 @@ else:default_lib = TOOLS_DIR / "defaults" / "lib"assert default_lib.is_dir()sys.path.append(str(default_lib))+ sys.path.append(str(TOOLS_DIR / "registry" / "lib"))from windowed_file import FileNotOpened, TextNotFound, WindowedFile # type: ignorefrom flake8_utils import flake8, format_flake8_output # type: ignore