Class Definition
Description
TheRunner class is the lower-level interface for executing discovery runs. It provides more control than the high-level run_discovery function and is suitable for:
- Custom discovery workflows
- Integration with existing systems
- Direct access to database and controller objects
- Custom monitoring and checkpointing logic
Constructor Parameters
str
required
Path to the evaluator script. The script must define an
evaluate() function that accepts a program path and returns a metrics dictionary.Optional[str]
Path to the starting solution file. If
None, the LLM generates solutions from scratch.Default: NoneOptional[str]
Path to a YAML configuration file. Ignored if
config parameter is provided.Default: NoneOptional[Config]
Pre-built
Config object. Takes priority over config_path.Default: NoneOptional[str]
Directory where logs, checkpoints, and best program are written. Auto-generated from search type and problem name if omitted.Default:
None (auto-generated)Properties
Optional[float]
Score of the seed program, or
None if unavailable.This property searches the database for the initial program and returns its score.Methods
run
Optional[int]
Maximum iterations to run. Uses
config.max_iterations if None.Default: NoneOptional[str]
Resume from this checkpoint directory if provided.Default:
NoneOptional[Program] - Best program found, or None if no valid programs were produced.
Attributes
Config
Configuration object for the run
str
Search algorithm name from config
str
Directory for results and logs
Optional[str]
Path to the initial program file
Optional[str]
Source code of the initial program
str
File extension for generated programs (e.g., “.py”)
ProgramDatabase
Database instance for storing programs
str
Path to the evaluator script
Optional[DiscoveryController]
Controller instance managing the discovery process
Examples
Basic Usage
With Custom Config
Resuming from Checkpoint
Accessing Database During Run
Starting from Scratch
Custom File Extension
Monitoring Progress
Error Handling
Output Directory Structure
After running, the output directory contains:Notes
- The
Runnerclass is async and must be used withasyncio.run()or within an async context - The runner automatically sets up signal handlers for graceful shutdown (SIGINT, SIGTERM)
- Checkpoints are saved periodically during the run
- If monitoring is enabled, a live web interface is available during execution
- The runner detects the programming language from the initial program file extension
- Use the
initial_scoreproperty to compare improvement over the initial solution
See Also
- run_discovery - High-level synchronous interface
- Program - Program object structure
- Config - Configuration options