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]

Fix: Update paths for run_batch

Kilian Lieret9efd6d2409dd
diff --git a/sweagent/run/common.py b/sweagent/run/common.py
index 53cced97..d7cce36f 100644
--- a/sweagent/run/common.py
+++ b/sweagent/run/common.py
@@ -360,7 +360,7 @@ class BasicCLI:
def save_predictions(traj_dir: Path, instance_id: str, result: AgentRunResult):
"""Save predictions in a file readable by SWE-bench"""
- output_file = traj_dir / (instance_id + ".pred")
+ output_file = traj_dir / instance_id / (instance_id + ".pred")
datum = {
"model_name_or_path": traj_dir.name,
"instance_id": instance_id,
diff --git a/sweagent/run/hooks/apply_patch.py b/sweagent/run/hooks/apply_patch.py
index 8d2614ba..6d9e97d8 100644
--- a/sweagent/run/hooks/apply_patch.py
+++ b/sweagent/run/hooks/apply_patch.py
@@ -77,7 +77,7 @@ class SaveApplyPatchHook(RunHook):
"""
patch_output_dir = self._output_dir
patch_output_dir.mkdir(exist_ok=True, parents=True)
- patch_output_file = patch_output_dir / f"{instance_id}.patch"
+ patch_output_file = patch_output_dir / instance_id / f"{instance_id}.patch"
if info.get("submission") is None:
self.logger.info("No patch to save.")
return None
diff --git a/sweagent/run/run_batch.py b/sweagent/run/run_batch.py
index c0fcfeba..9eafd68e 100644
--- a/sweagent/run/run_batch.py
+++ b/sweagent/run/run_batch.py
@@ -338,7 +338,7 @@ class RunBatch:
return False
# Check if there's an existing trajectory for this instance
- log_path = self.output_dir / (instance.problem_statement.id + ".traj")
+ log_path = self.output_dir / instance.problem_statement.id / (instance.problem_statement.id + ".traj")
if not log_path.exists():
return False
@@ -364,7 +364,7 @@ class RunBatch:
for level in ["trace", "debug", "info"]:
filter = instance_id if multi_worker else ""
add_file_handler(
- self.output_dir / filename_template.format(level=level),
+ self.output_dir / instance_id / filename_template.format(level=level),
filter=filter,
level=level,
id_=f"{instance_id}-{level}",