Skip to content

Sargolini2006: drop arbitrary numpy<2 cap, match Colab versions#157

Merged
bendichter merged 3 commits into
masterfrom
sargolini-numpy2-via-pynapple-bump
May 13, 2026
Merged

Sargolini2006: drop arbitrary numpy<2 cap, match Colab versions#157
bendichter merged 3 commits into
masterfrom
sargolini-numpy2-via-pynapple-bump

Conversation

@bendichter
Copy link
Copy Markdown
Member

The PR-141-era input deps for this notebook included numpy>=1.26,<2, which forced the resolver to pin numpy==1.26.4. Looking at the notebook content:

  • No removed-in-numpy-2.0 APIs (np.NaN, np.product, np.float_, etc).
  • The chosen pynapple==0.11.1 already supports numpy==2.0.2 (verified via uv pip compile).

The <2 cap was a precaution that's no longer needed. Dropping it lets this notebook match Colab's preinstalled numpy==2.0.2 — which means the install cell becomes a no-op for numpy and no kernel restart is required on Colab.

Direct-dep changes

- numpy>=1.26,<2  →  numpy>=1.26
- pynapple>=0.6   →  pynapple>=0.11   # bump floor; latest is 0.11.2

Resolved pins now match Colab exactly

Package Before After (this PR) Colab default
numpy 1.26.4 2.0.2 2.0.2 ✓
pandas 3.0.3 2.2.2 2.2.2 ✓
scipy 1.17.1 1.16.3 1.16.3 ✓
h5py 3.16.0 3.16.0 3.16.0 ✓
plotly 5.24.1 5.24.1 5.24.1 ✓
pynapple 0.11.1 0.11.2 (not preinstalled)

Why is .github/colab-preinstalled.txt new in this PR

I had originally added that constraints file in 7dd37f8 on the colab-bootstrap-locked branch, but it was pushed after #149 was merged, so it didn't reach master. Bringing it in here so the Sargolini re-resolution can use it. A separate, broader follow-up PR could re-apply the same regen to the other 41 notebooks that already have bootstraps — most would benefit from the same Colab-matching effect.

🤖 Generated with Claude Code

The PR-141-era input deps included `numpy>=1.26,<2` for this notebook,
which forced the resolver to pin numpy==1.26.4. That cap appears to
have been a precaution at the time — the notebook code itself is fully
numpy-2.x compatible (no removed APIs like np.NaN/np.product/etc),
and the chosen pynapple==0.11.1 already works against numpy 2.0.2.

Updated direct deps:
  - numpy>=1.26,<2  ->  numpy>=1.26
  - pynapple>=0.6   ->  pynapple>=0.11

Re-resolved against the Colab preinstalled-package constraint set
(.github/colab-preinstalled.txt, brought in from #149's
colab-bootstrap-locked branch which had it but didn't make it to
master in the merge).

Key resolved pins now match Colab exactly:

  numpy==2.0.2     <- matches Colab; no kernel restart on install
  pandas==2.2.2    <- matches Colab
  scipy==1.16.3    <- matches Colab
  h5py==3.16.0     <- matches Colab
  plotly==5.24.1   <- matches Colab
  pynapple==0.11.2 <- latest, supports numpy 2.x

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

Preview for this PR has been removed (PR closed).

github-actions Bot added a commit that referenced this pull request May 13, 2026
Previously the notebook called plotly's `fig.show()` without setting a
renderer. In Colab and Jupyter that auto-detects; in headless CI it
falls back to opening a browser tab and raises 'could not locate
runnable browser'. The notebook was on
`.github/notebook-test-exclusions.txt` for that reason.

Two changes:

1. New code cell (inserted right after the restart-admonition):

       import plotly.io as pio
       pio.renderers.default = "iframe"

   Renders figures inline as a self-contained iframe — works in Colab,
   Jupyter, and headless nbconvert/ipython runners.

2. Remove the Sargolini entry from `.github/notebook-test-exclusions.txt`.
   The notebook is now CI-testable.

Also cleans up an unrelated stray line in the install cell ('Resolved
103 packages in 569ms') that crept in from a 2>&1 stderr-redirect in
my prior regen — that string would have failed at `!uv pip install`
because it isn't a valid package spec.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bendichter
Copy link
Copy Markdown
Member Author

Pushed 4c1373e to also fix the headless-CI issue and pull this notebook out of the test-exclusions list.

What changed

  1. New code cell after the restart-admonition (cell index 4):

    import plotly.io as pio
    pio.renderers.default = "iframe"

    Plotly's default behavior is to auto-detect a renderer; in Colab it picks colab, in Jupyter it picks notebook_connected, but in a headless nbconvert/ipython-script run it falls back to opening a browser tab via webbrowser.open() — which raises "could not locate runnable browser" and was the reason this notebook was on notebook-test-exclusions.txt. iframe works in all three environments (the figure embeds as a self-contained HTML iframe).

  2. Removed from .github/notebook-test-exclusions.txt. The notebook is now CI-testable.

  3. Cleaned up a stray line in the install cell"Resolved 103 packages in 569ms" had crept in from a 2>&1 stderr-mixing bug in my earlier regen. That string would have failed at !uv pip install because it isn't a valid package spec.

Net effect

After this lands:

  • Notebook runs end-to-end on headless CI (no more browser-popup error).
  • Notebook runs end-to-end on Colab with no kernel restart (numpy==2.0.2, pandas==2.2.2, etc. all match Colab).
  • The per-PR CI workflow will exercise it on every PR that touches it (no longer skipped).

CI flagged 'CliVersionTooOldError: Client version 0.68.1 is too old!
Server requires at least version 0.74.0' on the first cell that
constructs DandiAPIClient().

The original input had `dandi>=0.56` (a stale floor from PR #141).
Bumping to `dandi>=0.74` triggered a constraint conflict against
Colab's `click==8.3.3` because dandi >=0.74 caps click at <8.2.
Resolved by dropping click from the constraint set for this notebook
— click downgrades from 8.3.3 to 8.1.8, a small CLI lib that doesn't
trigger a kernel restart on its own.

All other core-stack pins still match Colab exactly:

  dandi==0.75.1   (was 0.68.1; meets server min of 0.74.0)
  click==8.1.8    (was 8.3.3 in Colab; small downgrade)
  numpy==2.0.2    matches Colab
  pandas==2.2.2   matches Colab
  scipy==1.16.3   matches Colab
  h5py==3.16.0    matches Colab
  plotly==5.24.1  matches Colab
  pynapple==0.11.2 latest, supports numpy 2.x

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bendichter bendichter merged commit 73a2320 into master May 13, 2026
5 checks passed
github-actions Bot added a commit that referenced this pull request May 13, 2026
bendichter added a commit to catalystneuro/example-notebooks that referenced this pull request May 14, 2026
Applies the same Colab-version-matching approach that landed in PR dandi#157
(Sargolini2006) to the rest of the bootstrapped notebooks. Wherever a
notebook's direct deps allow, the lock now matches Colab's preinstalled
version exactly — so the install cell becomes a no-op for those
packages and no kernel restart is needed on Colab.

Adds .github/colab-preinstalled.txt (Colab's pip-freeze from
googlecolab/backend-info, refreshed 2026-05-13). Each notebook's lock
is then resolved with this file as a uv `--constraint`.

Two systematic adjustments applied during regen:

1. dandi floor bumped to >=0.74. The DANDI server now rejects clients
   older than 0.74 with CliVersionTooOldError. PR-141-era inputs had
   `dandi>=0.60` which let the resolver pick stale versions. The
   regen pipeline bumps the floor to 0.74 in every notebook's input.

2. click dropped from Colab constraints where needed. Colab ships
   click==8.3.3 but dandi >=0.74 caps click at <8.2. Resolution drops
   click for affected notebooks; it downgrades to 8.1.x. Click is a
   small CLI lib with no C extension or numpy dep, so the downgrade
   doesn't trigger a kernel restart.

Results across the 30 regenerated notebooks (Sargolini2006 already
covered by dandi#157, test-excluded notebooks skipped):

- Every notebook now pins dandi >=0.74 (or doesn't depend on dandi
  Python client at all — NWBWidget-demo uses requests directly).
- numpy unchanged at 2.0.2 (Colab default) on every notebook EXCEPT:
    * the dattalab reproduce_figure_* (numpy<2 for cellpose/np.NaN)
    * Turner motor-cortex (env.yml hard-pins numpy==2.2.6)
- pandas, scipy, h5py, plotly, matplotlib, etc. all match Colab
  wherever the notebook doesn't have specific older-version constraints.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant