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]

run_batch: Evaluate swe-bench every n minutes instead of n instances

Kilian Lieretde4389eab3a9
diff --git a/sweagent/run/hooks/swe_bench_evaluate.py b/sweagent/run/hooks/swe_bench_evaluate.py
index 663a4efc..326e8971 100644
--- a/sweagent/run/hooks/swe_bench_evaluate.py
+++ b/sweagent/run/hooks/swe_bench_evaluate.py
@@ -3,6 +3,7 @@ import subprocess
import sys
from pathlib import Path
from threading import Lock
+from time import time
from sweagent.run.hooks.abstract import RunHook
from sweagent.run.merge_predictions import merge_predictions
@@ -20,8 +21,9 @@ class SweBenchEvaluate(RunHook):
self.split = split
self.continuous_submission_every = continuous_submission_every
self.logger = get_logger("SB-evaluate", emoji="😬")
- self.n_completed = 0
self.merge_lock = Lock()
+ self.last_evaluation_time = time()
+ self.evaluation_interval = continuous_submission_every
def _get_sb_call(self, preds_path: Path, prefix: str = "", overwrite: bool = False) -> list[str]:
args = [
@@ -41,15 +43,19 @@ class SweBenchEvaluate(RunHook):
return args
def on_instance_completed(self, *, result: AgentRunResult):
- self.n_completed += 1
- if self.continuous_submission_every == 0:
+ if self.evaluation_interval == 0:
return
- if self.n_completed % self.continuous_submission_every != self.continuous_submission_every - 1:
+
+ current_time = time()
+ if current_time - self.last_evaluation_time < self.evaluation_interval:
return
+
with self.merge_lock:
merge_predictions([self.output_dir], self.output_dir / "tmppreds.json")
+ self.last_evaluation_time = current_time
+
subprocess.Popen(
- self._get_sb_call(preds_path=self.output_dir / "tmppreds.json", prefix="-tmp", overwrite=True),
+ self._get_sb_call(preds_path=self.output_dir / "tmppreds.json", prefix="tmp-", overwrite=True),
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
diff --git a/sweagent/run/run_batch.py b/sweagent/run/run_batch.py
index a4a08896..dc69af0e 100644
--- a/sweagent/run/run_batch.py
+++ b/sweagent/run/run_batch.py
@@ -191,7 +191,7 @@ class RunBatch:
output_dir=config.output_dir,
subset=config.instances.subset,
split=config.instances.split,
- continuous_submission_every=5,
+ continuous_submission_every=5 * 60,
)
)
return rb