Skip to content

feat: setup_colab registry for all 6 notebook repos, GPU/env fixes, tag-pinned clones#120

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/colab-maturity
Jul 9, 2026
Merged

feat: setup_colab registry for all 6 notebook repos, GPU/env fixes, tag-pinned clones#120
Jammy2211 merged 1 commit into
mainfrom
feature/colab-maturity

Conversation

@Jammy2211

@Jammy2211 Jammy2211 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Generalizes autoconf/setup_colab.py from two hand-duplicated helpers into a single _PROJECTS registry covering every Colab-enabled notebook repo (autofit/autogalaxy/autolens workspaces + HowToFit/HowToGalaxy/HowToLens), behind a public setup(project) entry point. PyAutoBuild's notebook generation (PyAutoLabs/PyAutoBuild#125) injects a setup cell calling setup_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 and for_autofit / for_howtofit / for_howtogalaxy / for_howtolens wrappers; for_autolens / for_autogalaxy keep their exact signatures and defaults. Behaviour fixes: importing the module no longer sets XLA_FLAGS (was clobbering user env on every import 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 in test_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)
  • First real Colab validation: open a regenerated notebook after the next release and run the setup cell
Full API Changes (for automation & release notes)

Added

  • setup_colab.setup(project: str, raise_error_if_not_gpu: bool = False) — bootstrap any of autofit|autogalaxy|autolens|howtofit|howtogalaxy|howtolens
  • setup_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_colab no longer mutates os.environ["XLA_FLAGS"]; the flag is set only inside the Colab setup path. Local users are unaffected: autoconf/__init__ imports jax_wrapper, which owns setting the flag — the removed module-level line was redundant.
  • check_jax_using_gpu accumulates accelerator status across all devices (was: last device enumerated wins) and returns True on an empty device list (was: UnboundLocalError).
  • The workspace clone is --depth 1 and 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 of main HEAD (version skew vs the pip-installed release).

Migration

  • None required — existing notebook calls setup_colab.for_autolens(...) / for_autogalaxy(...) work unchanged.

🤖 Generated with Claude Code

_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>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Jul 9, 2026
@Jammy2211 Jammy2211 merged commit ecbfef9 into main Jul 9, 2026
4 checks passed
@Jammy2211 Jammy2211 deleted the feature/colab-maturity branch July 9, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant