feat: setup_colab registry for all 6 notebook repos, GPU/env fixes, tag-pinned clones#120
Merged
Conversation
_PROJECTS registry covers all six notebook repos (autofit/autogalaxy/ autolens workspaces + HowToFit/HowToGalaxy/HowToLens) behind a public setup(project) entry point; for_autolens/for_autogalaxy wrappers keep their signatures and for_autofit/for_howto* are added. Fixes: GPU detection now accumulates across devices and handles an empty device list (was last-device-wins + UnboundLocalError); XLA_FLAGS is no longer mutated at import time (jax_wrapper remains the canonical local channel; the flag is set only inside the Colab setup path); the workspace clone is --depth 1 and pinned to the tag matching the installed release, with default-branch fallback. Adds the module's first unit tests. Part of PyAutoLabs/PyAutoBuild#124 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Generalizes
autoconf/setup_colab.pyfrom two hand-duplicated helpers into a single_PROJECTSregistry covering every Colab-enabled notebook repo (autofit/autogalaxy/autolens workspaces + HowToFit/HowToGalaxy/HowToLens), behind a publicsetup(project)entry point. PyAutoBuild's notebook generation (PyAutoLabs/PyAutoBuild#125) injects a setup cell callingsetup_colab.setup("<project>")into every generated notebook, so this module becomes the single runtime bootstrap for all ~489 published notebooks.Part of PyAutoLabs/PyAutoBuild#124 (Colab maturity, phase 1).
Release coupling: merge together with the PyAutoBuild injection PR — injected notebook cells call
setup_colab.setup(), which reaches users via the next autoconf release (notebooks are only regenerated at release time, so ordering is safe by construction).API Changes
Added a public
setup(project, raise_error_if_not_gpu=False)entry point andfor_autofit/for_howtofit/for_howtogalaxy/for_howtolenswrappers;for_autolens/for_autogalaxykeep their exact signatures and defaults. Behaviour fixes: importing the module no longer setsXLA_FLAGS(was clobbering user env on everyimport autoconf); GPU detection considers all devices and tolerates an empty device list; the workspace clone is shallow and pinned to the installed release's tag (default branch fallback).See full details below.
Test Plan
python -m pytest test_autoconf/— 132 passed (15 new intest_setup_colab.py: registry shape, wrapper delegation, clone tag/fallback logic with mocked subprocess, GPU-detection regressions on stub devices, no-import-side-effects guard, outside-Colab no-op)Full API Changes (for automation & release notes)
Added
setup_colab.setup(project: str, raise_error_if_not_gpu: bool = False)— bootstrap any ofautofit|autogalaxy|autolens|howtofit|howtogalaxy|howtolenssetup_colab.for_autofit(raise_error_if_not_gpu=False)setup_colab.for_howtofit(raise_error_if_not_gpu=False)setup_colab.for_howtogalaxy(raise_error_if_not_gpu=False)setup_colab.for_howtolens(raise_error_if_not_gpu=False)Changed Behaviour
import autoconf.setup_colabno longer mutatesos.environ["XLA_FLAGS"]; the flag is set only inside the Colab setup path. Local users are unaffected:autoconf/__init__importsjax_wrapper, which owns setting the flag — the removed module-level line was redundant.check_jax_using_gpuaccumulates accelerator status across all devices (was: last device enumerated wins) and returns True on an empty device list (was:UnboundLocalError).--depth 1and pinned to the git tag matching the installed release of the project's top package (importlib.metadata.version), falling back to the default branch when the tag is missing (e.g. dev installs). Previously: full-depth clone ofmainHEAD (version skew vs the pip-installed release).Migration
setup_colab.for_autolens(...)/for_autogalaxy(...)work unchanged.🤖 Generated with Claude Code