Python SDK reference¶
Everything below is importable straight from the top-level package:
Parsing¶
epochix.sdk.parse.parse(path, *, task=None, primary_metric=None, run_id=None, run_name=None, db=':memory:', locale='en')
¶
Parse a training log file and return the completed :class:~epochix.models.Run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the log file. |
required |
task
|
str | TaskType | None
|
Force a task type. Auto-detected when |
None
|
primary_metric
|
str | None
|
Override the primary metric key. |
None
|
run_id
|
str | None
|
Use a specific run ID. Auto-generated when |
None
|
run_name
|
str | None
|
Human-readable name for the run. |
None
|
db
|
str
|
SQLite database path. Defaults to |
':memory:'
|
locale
|
str
|
Language code for narrative templates. |
'en'
|
Returns:
| Type | Description |
|---|---|
Run
|
Finished run object with |
Example
::
from epochix import parse
run = parse("train.log", task="biometric")
print(run.final_grade) # Grade.A_PLUS
print(run.story_summary)
Source code in src/epochix/sdk/parse.py
epochix.sdk.parse.parse_string(log_text, *, task=None, primary_metric=None, run_id=None, run_name=None, db=':memory:', locale='en')
¶
Parse a log string (useful when the log is already in memory).
Writes log_text to a temporary file and delegates to :func:parse.
Source code in src/epochix/sdk/parse.py
Live reporting¶
epochix.sdk.live_reporter.LiveReporter
¶
Push metrics from the training loop directly to epochix.
Does NOT require log parsing — the caller supplies key-value metrics. Under the hood the reporter formats them as a log line, feeds them through the SDK receiver, and runs the full pipeline in a background asyncio event loop on a dedicated thread.
Thread-safety: :meth:log and :meth:finish are safe to call from
any thread (including the PyTorch DataLoader worker threads).
Source code in src/epochix/sdk/live_reporter.py
39 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 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | |
__init__(*, task=None, primary_metric=None, name=None, total_epochs=None, port=7860, open_browser=True, locale='en', run_id=None, model=None, capture_activations=False, activation_hz=2.0, capture_gradients=True)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
str | TaskType | None
|
Task type ( |
None
|
primary_metric
|
str | None
|
Which logged metric drives the grade / phase / narrative. Pass the
same name you use in :meth: |
None
|
name
|
str | None
|
Human-readable run name shown in the dashboard. |
None
|
total_epochs
|
int | None
|
Total planned epochs, used for the progress bar. Optional. |
None
|
port
|
int
|
Local dashboard port. Use a free port if you run several at once. |
7860
|
open_browser
|
bool
|
Open the dashboard in a browser tab on start (default True). |
True
|
locale
|
str
|
Dashboard language ( |
'en'
|
run_id
|
str | None
|
Explicit run id; auto-generated when omitted. |
None
|
model
|
object | None
|
The model being trained (PyTorch |
None
|
capture_activations
|
bool
|
When True (and a |
False
|
activation_hz
|
float
|
Cap on how often each layer's activation is sampled (Hz). |
2.0
|
capture_gradients
|
bool
|
When capturing, also register backward hooks for mean |
True
|
Source code in src/epochix/sdk/live_reporter.py
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 | |
finish()
¶
Signal end of training and wait for the pipeline to flush.
Source code in src/epochix/sdk/live_reporter.py
log(**metrics)
¶
Push one epoch of metrics.
All keyword arguments are treated as metric key-value pairs.
The special key epoch is used to track training progress.
Example::
reporter.log(epoch=5, train_loss=0.312, val_accuracy=0.871)
Source code in src/epochix/sdk/live_reporter.py
log_line(text)
¶
Feed one raw log line — exactly as a training script printed it — to the parser.
Use this when you are relaying somebody else's stdout (a subprocess, a
notebook cell) and the metrics are already formatted in the line. It is
the same path epochix --live takes, so every parser applies.
Example::
reporter.log_line("Epoch 3/10 train_loss=0.42 val_accuracy=0.88")
Source code in src/epochix/sdk/live_reporter.py
Comparison¶
epochix.sdk.compare.compare(run_a, run_b, *, db=None)
¶
Compare two runs and return a :class:RunDiff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_a
|
Run | str
|
Either a :class: |
required |
run_b
|
Run | str
|
Either a :class: |
required |
db
|
str | None
|
SQLite DB path (used when run_a/run_b is a run ID string). |
None
|
Returns:
| Type | Description |
|---|---|
RunDiff
|
|
Source code in src/epochix/sdk/compare.py
Export¶
epochix.sdk.export.export(run, fmt='html', *, output=None, db=None)
¶
Export a run to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
Run
|
A completed :class: |
required |
fmt
|
ExportFormat
|
Export format: |
'html'
|
output
|
str | Path | None
|
Output path. Defaults to |
None
|
db
|
str | None
|
SQLite DB containing the run (defaults to the configured DB). |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Absolute path to the written file. |
Source code in src/epochix/sdk/export.py
Visualisation¶
epochix.sdk.visualize.visualize(run, *, port=7860, host='127.0.0.1', db=None, blocking=True)
¶
Serve a finished run and open it in the browser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
Run
|
A :class: |
required |
port
|
int
|
Port for the embedded server. |
7860
|
host
|
str
|
Bind address. |
'127.0.0.1'
|
db
|
str | None
|
SQLite DB path that contains the run (defaults to the configured DB). |
None
|
blocking
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The URL where the run is being served. |
Source code in src/epochix/sdk/visualize.py
epochix.sdk.visualize.serve(port=7860, host='127.0.0.1', db=None, open_browser=True)
¶
Start the epochix server without a specific run.
Returns the base URL. Blocks until the server is stopped.
Source code in src/epochix/sdk/visualize.py
Core models¶
epochix.models.Run
¶
Bases: BaseModel
Source code in src/epochix/models.py
epochix.models.MetricEvent
¶
Bases: BaseModel
Source code in src/epochix/models.py
epochix.models.StoryFrame
¶
Bases: BaseModel
Source code in src/epochix/models.py
Plugin interface¶
epochix.parsers.base.BaseParser
¶
Bases: Protocol
Protocol every parser must satisfy.
Source code in src/epochix/parsers/base.py
epochix.parsers.registry.register_parser(cls)
¶
Decorator: register a parser class into the global registry.