Runner

Runner.run is the entry point that wires together the solver and checker orchestrators, the save handler, and the worker-status tracker. The remaining types here are the data structures that flow through a run: RunParams configures it, OutputBatch holds the results for one data item, and the RunObserver protocol (with its status snapshots) is how a run reports progress to a consumer such as the CLI.

runner

Runner

Entry point that drives the whole evaluation pipeline. Its single classmethod run wires together the solver and checker orchestrators, the save handler, and the worker-status tracker, then streams results to the optional RunObserver (e.g. the CLI) until every data item is done.

There is no instance state — call Runner.run(...) directly.

run classmethod

run(solver_config: SolverConfig[SolutionT], checker_params: dict[str, Any], checker_factory: CheckerFactory[DataT, SolutionT], data_provider: DataProvider[DataT], params: Optional[RunParams] = None, observer: Optional[RunObserver] = None, on_batch_saved: Optional[Callable[[OutputBatch[DataT, SolutionT]], None]] = None) -> None

Run the solver/checker pipeline.

Parameters:
  • on_batch_saved (Optional[Callable[[OutputBatch[DataT, SolutionT]], None]], default: None ) –

    optional user callback invoked after each output batch has been persisted by the built-in save handler. Exceptions raised by the callback are logged and swallowed so a faulty hook cannot lose results or stop the run.

runner

CheckerState

Bases: StrEnum

States a checker worker passes through. Set by the CheckerOrchestrator around each checker.check call.

CheckerStatus dataclass

CheckerStatus(id: int, state: CheckerState, data_id: Optional[Any], solver_id: Optional[int])

A checker worker's last-reported status, as shown on the dashboard.

id instance-attribute

id: int

Index of the checker worker (0-based).

state instance-attribute

state: CheckerState

Whether the worker is idle or busy.

data_id instance-attribute

data_id: Optional[Any]

Id of the data item being checked, or None when idle.

solver_id instance-attribute

solver_id: Optional[int]

Index of the solver worker whose solution is being checked, or None.

NullObserver

Default observer used when a caller doesn't pass one — drops every event on the floor. Lets Runner and WorkerStatusTracker treat "no observer" identically to "an observer that ignores everything", so internal state always stays consistent.

RunObserver

Bases: Protocol

The single channel through which a run reports progress to the outside world. Implement this on whatever consumes run telemetry — e.g. CLI does so to drive its dashboard. Pass an instance to Runner.run(observer=...).

Both methods are called from the runner's main thread (on_progress) or from the tracker's pump thread (on_worker_status). Implementations must be thread-safe with respect to themselves but do not need locking against each other.

on_progress

on_progress(done: int, total: int) -> None

Called when the count of completed data items changes.

Parameters:
  • done (int) –

    Number of data items fully processed so far.

  • total (int) –

    Total number of data items in the run.

on_worker_status

on_worker_status(snapshot: WorkerSnapshot) -> None

Called when any worker's status changes, with a full snapshot of every solver and checker worker.

SolverState

Bases: StrEnum

States a solver worker reports through its Session.

Emitted by the solver itself via session.report(state, ...); the orchestrator never sets these. Add new variants here when the real solver needs to expose more granular phases.

SolverStatus dataclass

SolverStatus(id: int, state: SolverState, data_id: Optional[Any], curr_run: int, total_runs: int, session_length: int)

A solver worker's last-reported status, as shown on the dashboard.

id instance-attribute

id: int

Index of the solver worker (0-based).

state instance-attribute

state: SolverState

What the worker is currently doing.

data_id instance-attribute

data_id: Optional[Any]

Id of the data item being solved, or None when idle.

curr_run instance-attribute

curr_run: int

Which attempt (run) of this data item is in progress.

total_runs instance-attribute

total_runs: int

Total attempts configured per data item (runs_per_data).

session_length instance-attribute

session_length: int

Number of steps taken so far in the current solve.

WorkerSnapshot dataclass

WorkerSnapshot(solvers: tuple[SolverStatus, ...], checkers: tuple[CheckerStatus, ...])

Immutable snapshot of every worker's last-reported status. Pumped to the RunObserver by WorkerStatusTracker.

OutputBatch

OutputBatch(input_data: DataT)

All attempts the framework made on a single data item. One batch is produced per data item and persisted by the SaveHandler; it pairs each solver result with the checker's verdict for that attempt.

Supports len(batch) (the number of attempts) and iteration, which yields (solver_result, check_result) tuples — check_result is None when the solver failed and the checker was never run.

Create an empty batch for one data item.

Parameters:
  • input_data (DataT) –

    The problem instance these attempts are for.

get_data

get_data() -> DataT

Return the data item this batch holds attempts for.

append

append(solver_result: Result[SolutionT], check_result: Optional[CheckResult]) -> None

Record one attempt.

Parameters:
  • solver_result (Result[SolutionT]) –

    What the solver produced for this attempt.

  • check_result (Optional[CheckResult]) –

    The checker's verdict, or None if the checker was not run (e.g. the solver errored).

pickle

pickle() -> str

Serialize the batch to a single JSON line (via jsonpickle) for the save file.

from_pickle staticmethod

from_pickle(pickle: str) -> OutputBatch

Reconstruct a batch from a line produced by pickle.

RunParams dataclass

RunParams(save_file: Path = Path('output/results.jsonl'), metadata_file: Path = Path('output/metadata.json'), checker_workers: int = 1, solver_workers: int = 1, runs_per_data: int = 1, load_save: bool = True)

Parameters that can be passed to the Runner class methods.

save_file class-attribute instance-attribute

save_file: Path = Path('output/results.jsonl')

Where to save results during a run to prevent lost progress.

metadata_file class-attribute instance-attribute

metadata_file: Path = Path('output/metadata.json')

Where to save metadata about the run.

checker_workers class-attribute instance-attribute

checker_workers: int = 1

How many checker workers should be created.

solver_workers class-attribute instance-attribute

solver_workers: int = 1

How many solver workers should be created.

runs_per_data class-attribute instance-attribute

runs_per_data: int = 1

How many solver sessions should be attempted for each data item.

load_save class-attribute instance-attribute

load_save: bool = True

Should the save handler attempt to load the save from the provided save file.