feat: inject Colab setup cell into every generated notebook#125
Merged
Conversation
build_util.inject_colab_setup(notebook, project) prepends a markdown
explainer + code cell calling setup_colab.setup("<project>") after the
notebook's title cell; notebooks whose script hand-writes a setup_colab
call are left untouched, and an unknown project fails generation loudly
(COLAB_PROJECTS must track the PyAutoConf registry). Wired into both
generate.py conversion sites and generate_autofit.py, so every notebook
published at the next release is Colab-runnable by construction
(previously 9 of 489 had a setup cell).
docs/internals.md gains a "Google Colab architecture" section covering
the four pieces (bootstrap, injection, URL bumper, Heart sweep); the
bump_colab_urls entry now lists HowToFit.
Part of #124
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Census (#124) found only 9 of 489 published notebooks carry a Colab setup cell, while docs/READMEs link 100+ notebooks to Colab — every other notebook dies on
ModuleNotFoundError. This makes coverage structural:build_util.inject_colab_setup(notebook, project)prepends the standard setup cell pair (markdown explainer +setup_colab.setup("<project>")code cell) after the title cell of every notebook generated bygenerate.py/generate_autofit.py. Hand-written setups are detected and skipped; an unknown project fails generation loudly. At the next release, all notebooks regenerate Colab-ready with zero per-script maintenance.Also documents the end-to-end Colab architecture (bootstrap → injection → URL bumper → Heart sweep) in
docs/internals.md.Part of #124 (Colab maturity, phase 1).
Release coupling: merge together with the PyAutoConf registry PR (same branch name there) — the injected cell calls
setup_colab.setup(), which ships in the next autoconf release; notebooks only regenerate at release time, so ordering is safe by construction.API Changes
None — internal changes only (notebook generation pipeline; no published package API).
Test Plan
python3 -m pytest tests/— 78 passed (7 new intest_inject_colab_setup.py: placement after title cell, top placement without title, skip on hand-written setup, idempotency, all six projects, unknown-project error, valid nbformat JSON)py_to_notebook+ injection onHowToLens/.../tutorial_1_grids_and_galaxies.py(cells placed correctly) and skip verified onautolens_workspace/.../imaging/start_here.py(hand-written setup preserved)generate_notebooksjobs🤖 Generated with Claude Code