Skip to content

taps.run.config

LoggingConfig

Bases: BaseModel

Logging configuration.

Parameters:

  • level (int | str, default: 'INFO' ) –

    Minimum logging level for stdout.

  • file_level (int | str | None, default: None ) –

    Override logging level for the log file.

  • file_name (str | None, default: 'log.txt' ) –

    Logging file name.

RunConfig

Bases: BaseModel

Run configuration.

Parameters:

  • dir_format (str, default: 'runs/{name}_{executor}_{timestamp}' ) –

    Run directory format (supports "{name}", "{timestamp}", and "{executor}" for formatting).

  • env_vars (dict[str, str] | None, default: None ) –

    Environment variables to set during benchmarking.

Config

Bases: BaseSettings

Application benchmark configuration.

Parameters:

  • app (AppConfig) –

    Application configuration.

  • engine (EngineConfig, default: EngineConfig(executor=ProcessPoolConfig(name='process-pool', max_processes=4, context=None), filter=None, transformer=None, task_record_file_name='tasks.jsonl') ) –

    Engine configuration.

  • logging (LoggingConfig, default: LoggingConfig(level='INFO', file_level=None, file_name='log.txt') ) –

    Logging configuration.

  • run (RunConfig, default: RunConfig(dir_format='runs/{name}_{executor}_{timestamp}', env_vars=None) ) –

    Run configuration.

  • version (str, default: '0.2.2.dev1' ) –

    TaPS version (do not alter).

from_toml classmethod

from_toml(filepath: str | Path) -> Config

Load a configuration from a TOML file.

Source code in taps/run/config.py
@classmethod
def from_toml(cls, filepath: str | pathlib.Path) -> Config:
    """Load a configuration from a TOML file."""
    with open(filepath, 'rb') as f:
        options = tomllib.load(f)

    flat_options = flatten_mapping(options)
    config_cls = _make_config_cls(flat_options)

    return config_cls(**options)

write_toml

write_toml(filepath: str | Path) -> None

Write the configuration to a TOML file.

Source code in taps/run/config.py
def write_toml(self, filepath: str | pathlib.Path) -> None:
    """Write the configuration to a TOML file."""
    model = self.model_dump(
        exclude_unset=False,
        exclude_defaults=False,
        exclude_none=True,
    )

    filepath = pathlib.Path(filepath)
    filepath.parent.mkdir(parents=True, exist_ok=True)
    with open(filepath, 'wb') as f:
        tomli_w.dump(model, f)

make_run_dir

make_run_dir(config: Config) -> Path

Create and return the run directory path created from the config.

Source code in taps/run/config.py
def make_run_dir(config: Config) -> pathlib.Path:
    """Create and return the run directory path created from the config."""
    timestamp = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
    run_dir = pathlib.Path(
        config.run.dir_format.format(
            executor=config.engine.executor.name,
            name=config.app.name,
            timestamp=timestamp,
        ),
    )
    run_dir.mkdir(parents=True, exist_ok=True)
    return run_dir.resolve()