Skip to content

Run batch

sweagent.run.run_batch.RunBatchConfig

Bases: BaseSettings

agent class-attribute instance-attribute

agent: AgentConfig = Field(description='Agent options.')

env_var_path class-attribute instance-attribute

env_var_path: Path | None = None

Path to a .env file to load environment variables from.

instances class-attribute instance-attribute

instances: BatchInstanceSourceConfig = Field(description='Instances to run.')

num_workers class-attribute instance-attribute

num_workers: int = Field(default=1)

Number of parallel workers to use.

output_dir class-attribute instance-attribute

output_dir: Path = Field(default=Path('DEFAULT'), description='Output directory.')

progress_bar class-attribute instance-attribute

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.

raise_exceptions class-attribute instance-attribute

raise_exceptions: bool = False

Raise exceptions instead of skipping instances.

random_delay_multiplier class-attribute instance-attribute

random_delay_multiplier: float = 1

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.

redo_existing class-attribute instance-attribute

redo_existing: bool = False

Do not skip instances that already have a trajectory.

suffix class-attribute instance-attribute

suffix: str = ''

Suffix to add to the output directory. Only used if output_dir is DEFAULT.

set_default_output_dir

set_default_output_dir() -> None
Source code in sweagent/run/run_batch.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
def set_default_output_dir(self) -> None:
    # Needs to be called explicitly, because self._config_files will be setup
    # post-init.
    if self.output_dir == Path("DEFAULT"):
        user_id = getpass.getuser()
        source_id = self.instances.id
        model_id = self.agent.model.id
        config_file = getattr(self, "_config_files", ["no_config"])[0]
        if config_file != "no_config":
            config_file = Path(config_file).stem
        suffix = f"__{self.suffix}" if self.suffix else ""
        self.output_dir = Path.cwd() / "trajectories" / user_id / f"{config_file}__{model_id}___{source_id}{suffix}"