Skip to content

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]

Change: run_batch uses instance id for output

Kilian Lieret64c80fcd3365
diff --git a/pyproject.toml b/pyproject.toml
index e41acef8..7d45297c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -19,8 +19,9 @@ requires-python = ">=3.10"
license = {file = "LICENSE"}
keywords = ["nlp", "agents", "code"]
authors = [
- {name = "Carlos E. Jimenez", email = "[email protected]" },
- {name = "John Yang", email = "[email protected]" }
+ {name = "Carlos E. Jimenez", email = "[email protected]" },
+ {name = "John Yang", email = "[email protected]" },
+ {name = "Kilian Lieret", email = "[email protected]" },
]
# Classifiers help users find your project by categorizing it.
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.py
index eb98741d..33003fa8 100644
--- a/sweagent/agent/agents.py
+++ b/sweagent/agent/agents.py
@@ -860,6 +860,7 @@ class Agent:
env: The environment to run the agent on.
traj_dir: Directory to save the trajectory to
"""
+ output_dir.mkdir(parents=True, exist_ok=True)
self.setup(env=env, problem_statement=problem_statement, output_dir=output_dir)
# Run action/observation loop
diff --git a/sweagent/run/run_batch.py b/sweagent/run/run_batch.py
index 46b8c5f2..eeb1ae89 100644
--- a/sweagent/run/run_batch.py
+++ b/sweagent/run/run_batch.py
@@ -312,7 +312,7 @@ class RunBatch:
result = agent.run(
problem_statement=instance.problem_statement,
env=env,
- output_dir=Path(self.output_dir),
+ output_dir=Path(self.output_dir) / instance.problem_statement.id,
)
except Exception:
# The actual handling is happening in `run_instance`, but we need to make sure that
diff --git a/tests/test_run_batch.py b/tests/test_run_batch.py
index be938f37..d978a30f 100644
--- a/tests/test_run_batch.py
+++ b/tests/test_run_batch.py
@@ -24,7 +24,7 @@ def test_expert_instances(test_data_sources_path: Path, tmp_path: Path):
]
main(cmd)
for _id in ["simple_test_problem", "simple_test_problem_2"]:
- assert (tmp_path / f"{_id}.traj").exists(), list(tmp_path.iterdir())
+ assert (tmp_path / f"{_id}" / f"{_id}.traj").exists(), list(tmp_path.iterdir())
@pytest.mark.slow
@@ -43,7 +43,7 @@ def test_simple_instances(test_data_sources_path: Path, tmp_path: Path):
"True",
]
main(cmd)
- assert (tmp_path / "simple_test_problem.traj").exists(), list(tmp_path.iterdir())
+ assert (tmp_path / "simple_test_problem" / "simple_test_problem.traj").exists(), list(tmp_path.iterdir())
def test_empty_instances_simple(test_data_sources_path: Path, tmp_path: Path):