Reports¶
A gate run produces three renderings of the same findings, for three different readers.
| Reader | Call | |
|---|---|---|
| Summary | whoever is watching the pipeline | report.summary() |
| JSON | the system that files it | report.to_json(path) |
| HTML | the person who has to sign it | report.to_html(path) |
BLOCKED and PASS need no page — the pipeline acts on the exit code.
NEEDS_REVIEW is the verdict that delegates
to a human, and that human should not be handed a JSON blob.
One file, nothing fetched¶
from bdp_model_gate import ModelGate
report = ModelGate().run(context)
report.to_html("gate-report.html")
That is the whole API. ModelGate.run attaches the checks and the context to
the report, so the charts are drawn without you re-supplying anything.
The page has no <script>, no stylesheet, no font and no image fetched from
anywhere. A governance record gets emailed, filed, and reopened years later,
and every external reference is a way for it to stop rendering. It opens from
a file:// URL on a laptop with no network.
Charts are inlined as SVG, not <img src="data:...">. Inline SVG
participates in the page's CSS, which is what lets one render read correctly
in light and dark, and it stays sharp when printed.
Options¶
report.to_html(
path="gate-report.html",
title="Retail credit scorecard v4", # shown in the tab and the header
include_plots=True,
)
Pass checks= and context= explicitly when rendering a report you rebuilt
from somewhere else:
It degrades; it does not fail¶
Three ways the page can lose its charts, and none of them loses a finding:
- No
[plots]extra installed — text-only. - No checks or context (a report reconstructed from JSON) — text-only.
- A
plot()raised — that one chart is replaced in place by a note naming the exception. The findings around it are untouched.
That last one is deliberate. A chart is an aid; a renderer that throws must never cost a reviewer the results it was illustrating.
What is in the page¶
- The verdict, in plain words: "A blocking check failed. This model must not be promoted as it stands."
- The headline metric — whichever metric was configured, named, never assumed to be AUC.
- Categories in the order that matters: performance and compliance stop a deploy outright, security next, then fairness, which asks for a judgement.
- Every result, including
NOT_APPLICABLEones. What was skipped and why is part of the record — a report that silently omits them lets a reader assume coverage that never happened. - Each result's
metadatabehind an evidence toggle, so the numbers behind a sentence are one click away and not in the way. - The plot for each check that has one, beneath that check's findings.
What is deliberately not in the page¶
The check objects and the validation set are attached to the GateReport for
rendering, and excluded from the constructor, the repr, equality and
to_dict(). A report is an archival record of findings. Neither your data
nor your model belongs in one.
Printing and archiving¶
The page carries a print stylesheet: cards avoid breaking across pages and the
background drops out. Ctrl/Cmd-P → Save as PDF gives you the artefact to
attach to a change request.
API¶
bdp_model_gate.reporting
¶
A gate report as a page a reviewer can read and sign.
NEEDS_REVIEW is a verdict that delegates to a human. Until now that human
received a JSON blob: correct, archival, and close to unreadable at the moment
a decision has to be made. This renders the same report as one self-contained
HTML file — no network, no JavaScript, nothing to install to open it — with
each check's plot inlined beside the number it explains.
Three properties are deliberate:
- Self-contained. No
<script>, no external stylesheet, no remote font. A governance record is emailed, filed and reopened years later, and every external reference is a way for it to stop rendering. - Plots inlined as SVG, not
<img src="data:...">. Inline SVG inherits the page's CSS, which is what makes one render read correctly in light and dark. It also stays sharp when printed. - Degrades rather than fails. Without the
[plots]extra the page renders text-only. A plot that raises is reported in place as a note, because a broken chart must never cost a reviewer the findings around it.
CATEGORY_ORDER
module-attribute
¶
render_html
¶
render_html(
report,
checks=None,
context=None,
title="Model gate report",
include_plots=True,
generated_at=None,
)
Renders a GateReport as one self-contained HTML document.
checks and context are what plotting needs — a plot recomputes from
the data rather than reading presentation arrays out of the archived
JSON. ModelGate.run attaches both to the report it returns, so
report.to_html() normally supplies them for you; pass them explicitly
when rendering a report reconstructed from elsewhere.
Without them, or without the [plots] extra, the page renders text-only.
Source code in bdp_model_gate/reporting.py
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 | |