Skip to content

batches

Ingest-dispatch batching for wiki_toolkit.

Splits raw files under a source directory into size/count-bounded batches for parallel wiki-ingest dispatch. Runs before anything becomes a source in the domain sense (no frontmatter, no manifest) – see ADR-0011.

CLASS DESCRIPTION
Batch

A single batch of files for parallel ingest dispatch.

BatchPlan

The full result of a batch-plan pass.

BatchStats

Aggregate totals across a batch-plan run.

FUNCTION DESCRIPTION
plan_batches

Split the files under source_dir into batches of at most batch_byte_cap bytes or batch_file_cap files.

Classes

Batch dataclass

Batch(id: str, files: list[str] = list(), total_bytes: int = 0)

A single batch of files for parallel ingest dispatch.

BatchPlan dataclass

BatchPlan(batches: list[Batch], stats: BatchStats)

The full result of a batch-plan pass.

BatchStats dataclass

BatchStats(total_files: int, total_bytes: int, batch_count: int)

Aggregate totals across a batch-plan run.

Functions:

plan_batches

plan_batches(
    source_dir: Path, batch_byte_cap: int, batch_file_cap: int
) -> BatchPlan

Split the files under source_dir into batches of at most batch_byte_cap bytes or batch_file_cap files.

Files are visited in sorted order for determinism. A batch closes as soon as adding the next file would cross either cap; a single file larger than batch_byte_cap still gets its own batch rather than being split. Reports zero files if source_dir doesn’t exist.