bwm_usage_notebook: work around brainglobe S3 403 on Colab#160
Merged
Conversation
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>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Contributor
|
Preview for this PR has been removed (PR closed). |
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.
The problem
brainglobe-atlasapi==2.3.1fetches its atlas-version manifest fromhttps://brainglobe.s3.us-west-2.amazonaws.com/atlas/atlases/last_versions.confon everyBrainGlobeAtlas()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: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:urllib(bypasses brainglobe's pooch path that's getting 403'd from Colab).[atlases]\n allen_mouse_25um = 3.0\n— enough for this notebook's one atlas.~/.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
BrainGlobeAtlascell.🤖 Generated with Claude Code