Skip to content

bwm_usage_notebook: work around brainglobe S3 403 on Colab#160

Merged
bendichter merged 1 commit into
masterfrom
fix-bwm-brainglobe-403
May 13, 2026
Merged

bwm_usage_notebook: work around brainglobe S3 403 on Colab#160
bendichter merged 1 commit into
masterfrom
fix-bwm-brainglobe-403

Conversation

@bendichter
Copy link
Copy Markdown
Member

The problem

brainglobe-atlasapi==2.3.1 fetches its atlas-version manifest from https://brainglobe.s3.us-west-2.amazonaws.com/atlas/atlases/last_versions.conf on every BrainGlobeAtlas() construction. Some Colab IPs get a 403 from that bucket, and the library doesn't gracefully fall back when the local cache is missing on a fresh runtime:

Could not fetch the latest atlas versions: 403
Using the last cached version from /root/.brainglobe/last_versions.conf
FileNotFoundError: Last versions cache file not found.

Same upstream issue: brainglobe/brainglobe-atlasapi#738 (closed January 2026 with a fix that didn't land in 2.3.1).

Fix

Pre-seed the manifest cache before BrainGlobeAtlas() is called. The new code at the top of the affected cell:

  1. Tries to fetch the manifest directly with stdlib urllib (bypasses brainglobe's pooch path that's getting 403'd from Colab).
  2. If that also fails, writes a minimal hardcoded [atlases]\n allen_mouse_25um = 3.0\n — enough for this notebook's one atlas.
  3. Writes to both ~/.brainglobe/last_versions.conf (the V1 path brainglobe-atlasapi 2.3.1 actually reads) and the V2 subpath, so future library upgrades keep working.

No notebook content downstream of the workaround changes — only an addition at the top of the existing BrainGlobeAtlas cell.

🤖 Generated with Claude Code

brainglobe-atlasapi 2.3.1 fetches its atlas-version manifest from
https://brainglobe.s3.us-west-2.amazonaws.com/... on every BrainGlobeAtlas()
construction. Some Colab IPs hit a 403 against that bucket, and the
library doesn't gracefully fall back when the local cache is missing
on a fresh runtime — it raises:

    Could not fetch the latest atlas versions: 403
    Using the last cached version from /root/.brainglobe/last_versions.conf
    FileNotFoundError: Last versions cache file not found.

Same upstream issue tracked at brainglobe/brainglobe-atlasapi#738.

Workaround: pre-seed the manifest cache before BrainGlobeAtlas is
called. First try fetching the manifest directly with stdlib urllib
(skips brainglobe's pooch path that's getting 403'd); if that also
fails, fall back to a minimal hardcoded `allen_mouse_25um = 3.0`
entry — enough for this notebook's one call. Writes the cache to both
`~/.brainglobe/last_versions.conf` (V1 path that brainglobe-atlasapi
2.3.1 actually reads) and the V2 subpath in case the library upgrades.

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
@bendichter bendichter merged commit 80fc8c9 into master May 13, 2026
5 checks passed
github-actions Bot added a commit that referenced this pull request May 13, 2026
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