Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions 000409/IBL/bwm_usage_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2277,6 +2277,31 @@
}
],
"source": [
"# Workaround: brainglobe-atlasapi 2.3.1 fetches its atlas-version manifest\n",
"# from a Colab-unfriendly S3 endpoint that returns 403 for some Colab IPs.\n",
"# Pre-seed the cache so BrainGlobeAtlas() below can find a version manifest\n",
"# even when the live fetch fails. See https://github.com/brainglobe/brainglobe-atlasapi/issues/738\n",
"from pathlib import Path\n",
"import urllib.request\n",
"\n",
"_bg_dir = Path.home() / \".brainglobe\"\n",
"_manifest_url = (\n",
" \"https://brainglobe.s3.us-west-2.amazonaws.com/atlas/atlases/last_versions.conf\"\n",
")\n",
"try:\n",
" _manifest = urllib.request.urlopen(_manifest_url, timeout=20).read().decode()\n",
"except Exception as _e: # noqa: BLE001\n",
" print(f\"Couldn't reach brainglobe manifest ({_e}); writing a minimal fallback.\")\n",
" _manifest = \"[atlases]\\nallen_mouse_25um = 3.0\\n\"\n",
"\n",
"# Write to both the V1 and V2 cache paths so whichever brainglobe-atlasapi\n",
"# code path reads from disk finds the file.\n",
"for _p in (_bg_dir / \"last_versions.conf\",\n",
" _bg_dir / \"brainglobe-atlasapi\" / \"atlases\" / \"last_versions.conf\"):\n",
" _p.parent.mkdir(parents=True, exist_ok=True)\n",
" if not _p.exists():\n",
" _p.write_text(_manifest)\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from brainglobe_atlasapi import BrainGlobeAtlas\n",
Expand Down
Loading