Notebook Policy for calibrated_explanations¶
Scope: Rules for notebooks under
notebooks/that are executed in CI viascripts/docs/run_notebooks.py. Cross-links to the release checklist and ADR-012 rather than redefining their ownership.Governing ADR:
docs/improvement/adrs/ADR-012-documentation-and-gallery-build-policy.md
1. Contribution rules¶
Every notebook contributed to notebooks/ MUST:
Run headlessly — no interactive widgets, no
%matplotlib inlinethat requires a display. Useimport matplotlib; matplotlib.use("Agg")or rely on the project’s headless CI configuration.Seed all randomness — call
numpy.random.seed(0)(or equivalent) near the top of the notebook so outputs are reproducible across runs.Use light datasets — data loading must complete in ≤ 5 s and the full notebook must finish within the CI ceiling (default: 300 s per notebook, 30 s per cell).
Be importable with
[notebooks,viz]extras only — notebooks MUST NOT depend on packages outside the[notebooks,viz]extra group. Core dependencies MUST NOT be expanded (ADR-010).
3. Runtime ceilings (ADR-012)¶
Parameter |
Default |
Override via CLI |
|---|---|---|
Per-cell timeout |
30 s |
|
Per-notebook wall-clock |
300 s |
|
When a ceiling is exceeded the notebook record receives status: "timed_out".
Raising either ceiling requires a PR rationale comment because it affects all
notebooks in scope.
4. Execution modes (ADR-012 branch-gate contract)¶
Context |
Mode |
CLI flag |
Enforcement |
|---|---|---|---|
mainline ( |
|
|
Nightly CI reports failures but never blocks. |
Before release |
|
|
Maintainer runs blocking mode before tagging; any |
The nightly CI job (notebook-exec-report in ci-nightly.yml) always runs in
advisory mode. Release gating is the responsibility of the release manager.
Before cutting a release, run the driver locally in blocking mode to catch failures early:
python scripts/docs/run_notebooks.py \
--mode blocking \
--output reports/docs/notebook_execution_report.json
Resolve all failed and timed_out entries before tagging the release.
5. Report schema¶
The driver writes reports/docs/notebook_execution_report.json. Each record
carries:
Field |
Type |
Description |
|---|---|---|
|
|
Relative path to the notebook. |
|
|
One of: |
|
|
Wall-clock seconds. |
|
|
List of |
|
|
UUID shared across all records in one run. |
|
|
Tag value used to skip, or |
|
|
|
Validate any custom tooling against the schema with:
from scripts.docs.run_notebooks import validate_report_schema
errs = validate_report_schema(report_dict)
assert errs == []
6. Cross-links¶
ADR-012 — governing policy:
docs/improvement/adrs/ADR-012-documentation-and-gallery-build-policy.mdADR-010 — optional-dependency boundary:
docs/improvement/adrs/ADR-010-optional-dependency-split.mdRelease checklist — resolve notebook failures before branching:
docs/improvement/RELEASE_PLAN_v1.mdCI nightly job —
notebook-exec-reportin.github/workflows/ci-nightly.yml