Repository navigation
PP-8d: Colab and LabConstrictor readiness of the notebook - #118
Merged
Merged
Conversation
… portability guide - Code cells start with "# @title" (all hidden: an app-like widget notebook). - Step 0: Google Drive mounted and Colab's custom widget manager enabled inside `if "google.colab" in sys.modules:`; locally an environment report. The GitHub install is pinned to RELEASE_TAG v0.4.0rc2; current_version/notebook_name match notebooks/notebook_latest_versions.yaml. ipywidgets 7 is upgraded, or a restart asked for when it is already loaded. - Colab / JupyterLab callouts at Steps 0 and 1; a stale-lock entry in Common problems; the removed TIFF conversion card is no longer described. - Browse... without a dialog (Colab) says how to copy a path (notebook_style no_dialog_status). - tests/test_notebook_file.py: the portability rules, the pin, and the notebook run in a real kernel (nbclient, ipykernel in the dev extra). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
… plan question 52 - README: "Notebook: Google Colab and JupyterLab" (the portability rules, the release pin and how it moves at a release). - User guide §1 "Google Colab": Drive, output folder, copying a large dataset to the runtime's disk (same path every session), and the limits of Google Drive (lock only within one runtime, a stale lock after a disconnect, files read again). - Plan: question 52 (supersedes "Local Jupyter (not Colab-first)"), the v0.4.0 (PP-13) release checklist with the notebook pin, milestone 5 note. - AGENTS.md and development.md: the notebook rules and tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
guijacquemet
marked this pull request as ready for review
November 2, 2026 08:05
Conflict in docs/plan.md §12: main's PP-8c questions 52-57 kept; this PR's question renumbered 58, with every reference (AGENTS.md, plan §10, development.md, tests/test_notebook_file.py). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
…of order - Owner decision (2 November 2026): on Colab, Step 0 installs the notebook and zarr extras, so OME-Zarr images can be read there; zarr is then a requirement Step 0 checks, so an installed package without it gets the extra. Locally unchanged (notebook extra). Tests: release from GitHub with [notebook,zarr] on Colab, zarr added to an installed package on Colab, zarr neither required nor installed locally. - Colab callouts: data and output stay on Drive at the same place (no advice to copy to the runtime's disk), and one session per output folder, because the lock cannot guard it across sessions on Drive. - The setup tests failed (15 of 17) when run on their own: Step 0 calls platform.platform(), which runs uname through subprocess the first time, and the fixture fakes subprocess.run for pip. The fixture now fills platform's cache before faking pip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
User guide, README, AGENTS: the lock on Google Drive is documented only (one session per output folder; it cannot guard across machines or sessions); no advice to copy datasets to the runtime's disk (reuse depends on the absolute path); Colab installs the zarr extra (the manual pip line is gone). Plan: Q58 records the decisions; §10 gains the PP-10 note for a remove-the-lock button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
Contributor
Author
Independent review: merged (merge commit 44971bc)Review fixes
Verified
Gate (own worktree and venv,
§9 figures
Branch: it was auto-deleted on merge and restored at 40376f5. Not verified: a real Colab run. That is the hand-check list in the PR description, for the owner before tagging v0.4.0rc2. Follow-up (not blocking): spec §9 calls Generated by Claude Code |
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.
PP-8d makes
notebooks/MorphoBricks_Preprocessing.ipynbrun on Google Colab against a full dataset on Google Drive, following LabConstrictor's notebook portability guide, code-hiding guide and the version-check convention of its notebook upload guide. The reference was fiberfeatures' notebooks andtests/test_notebooks.py(at 362f1ba). Based on main 501c2dc, then main d35db1e (PP-8b, roadmap) and, in review, main a4e30a7 (PP-8c, #117) merged in. No rebase. Version stays 0.3.4.Summary
Notebook (
notebooks/MorphoBricks_Preprocessing.ipynb)# @title Run to …. They were# @markdown ### …before. All code cells stay hidden (see the decisions below).if "google.colab" in sys.modules::drive.mount("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/content/drive")and prints a message first;output.enable_custom_widget_manager().subprocesswith the kernel's Python.RELEASE_TAG = "v0.4.0rc2", one constant, throughgit+{REPOSITORY}@{RELEASE_TAG}. It wasmainbefore.notebook_name current_version.current_version = "0.4.0rc2"(was 0.0.1) andnotebook_name = "MorphoBricks_Preprocessing".notebookandzarrextras (review, owner decision); locallynotebook, unchanged. On Colabzarris a checked requirement, so an installed package without it gets the extra.output_lockedafter a disconnect, with theremove_stale_lockcell.New:
notebooks/notebook_latest_versions.yaml. The index LabConstrictor's version check reads, keyed bynotebook_name, as in fiberfeatures.notebook_style.no_dialog_status(dialog, target)(new, ui layer)notebook_ui._browseand_browse_csvuse it. notebook_ui.py changes only in those two calls, and lost 8 lines.Tests
tests/test_notebook_file.py. The notebook-file tests moved there fromtest_notebook_ui.py. New tests:# @titleand hidden with the standard metadata;get_ipython;google.colabimports and/contentappear only inside the single top-level Colab guard, checked by AST line spans;RELEASE_TAGmatchesv\d+.\d+.\d+(rcN)?and is the onlygit+install;current_versionequals the tag without "v", the yaml index and the tag named in the Step 0 callout;notebook_nameequals the file name;notebooks/): no error outputs, the local environment report, every code cell shows a widget. It skips with a reason when nbclient or ipykernel is missing. Both are added to thedevextra, so CI runs it.tests/test_notebook_setup.py:google.colab);tests/test_notebook_ui.py: the Colab hint in both Browse fallbacks, and a quoted Colab "Copy path" path forclean_path.Docs
Decisions
current_versionis the release tag without "v". This gives one bump per release, and the test ties the two together. The pin moves in the release PR before the tag is pushed, so a tagged notebook installs its own tag. Until v0.4.0rc2 exists, a fresh Colab install from this notebook fails at pip: this is expected, and the owner tags rc2 after PP-8c and this PR.Tk()raisesTclErrorand the fallback message appears. The path boxes take any kernel path.clean_pathkeeps/content/drive/MyDrive/…unchanged, which is tested.Notes for review: Google Drive (code read, run semantics unchanged)
run/lock.py,O_CREAT|O_EXCL). It is exclusive within one runtime's FUSE mount. Drive syncs files between machines with a delay, so a second Colab session, or a PC syncing the same Drive folder, can take the "same" lock at the same time. Owner: documented only. The user guide, README and notebook say plainly that on Drive the lock cannot guard an output folder across machines or sessions, so use one session per output folder.output_locked. The notebook has no button for it, so the guide and "Common problems" give aremove_stale_lock(...)cell (a button comes in PP-10). A new runtime has another host name, soremove_stale_lockremoves it once asked.st_mtime_ns). Drive reports times at about 1 ms resolution. If Drive reports a different time later, for example after a resync, the image is read again: that is safe. Reuse after a size-and-time-preserving overwrite is the general risk, not specific to Drive.RowKeycontains the absolute read path. Reading the images from another place recomputes every row, so the docs no longer suggest copying to the runtime's disk (owner): data and output stay on Drive.os.replaceof a temporary file, staged publishing with backups). They should work on Drive FUSE, but I could not test this. It is on the hand-check list.I could not run Google Colab. Everything above was verified only by reading the code and by local tests: the notebook was executed in a local kernel and with a faked
google.colab.Colab hand check (owner, before tagging v0.4.0rc2)
morphobricks-preprocessing[notebook,zarr].enable_custom_widget_manager()and report it.plane_histograms.csv,run_manifest.json,experiment_design.csvand the report..run-*/.tmpfiles.output_lockedand that theremove_stale_lockcell from "Common problems" clears it.Owner decisions (2 November 2026, applied in review)
[notebook,zarr]on Colab (locally unchanged). The manual pip line is gone. Tests and docs are updated.RELEASE_TAG = "v0.4.0rc2": the owner publishes v0.4.0rc2 after both PRs merge.Review fixes
tests/test_notebook_setup.pyfailed 15 of 17 when run on its own, because Step 0'splatform.platform()runsunamethrough the fakedsubprocess.run. It passed only after another test had filled platform's cache. The fixture now fills the cache first.Tests
.[dev,notebook,zarr], Python 3.11:ruff checkandruff format --check: clean;tools/check.py --rules: exit 0.pytestwith.[dev,notebook,zarr](+ nbclient, ipykernel), Python 3.11: 1532 passed, 1 skipped.test_discovery.py:665("running with permissions that ignore file modes": the sandbox runs as root). The kernel execution test ran and did not skip.§9 figures (measured)
notebook_style.no_dialog_status: complexity 1, 2 parameters, 1 statement (11 lines with the call), fully annotated, NumPy docstring.notebook_style.py: 386 → 417 lines (≤ 600), layerui.notebook_ui.py: 3051 → 3043 lines. The baseline shrank, and the_browse_csventry (11 lines without a docstring) left it.tests/test_notebook_ui.py: 1604 → 1540 lines, baseline shrunk.tests/test_notebook_file.py: 199 lines.tests/test_notebook_setup.py: 215 → 317 lines after review.# noqatotal 88 on main and on head; no new exemptions.🤖 Generated with Claude Code
https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc