Skip to content

Make the paper render hermetic; render-check it in CI#64

Merged
MaxGhenis merged 1 commit into
mainfrom
paper-hermetic-render
Jun 10, 2026
Merged

Make the paper render hermetic; render-check it in CI#64
MaxGhenis merged 1 commit into
mainfrom
paper-hermetic-render

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Why

The paper render depended on a user-level Jupyter kernelspec (policybench-paper) registered against one specific checkout's venv. Rendering from any other checkout silently executed the other checkout's policybench code, fresh machines couldn't render at all, and the env needed undeclared deps (nbformat/nbclient). All three bit us during the #62 render.

What

  • paper/index.qmd uses the standard python3 kernel; render_paper.py sets QUARTO_PYTHON (already did) plus JUPYTER_PREFER_ENV_PATH=1 — the load-bearing discovery: Quarto resolves the python3 kernel by name, and a user-level ~/Library/Jupyter/kernels/python3 can shadow the venv kernel and point at an unrelated checkout (it does on this machine — proven empirically with a probe render that imported the wrong policybench). The env var makes Jupyter search the venv's kernels first.
  • nbformat + nbclient declared in the docs extra (uv.lock diff: 6 lines, no version changes).
  • New paper.yml workflow renders the manuscript (HTML-only, no TeX) on PRs touching paper/**, policybench/**, or dependencies — failing on any notebook cell error. This catches the import-drift class of failure (e.g. a dep bump breaking policybench imports the paper executes). The job also runs generate_figures.py + installs librsvg2-bin, without which the embedded scatter PNG never gets generated and the render fails.
  • paper/README.md: render flow is now uv sync --extra docs + uv run python paper/render_paper.py; the kernelspec/JUPYTER_PATH workaround instructions are gone.

Committed rendered artifacts under app/public/paper/ are untouched — the header change has no effect on them, and CI renders go to gitignored paper/out/.

Verification

  • Worktree render with the exact CI env executes the worktree's own policybench (probe: policybench.config.__file__ resolves into the worktree), exit 0, all 19 cells clean.
  • uv run pytest -m "not slow" (279 passed), ruff clean, uv sync --locked consistent, actionlint clean on both workflows.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policybench-site Ready Ready Preview, Comment Jun 10, 2026 6:59pm

Request Review

The manuscript pinned `jupyter: policybench-paper`, a user-level kernelspec
whose argv points at one specific checkout's .venv. Rendering from any other
checkout silently executed that other checkout's policybench, fresh machines
could not render at all, and the render env relied on undeclared deps.

- paper/index.qmd: switch the Jupyter kernel from the named `policybench-paper`
  kernelspec to the standard `python3` kernel.
- paper/render_paper.py: pin the Jupyter engine to the invoking virtualenv.
  QUARTO_PYTHON selects the interpreter, but QUARTO_PYTHON alone is not enough
  because Quarto resolves the `python3` kernel by name and a user-level
  `python3` kernelspec can shadow the venv's own kernel. JUPYTER_PREFER_ENV_PATH=1
  makes Jupyter search the venv's share/jupyter first, so the kernel resolves to
  the invoking venv. Updated the install hint to `uv run python`.
- pyproject.toml / uv.lock: declare the full render env by adding nbformat and
  nbclient to the docs extra (previously only transitive). Lock diff is minimal;
  no unrelated upgrades.
- .github/workflows/paper.yml: new job, gated to paper/** and policybench/**
  changes, that installs the locked docs env + quarto + rsvg-convert, generates
  the embedded figure, and renders the manuscript to HTML only (no PDF/TeX). The
  render executes the venv's policybench and fails the job on any cell error.
  Rendered output goes to paper/out (gitignored); nothing rendered is committed.
- paper/README.md: document the hermetic render and the `uv sync --extra docs`
  + `uv run python paper/render_paper.py` workflow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@MaxGhenis MaxGhenis force-pushed the paper-hermetic-render branch from 16bb213 to 13afbf4 Compare June 10, 2026 18:58
@MaxGhenis MaxGhenis merged commit 9a553fa into main Jun 10, 2026
6 checks passed
@MaxGhenis MaxGhenis deleted the paper-hermetic-render branch June 10, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant