evalwire.runner¶
ExperimentRunner auto-discovers experiment subdirectories, fetches the matching Phoenix dataset for each one, and runs the task against every example. Results are stored in Phoenix and returned as a list.
Basic usage¶
from phoenix.client import Client
from evalwire.runner import ExperimentRunner
client = Client()
runner = ExperimentRunner(
experiments_dir="experiments",
phoenix_client=client,
concurrency=2,
)
results = runner.run()
Directory layout¶
Each subdirectory of experiments_dir that contains a task.py is treated as one experiment. The directory name must exactly match a Phoenix dataset name:
experiments/
es_search/ <- matches dataset named "es_search"
task.py <- must define async def task(example)
top_k.py <- evaluator: must define top_k = ...
exact_match.py <- evaluator: must define exact_match = ...
source_router/ <- matches dataset named "source_router"
task.py
is_in.py
Subdirectories without task.py are silently skipped. Files (non-directories) at the top level of experiments_dir are also skipped.
Experiment naming¶
Each run in Phoenix is named {prefix}_{dataset_name}_{iso_timestamp}. The default prefix is "eval". Override it with experiment_name_prefix:
results = runner.run(experiment_name_prefix="nightly")
# produces e.g. "nightly_es_search_2025-01-15T09:30:00"
Running a subset¶
Pass names to run only specific experiments:
Dry run¶
Set dry_run=True (or dry_run=N to limit to N examples) to execute tasks without uploading results to Phoenix. Useful for smoke-testing your task code:
runner = ExperimentRunner(
experiments_dir="experiments",
phoenix_client=client,
dry_run=3,
)
runner.run()
Async tasks¶
Tasks are async functions. evalwire wraps them in a per-thread event loop so Phoenix's synchronous runner can call them. The loop is kept open between calls (unlike asyncio.run()) so that async I/O libraries which reuse connections across calls work correctly.
Error behaviour¶
If any experiment fails (dataset not found, task raises, evaluator raises), runner.run() raises SystemExit(1) after all experiments complete so that CI pipelines fail loudly. Successful experiments are still returned.
Pitfalls¶
- The dataset name must match the directory name exactly (case-sensitive).
- At least one evaluator file is required per experiment. Phoenix raises an error if
run_experimentis called with an empty evaluator list. - Relative imports inside experiment modules work because evalwire adds the parent of
experiments_dirtosys.pathduring discovery. It is removed again afterwards.
See also¶
- Concepts for the experiment lifecycle
- Configuration Reference for
evalwire.tomlkeys - CLI Reference for
evalwire run
evalwire.runner
¶
ExperimentRunner — auto-discovers and executes evalwire experiments.
ExperimentRunner
¶
Discover, load, and run all experiments under experiments_dir.
Each subdirectory that contains a task.py file is treated as one
experiment. The directory name must match the name of a Phoenix dataset.
Parameters¶
experiments_dir:
Root directory containing per-experiment subdirectories.
phoenix_client:
An initialised phoenix.client.Client instance.
concurrency:
Number of experiments to run in parallel. Default: 1 (sequential).
dry_run:
If True, run one example per experiment without uploading results.
If an int, run that many examples.
Source code in src/evalwire/runner.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
run(names=None, *, experiment_name_prefix='eval', metadata=None)
¶
Discover, load, and run experiments.
Parameters¶
names:
If provided, only run experiments whose directory names are in
this list. If None, run all discovered experiments.
experiment_name_prefix:
Prefix for the auto-generated experiment name in Phoenix.
Format: "{prefix}_{dataset_name}_{iso_timestamp}".
metadata:
Extra key/value pairs attached to each experiment record.
Returns¶
list One experiment result object per experiment.
Source code in src/evalwire/runner.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |