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: Allow to disable progress bar

Kilian Lieret4412ad1507f7
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.py
index faccff0f..09694acc 100644
--- a/sweagent/agent/agents.py
+++ b/sweagent/agent/agents.py
@@ -562,6 +562,7 @@ class Agent:
step.done = True
step.observation = "Exited"
step.exit_status = "exit_command"
+ assert self._env is not None
step.state = self.tools.get_state(env=self._env) # for history
return step
@@ -613,7 +614,7 @@ class Agent:
try:
# Forward model and get actions
self._chook.on_model_query(messages=history, agent=self.name)
- output = self.model.query(history)
+ output = self.model.query(history) # type: ignore
step.output = output["message"]
if isinstance(self.model, HumanThoughtModel):
# TODO: This might be a bit hacky
diff --git a/sweagent/run/run_batch.py b/sweagent/run/run_batch.py
index 51ab0316..43783fea 100644
--- a/sweagent/run/run_batch.py
+++ b/sweagent/run/run_batch.py
@@ -54,12 +54,17 @@ class RunBatchConfig(BaseSettings, cli_implicit_flags=False):
"""Do not skip instances that already have a trajectory."""
env_var_path: Path | None = None
"""Path to a .env file to load environment variables from."""
- num_workers: int = Field(default=1, description="Number of parallel workers to use.")
+ num_workers: int = Field(default=1)
+ """Number of parallel workers to use."""
random_delay_multiplier: float = 0.3
"""We will wait for a random amount of time between 0 and `random_delay_multiplier`
times the number of workers at the start of each instance. This is to avoid any
potential race conditions.
"""
+ progress_bar: bool = True
+ """Whether to show a progress bar. Progress bar is never shown for human models.
+ Progress bar is always shown for multi-worker runs.
+ """
def set_default_output_dir(self) -> None:
# Needs to be called explicitly, because self._config_files will be setup
@@ -90,6 +95,7 @@ class RunBatch:
raise_exceptions: bool = False,
redo_existing: bool = False,
num_workers: int = 1,
+ progress_bar: bool = True,
):
"""Note: When initializing this class, make sure to add the hooks that are required by your actions.
See `from_config` for an example.
@@ -97,6 +103,8 @@ class RunBatch:
Args:
hooks: If not specified, the default hooks will be used.
num_workers: Number of parallel workers to use. Default is 1 (sequential execution).
+ progress_bar: Whether to show a progress bar. Progress bar is never shown for human models.
+ Progress bar is always shown for multi-worker runs.
"""
if agent_config.model.name in ["human", "human_thought"] and num_workers > 1:
msg = "Cannot run with human model in parallel"
@@ -121,6 +129,7 @@ class RunBatch:
self._progress_manager = RunBatchProgressManager(
num_instances=len(instances), yaml_report_path=output_dir / "run_batch_exit_statuses.yaml"
)
+ self._show_progress_bar = progress_bar
@classmethod
def from_config(cls, config: RunBatchConfig) -> Self:
@@ -168,7 +177,7 @@ class RunBatch:
def main_single_worker(self) -> None:
with ExitStack() as stack:
# Conditionally add progress bar
- if self.agent_config.model.name not in ["human", "human_thought"]:
+ if self.agent_config.model.name not in ["human", "human_thought"] and self._show_progress_bar:
stack.enter_context(Live(self._progress_manager.render_group))
for instance in self.instances:
try: