Repository navigation
Conversation
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.
848bc82 to
a83b8c0
Compare
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.
a83b8c0 to
b56d1c3
Compare
XrossFox
left a comment
There was a problem hiding this comment.
Code LGTM, but pytest version in requirementes should be upgraded, or dependabot will eventually raise a security alert.
| @@ -0,0 +1 @@ | |||
| pytest>=8.0.0 | |||
There was a problem hiding this comment.
This pytest version will be flagged as a security alert by dependabot, please update to version 9.0.3 or newer.
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).