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]

RunBatchProgressManager: some renmaes & doc

Kilian Lieret22b429e2f989
diff --git a/sweagent/run/_progress.py b/sweagent/run/_progress.py
index 1405a341..633784ba 100644
--- a/sweagent/run/_progress.py
+++ b/sweagent/run/_progress.py
@@ -1,3 +1,5 @@
+"""This module contains an auxiliary class for rendering progress of the batch run."""
+
import collections
from threading import Lock
@@ -20,8 +22,17 @@ class RunBatchProgressManager:
self,
num_instances: int,
):
+ """This class manages a progress bar/UI for run-batch
+
+ Args:
+ num_instances: Number of task instances
+ """
+
self._spinner_tasks: dict[str, TaskID] = {}
+ """We need to map instance ID to the task ID that is used by the rich progress bar."""
+
self._lock = Lock()
+
self.exit_status_histogram = collections.defaultdict(int)
self._main_progress_bar = Progress(
SpinnerColumn(),
@@ -37,11 +48,17 @@ class RunBatchProgressManager:
TextColumn("{task.fields[status]}"),
TimeElapsedColumn(),
)
+ """Task progress bar for individual instances. There's only one progress bar
+ with one task for each instance.
+ """
+
self._main_progress_bar.add_task("[cyan]Overall Progress", total=num_instances)
self.render_group = Group(Table(), self._main_progress_bar, self._task_progress_bar)
def update_exit_status_table(self):
+ # We cannot update the existing table, so we need to create a new one and
+ # assign it back to the render group.
t = Table()
t.add_column("Exit Status")
t.add_column("Count")
@@ -54,7 +71,7 @@ class RunBatchProgressManager:
assert self.render_group is not None
self.render_group.renderables[0] = t
- def update_task_progress(self, instance_id: str, message: str):
+ def update_instance_status(self, instance_id: str, message: str):
assert self._task_progress_bar is not None
assert self._main_progress_bar is not None
with self._lock:
diff --git a/sweagent/run/run_batch.py b/sweagent/run/run_batch.py
index 396c9a5b..decdd96e 100644
--- a/sweagent/run/run_batch.py
+++ b/sweagent/run/run_batch.py
@@ -205,12 +205,12 @@ class RunBatch:
self.agent_config.name = f"{instance.problem_statement.id}"
agent = Agent.from_config(self.agent_config)
agent.logger.setLevel(logging.DEBUG if self._num_workers == 1 else logging.WARNING)
- agent.add_hook(SetStatusAgentHook(instance.problem_statement.id, self._progress_manager.update_task_progress))
- self._progress_manager.update_task_progress(instance.problem_statement.id, "Starting environment")
+ agent.add_hook(SetStatusAgentHook(instance.problem_statement.id, self._progress_manager.update_instance_status))
+ self._progress_manager.update_instance_status(instance.problem_statement.id, "Starting environment")
instance.env.name = f"{instance.problem_statement.id}"
env = SWEEnv.from_config(instance.env)
env.add_hook(
- SetStatusEnvironmentHook(instance.problem_statement.id, self._progress_manager.update_task_progress)
+ SetStatusEnvironmentHook(instance.problem_statement.id, self._progress_manager.update_instance_status)
)
env.logger.setLevel(logging.DEBUG if self._num_workers == 1 else logging.INFO)
env.deployment.logger.setLevel(logging.DEBUG if self._num_workers == 1 else logging.WARNING) # type: ignore