Skip to main content

Module persist

Module persist 

Source
Expand description

Automatic persistence of an eval run: write it as a JSON RunRecord into a results directory and (re)generate the self-contained report.html over every run saved there.

This is the engine behind RunMeta::persist_to: when a run carries a Persist target, run_eval_with_meta assembles a RunRecord via build_record and writes it + the report via write_record_and_report once the EvalReport is ready (the one-shot save_and_report does both), so a host gets the saved JSON + the HTML report for free — no manual wiring. The same record is reused for the optional EvalForge upload, so the saved file and the uploaded record share one timestamp / dedup key. The filename pattern ({slug(model)}_{timestamp_file}.json), the pretty-printed JSON, and the “warn, don’t fail” posture all match the convention hosts used before this was built in, so existing results/*.json and report.html stay shape-compatible.

Structs§

Persist
Where and how to persist a run, attached to a RunMeta via RunMeta::persist_to. When present on the meta passed to a run, the runner writes {slug(model)}_{timestamp_file}.json into results_dir and regenerates results_dir/report.html.

Functions§

build_record
Assemble a RunRecord from a finished report plus the run identity, stamping it with a single now timestamp (so a record built once can be written to disk AND uploaded sharing the same timestamp / dedup key).
save_and_report
Build a RunRecord from report + the Persist target, write it as {slug(model)}_{timestamp_file}.json under persist.results_dir, then (re)generate report.html over every run in that directory. Returns the written JSON path.
save_record
Write record as pretty JSON to {results_dir}/{slug(model)}_{timestamp_file}.json, creating the directory if needed, and return the written path. Public so a host can persist a hand-built RunRecord without driving a full run through the runner.
slug
Sanitize a model label into a filesystem-safe slug for the results filename: keep [A-Za-z0-9._-], replace every other char with -, collapse runs of -, trim leading/trailing -, and fall back to "model" if nothing is left.
write_record_and_report
Write record into results_dir (via save_record) and (re)generate report.html over every run in that directory, returning the written JSON path. Public so a host can persist a pre-built RunRecord (e.g. one from build_record) without re-assembling it.