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: add_hooks for run_batch
Kilian Lieretd9f23a39141c
diff --git a/sweagent/run/hooks/swe_bench_evaluate.py b/sweagent/run/hooks/swe_bench_evaluate.pyindex a3a89dd7..ce1c5e46 100644--- a/sweagent/run/hooks/swe_bench_evaluate.py+++ b/sweagent/run/hooks/swe_bench_evaluate.py@@ -2,6 +2,7 @@ import subprocessfrom pathlib import Pathfrom sweagent.run.hooks.abstract import RunHook+from sweagent.utils.log import get_loggerclass SweBenchEvaluate(RunHook):@@ -12,6 +13,12 @@ class SweBenchEvaluate(RunHook):self.output_dir = output_dirself.subset = subsetself.split = split+ self.logger = get_logger("SB-evaluate", emoji="😬")def on_end(self) -> None:- subprocess.run(["sb-cli", "submit", self._SUBSET_MAP[self.subset], self.split, self.output_dir.name])+ try:+ subprocess.check_output(+ ["sb-cli", "submit", self._SUBSET_MAP[self.subset], self.split, self.output_dir.name]+ )+ except subprocess.CalledProcessError as e:+ self.logger.error("Failed to submit results to SweBench eval: %s", e)diff --git a/sweagent/run/run_batch.py b/sweagent/run/run_batch.pyindex e7f2b7b6..3a548215 100644--- a/sweagent/run/run_batch.py+++ b/sweagent/run/run_batch.py@@ -149,7 +149,6 @@ class RunBatch:self.instances = instancesself.agent_config = agent_configself.output_dir = output_dir- self._hooks = []self._raise_exceptions = raise_exceptionsself._chooks = CombinedRunHooks()self._redo_existing = redo_existing@@ -199,7 +198,7 @@ class RunBatch:def add_hook(self, hook: RunHook) -> None:hook.on_init(run=self)- self._hooks.append(hook)+ self._chooks.add_hook(hook)def main(self) -> None:self.logger.info("Starting run. Find output files at %s", self.output_dir)