Tracking and reports¶
Experiment tracking behind one protocol, and the HTML report.
ExperimentTracker
¶
Bases: Protocol
The tracking contract shared by every backend.
run
¶
run(experiment: str, run_name: str) -> ActiveRun
Open a new run under experiment and return a context-manager handle.
list_runs
¶
list_runs(experiment: str) -> list[RunRecord]
Return all runs for experiment, newest first.
get_run
¶
get_run(experiment: str, run_id: str) -> RunRecord | None
Return a single run by id, or None if absent.
ActiveRun
¶
ActiveRun(tracker: _Persistable, record: RunRecord)
A live run handle. Accumulates state and asks the tracker to persist.
Obtained from ExperimentTracker.run and used as a context manager so
the run is flushed (with a finished/failed status) on exit even when
the body raises.
log_reproducibility
¶
log_reproducibility(record: Any) -> None
Store the run's ReproducibilityRecord (or its dict).
It sits next to the params and metrics, so pmlab reproduce <run_id> can re-execute
the run from this file alone.
LocalJSONTracker
¶
LocalJSONTracker(root: str | Path)
RunRecord
dataclass
¶
RunRecord(
run_id: str,
experiment: str,
run_name: str,
params: dict[str, Any] = dict(),
metrics: dict[str, Any] = dict(),
gate: dict[str, Any] = dict(),
reproducibility: dict[str, Any] = dict(),
status: str = "running",
started_at: str = "",
ended_at: str | None = None,
error: str | None = None,
)
An immutable record of one tracked run.
reproducibility
class-attribute
instance-attribute
¶
reproducibility: dict[str, Any] = field(
default_factory=dict
)
generate_report
¶
generate_report(
trades: list[dict[str, Any]],
output_path: Path | str = Path("pmlab_report.html"),
title: str = "pmlab Paper Trading Report",
brier_score: float | None = None,
) -> Path
Render paper trades as one self-contained HTML report and write it to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trades
|
list[dict[str, Any]]
|
Trade records (dicts). A trade with a |
required |
output_path
|
Path | str
|
Where to write the file. |
Path('pmlab_report.html')
|
title
|
str
|
The report's heading. |
'pmlab Paper Trading Report'
|
brier_score
|
float | None
|
A Brier score to show alongside the summary, if you have one. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The path written. |
MLflowTracker
¶
MLflowTracker(tracking_uri: str | None = None)