feat(notebooks): optional Docker launcher for Python notebook series#79
Merged
Conversation
Adds a scoped Dockerfile + docker-compose.yml under examples/notebooks/python/ that build JupyterLab on Python 3.13 with getpatter (pinned via PATTER_VERSION) and the helper deps. _setup.py gains in_docker() and start_docker() so any notebook can spin the stack up from a single cell; the launcher is commented by default in all 12 Python notebooks, keeping host-Python Run All behaviour unchanged.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
- docker-compose: bind ports loopback-only (127.0.0.1) so Lab never reaches the LAN; pass JUPYTER_TOKEN through to the container. - Dockerfile: drop --allow-root, run as patter (UID 1000 by default, override via PUID/PGID), install pinned deps from requirements.txt. - _setup.start_docker: returns bool, captures and prints stderr on compose failure, refuses detach=False, generates a stable per-host JUPYTER_TOKEN (PATTER_NOTEBOOKS_NO_TOKEN=1 to opt out), accepts truthy variants for PATTER_NOTEBOOKS_IN_DOCKER. - New requirements.txt with pinned top-level deps. - New tests/test_docker_bootstrap.py — 19 unit tests covering env parsing, every start_docker early-return, argv assembly, token persistence. - _setup module docstring acknowledges the TS-side parity gap on the Docker helpers (tracking issue to follow).
5 tasks
Collaborator
Author
Review fixes pushed (
|
Collaborator
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Resolves the PEP 8 E402 warning IDEs surface on this file. Late imports (contextlib, time, traceback, typing.Iterable/Iterator, re) pre-dated PR \#79 — they came in with the original notebook skeleton — but the partial hoist of `webbrowser` made the inconsistency more visible. Moving them all to the top in one go keeps the file cleanly PEP 8-compliant. No behaviour change.
Three CI gates were red on PR #79: - Pre-commit / fix-end-of-files: trailing blank lines in docs/superpowers/plans/2026-04-24-patter-feature-test-notebook-implementation.md - Pre-commit / nbstripout: cell IDs, outputs, and \\u-escaped unicode not normalized across all 24 .ipynb files in examples/notebooks/. - notebooks/parity: Python notebooks gained `## Optional: run in Docker` in 5cad9f6 but TypeScript siblings did not, breaking the section-by- section parity contract enforced by scripts/check_notebook_parity.py. Fixes: - nbstripout 0.7.1 canonicalisation across all 24 notebooks (sequential string IDs, unicode normalisation, no outputs/execution_count). - EOF trim on the plans markdown. - Added matching `## Optional: run in Docker` markdown + commented-out TS launcher cell to all 12 TypeScript notebooks. The `_setup.ts` helpers (`inDocker`, `startDocker`) are still pending per issue #80; the cells are commented so behaviour is unchanged. New tool — scripts/pr-validate.sh — runs every PR-blocking CI check locally before opening a PR, mirroring .github/workflows/{test,notebooks}.yml. Modes: --quick (~30 s), default (~3-5 min), --full (~10 min). Selective skips: --skip-py, --skip-ts, --skip-notebooks. Documented escape hatches for memory-constrained / hardened-macOS local environments (PR_VALIDATE_SKIP_GITLEAKS, PR_VALIDATE_SKIP_NBSTRIPOUT) — CI runs the full pre-commit unaltered. Verified locally: pre-commit + parity + outputs-stripped all green.
nicolotognoni
added a commit
that referenced
this pull request
May 1, 2026
PR #79 added an optional Docker launcher under examples/notebooks/python/ and re-touched all 24 .ipynb files (kernel ID renumbering, source-array reshape). Resolution: - examples/notebooks/python/**.ipynb + examples/notebooks/typescript/**.ipynb: take the main version. Our only prior contribution to these files was the nbstripout pass, which is now re-applied via pre-commit (no behaviour or content of ours is lost). - docs/DEVLOG.md + docs/superpowers/plans/2026-04-24-...md: keep deletion. Both were removed from this branch as out-of-scope for the public docs site; no merge-back.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
examples/notebooks/python/Dockerfile+docker-compose.ymlbuild a Python 3.13-slim image withgetpatter(pinned viaPATTER_VERSION, default0.5.4), JupyterLab, and the helper deps frompyproject.toml. Compose mounts the parentexamples/notebooks/tree at/notebooksso_setup.pystill finds.envandfixtures/; ports 8888 (Lab) and 8765 (EmbeddedServer for T2/T4 cells) are published.env_fileis markedrequired: falseso §1 zero-key cells just work._setup.pygainsin_docker()(checksPATTER_NOTEBOOKS_IN_DOCKER=1and/.dockerenv) andstart_docker(*, build, detach, open_url)which shells out todocker compose up -d --buildfrom the notebooks dir; no-ops when already inside the container or when thedockerCLI is missing.Test plan
cd examples/notebooks/python && docker compose configparses without warningsdocker compose up --buildopens JupyterLab at http://localhost:8888/lab/tree/01_quickstart.ipynb01_quickstart.ipynbinside the container — §1 cells pass with zero keys_setup.start_docker()in cell 1 of any notebook → container starts, URL printed_setup.in_docker()returns True inside the container, False on hostnbstripoutstill strips outputs cleanly across all 12 notebooks