Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a reusable notebook setup helper (notebook_setup.py) along with tests and documentation to bootstrap sample environments in Google Colab or local checkouts. The review feedback highlights several improvement opportunities: handling potential None values in sys.modules to prevent runtime crashes, safely handling cases where the repository root path is a file rather than a directory, removing the --upgrade flag from pip install to avoid breaking pre-installed Colab packages, and using a more robust parent-directory search in the README usage example.
Add a reusable, standard-library bootstrap utility in scripts/notebook-setup/ for tutorials and sample notebooks that depend on sibling Python modules when opened standalone in Google Colab or Colab Enterprise. - Sparse-clones only the target sample subdirectory into a managed cache folder, self-heals interrupted non-git directories, fetches and checks out FETCH_HEAD on persistent runtimes, installs requirements.txt, and reloads imported sibling sample modules. - Preserves existing local developer and CI repository checkouts without running git fetch or git checkout -f. - Includes unit tests in scripts/notebook-setup/tests/notebook_setup_test.py.
iennae
force-pushed
the
feat/notebook-setup-helper
branch
from
November 7, 2026 03:23
b896ebf to
848bc82
Compare
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
Adds a reusable standard-library bootstrap helper (
scripts/notebook-setup/notebook_setup.py) so tutorial notebooks acrosspython-docs-samplesdo not have to inline ~65 lines ofgit sparse-checkout,pip install, andimportlib.reloadplumbing at the top of each.ipynbfile.Key Behaviors
.ipynbruns: Creates or updates a managed sparse checkout (samples-<name>), self-heals partial non-git directories, fetches and checks out the latestFETCH_HEADfor the requested branch, installsrequirements.txt, and reloads any previously imported sibling modules.git fetchorgit checkout -f), switching into the sample directory and ensuringsys.pathis configured.scripts/notebook-setup/tests/notebook_setup_test.pywith target-safemock.patch.object(..., autospec=True).