Skip to content

refactor: make Colab setup compact across projects #327

Closed

Description

@Jammy2211

Make Colab setup unobtrusive across projects

Type: refactor
Target: PyAutoHands
Difficulty: medium
Consequence: judge

Primary: @PyAutoHands. Consumers: @autolens_workspace, @autogalaxy_workspace,
@autofit_workspace, @HowToFit, @howtogalaxy, @HowToLens, @autolens_assistant.
Shared implementation: @PyAutoNerves (preserve runtime behavior).

Original request (verbatim)

  • This takes up too much space and brain capacity of a user, and should be a single line or the most brief possible
    thign which doesnt require them to think about whats actually going on. This should not be the first thing a user
    has to think about:

try:
import google.colab
except ImportError:
from autolens import setup_colab as _setup_colab
else:
import importlib
import subprocess
import sys

subprocess.check_call(
    [sys.executable, "-m", "pip", "install", "autonerves", "--no-deps"]
)
_setup_colab = importlib.import_module("autonerves.setup_colab")

_setup_colab.for_autolens(
raise_error_if_not_gpu=False # Switch to False for CPU Google Colab
)

Sort this across all projects, it function is important and works as expected but its confusing and a lot of code.

Approved plan

  • Present Colab setup as one short run cell labelled "Set up Google Colab", with implementation hidden by default.
  • Centralize bootstrap generation and shorten source-script setup to an import and call.
  • Apply the presentation consistently to existing handwritten setup and all six generated notebook project families.
  • Preserve installation, workspace/config setup, CPU/GPU choices and local execution; validate fresh-session and regeneration behavior.
  • Tier: judge — merge mode: human /prm.

Detailed implementation plan

  1. PyAutoHands autohands/build_util.py: revise inject_colab_setup, COLAB_SETUP_CODE and COLAB_SETUP_MARKDOWN. Use compact notebook presentation (Colab form title and hidden source metadata, Jupyter collapsed-source metadata where supported). Remove the long introductory explainer. Keep fresh-Colab bootstrap self-contained: importing the scientific library before installation is not sufficient.
  2. Recognize supported handwritten setup_colab cells and normalize them, preserving project and keyword options; avoid duplicate setup and retain surrounding science code. Do not blindly replace arbitrary cells containing the string. Make regeneration idempotent.
  3. Replace duplicated bootstrap blocks in Lens/Galaxy start_here.py and scripts/**/start_here.py with the established short import/call form; shorten adjacent setup prose. Inventory all project sources, including the assistant's docs/colab/cosmos_web_ring_colab.py. Generated markdown/notebooks follow their canonical generator, not manual parallel edits.
  4. Cover all COLAB_PROJECTS keys: autofit, autogalaxy, autolens, howtofit, howtogalaxy, howtolens. Inventory CTI/Reduce too; do not introduce Colab support where none exists. Preserve autonerves/setup_colab.py behavior and wrapper API; only change it if investigation establishes necessity within this scope.
  5. Extend PyAutoHands/tests/test_inject_colab_setup.py: generated and handwritten inputs, preserved options, repeated generation, mixed cells, prose-only notebooks, all projects. Exercise fresh Colab with package imports absent, local no-install behavior, CPU and GPU settings. Use existing Nerves tests and Heart Colab gate contract as behavior references; do not claim hosted Colab testing without running it.
  6. Generate representative artifacts for review, then ship generator changes before consumer changes through the required development workflows. No release or merge authorized.

Evidence and next action

Heart entry gate GREEN (2026-10-28). No matching active/planned Colab task found.
Memory consultation identified prior local-CLI silence and faithful fresh-Colab bootstrap validation; preserve both.
Branch proposal: feature/compact-colab-setup.
Next: user plan approval, branch/claim survey, create_issue registration, isolated worktree setup, implementation and validation.

Approved copy and scope clarification

User approved the plan and these two prose tiers, with the correction “locally or in HTML”.
Introductory: “Run this cell to install PyAutoLens and download the files needed for this notebook on Google Colab. If you’re running locally or in HTML, it leaves your installation unchanged.”
Advanced: “Set up Google Colab as in [the introductory notebook].”
Substitute each project’s name and actual introductory link. Cell title: “Set up Google Colab”. HTML support itself is future work, not part of this change.

Branch survey: PyAutoHands, autolens_workspace, autogalaxy_workspace, autofit_workspace, HowToFit, HowToGalaxy, HowToLens, autolens_assistant all on main, clean; no conflicting active claims. Proposed branch feature/compact-colab-setup.

Activity

  1. Jammy2211 commented on Oct 28, 2026

    @Jammy2211
    CollaboratorAuthor

    Development-only Heart RED override for compact-colab-setup (#327)

    User authorization: “I authorize you to continue despite RED”.

    Exact current reasons:

    • PyAutoArray: 4 uncommitted source change(s)
    • PyAutoGalaxy: 9 commit(s) behind origin
    • PyAutoLens: 7 commit(s) behind origin
    • release validation stale: source moved since rehearsal (PyAutoGalaxy, PyAutoLens)

    Prior validation: 581 PyAutoHands tests passed; six notebook-family previews generated; 15 changed source scripts preserve science AST; real local Lens/Galaxy setup calls pass. Final rollout tests and review are in progress and must pass before shipping.

    Authorizes continued implementation, commit, push and opening this task’s PRs. No merge, release, failed-test override or CI bypass.

  2. Jammy2211 commented on Oct 28, 2026

    @Jammy2211
    CollaboratorAuthor

    Library PR Created

    Shared generator: #328 (77bbc1e), 584 tests passed. Independent Markdown-preservation finding resolved and rechecked.

    Workspace migration is underway: PyAutoLabs/autofit_workspace#178 (79a996a), 32 regenerated notebooks; 8 scripts and 2 notebook smokes passed. All six families regenerated (633 notebooks, 632 compact setup cells); science code and idempotency checked. Remaining consumer smoke suites and assistant pinned-runtime validation are in progress.

    The task-specific RED development override is recorded above. No merge or release requested.

  3. Jammy2211 commented on Oct 28, 2026

    @Jammy2211
    CollaboratorAuthor

    Implemented the compact Colab setup rollout. Introductory notebooks use the approved two-sentence explanation (including “locally or in HTML”); advanced examples link back. Installation behavior and CPU/GPU options are preserved. HTML support itself remains future work.

    Pull requests

    Merge PyAutoHands first, then consumers; the Galaxy assistant guide also follows the Galaxy workspace. No merges or releases performed.

    Validation

    • Shared generator: 584 tests pass, including 28 focused setup tests; tenant-firewall check passes after moving project metadata into configuration.
    • All six families regenerated: 633 notebooks, 632 compact setup cells and one prose-only notebook. Scientific cell sources unchanged; setup normalization idempotent. Assistant adds one generated compact notebook with existing execution outputs preserved.
    • Workspace smoke: Lens 42 scripts + 2 notebooks; Galaxy 14 + 2; Fit 8 + 2; HowToFit 19 scripts; HowToGalaxy 32; HowToLens 50 — all pass.
    • Lens assistant: 11 focused tests pass; isolated pinned-runtime benchmark module 12 pass. Full suite: 263 pass, 1 skip, 1 xfail, with one interpreter-path assertion subsequently passing in the canonical-path preflight rerun (4 pass).
    • Galaxy assistant: Colab context mapping/cap check and documentation diff review pass.
    • Independent generator review finding fixed and rechecked CLEAN. Fresh-Colab behavior tested with simulation; hosted Colab installation/UI not exercised.

    Heart development override

    User: “I authorize you to continue despite RED”. Exact reasons retained:

    • PyAutoArray: 4 uncommitted source change(s)
    • PyAutoGalaxy: 9 commit(s) behind origin
    • PyAutoLens: 7 commit(s) behind origin
    • release validation stale: source moved since rehearsal (PyAutoGalaxy, PyAutoLens)

    This authorizes development shipping only; no readiness promotion, merge, release or CI bypass. The initial Hands CI failure was the tenant firewall; fixed in a405d14, local full suite and firewall pass. Fresh CI remains subject to review before merge.

  4. Jammy2211 commented on Oct 28, 2026

    @Jammy2211
    CollaboratorAuthor

    Partial merge — human /prm

    Every run/job for each current head was checked. Five fully green PRs merged in dependency order. Four remain open because their smoke / smoke job was skipped by the shared workflow change filter for generated-notebook-only changes; skipped is not a passing test result. Their local smoke suites passed during development. No failed jobs. Issue and Mind task remain open; worktree and claims retained. No release.

  5. Jammy2211 commented on Oct 29, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped — Colab setup rollout merged

    All nine rollout PRs are confirmed merged. The final four merged on 2026-10-29:

    • autofit_workspace#178 — 572d22e5cb8aafea2f4dea7e16cf848ddbcbb42f
    • HowToFit#77 — 2ba2d84de779c591d4c37f709bc5c226dd119051
    • HowToGalaxy#92 — b44cd924f4057dcf1652c5ba5b1c653b5aabeb92
    • HowToLens#102 — bc94def0a9d211041253111c6644f6a271de2a42

    Previously merged and re-confirmed: PyAutoHands#328, autogalaxy_workspace#265, autolens_workspace#604, autolens_assistant#167, autogalaxy_assistant#41.

    Human authorization in this session: “ok merge them and finish this task”, followed by “yes I do” when explicitly asked to accept the recorded local smoke results as an exception for these four generated-notebook-only PRs. This exception applies only to their skipped smoke / smoke jobs. All other enumerated workflow jobs succeeded; all four heads were unchanged, mergeable/clean, and had no review requests for changes or unresolved review threads. Merged with exact-head guards, without bypassing GitHub protection. Skipped smoke jobs are not reported as passing. Hosted Colab remains untested; no release performed.

    Repository rollout is complete. Local administrative close-out remains outstanding: Mind lifecycle completion record/active-row release, dashboard regeneration, and worktree cleanup. The local command hook rejects even pwd because /home/jammy/Code/PyAutoLabs/.codex/hooks/validate_pyauto_code.py is missing. No hook bypass attempted, and no local cleanup claimed. Resume the standard prm close-out for compact-colab-setup once local command access is repaired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions