Repository navigation
Description
Overview
Workspace/library version mismatches today only surface when users run welcome.py — which most users execute once and then never again. Every other script imports the library and loads config, but never calls check_version, so a stale-workspace-vs-fresh-library mismatch goes undetected and produces confusing API errors. This task moves the check into every library's __init__.py, embeds the canonical version inside config/general.yaml so it travels with the user's config directory (even when scripts are copy-pasted into their own drive), and adds a YAML override flag so users on main-branch clones — where mismatches are expected — can opt out without an env var.
Plan
- Move the workspace-version check from
welcome.pyinto every library's__init__.pyso every script run from a workspace triggers it on import. - Embed the workspace version inside
config/general.yamlunder the existingversion:key, so the version travels with the user's config directory.version.txtstays as the build-time canonical source. - Add a
workspace_version_check: True/Falseflag toversion:ingeneral.yaml, mirroring the existingpython_version_checkpattern, so users can disable the check without setting an env var. - Rewrite the mismatch error to explicitly mention: (a) the YAML override, (b) that users on
mainbranch clones should disable it sincemainupdates faster than releases, and (c) the existingPYAUTO_SKIP_WORKSPACE_VERSION_CHECKenv-var escape hatch. - Update the release pipeline to write the version into
config/general.yamlon every release (in addition toversion.txt), and updateverify_workspace_versions.shto check both sources. - Backfill
workspace_version: 2026.4.13.6andworkspace_version_check: Trueinto all 7 workspaces'general.yaml.
Detailed implementation plan
Affected Repositories
- PyAutoConf (primary — core check logic + tests)
- PyAutoFit (call check from
__init__.py) - PyAutoGalaxy (call check from
__init__.py) - PyAutoLens (call check from
__init__.py) - PyAutoBuild (release pipeline + verify script)
- autofit_workspace, autogalaxy_workspace, autolens_workspace (config + welcome.py)
- HowToFit, HowToGalaxy, HowToLens (config + welcome.py for HowToLens)
- euclid_strong_lens_modeling_pipeline (config)
Work Classification
Both — library work first, workspace follows after the library PRs are merged so the libraries can be re-installed and the new YAML keys exercised.
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| PyAutoConf | main | clean |
| PyAutoFit | main | 1 file (unrelated) |
| PyAutoGalaxy | main | 1 file (unrelated) |
| PyAutoLens | main | 1 file (unrelated) |
| PyAutoBuild | main | clean |
| autofit_workspace | main | clean |
| autogalaxy_workspace | main | 2 files (unrelated) |
| autolens_workspace | main | 13 files (unrelated) |
| HowToFit | main | 2 files (unrelated) |
| HowToGalaxy | main | clean |
| HowToLens | main | 2 files (unrelated) |
| euclid_strong_lens_modeling_pipeline | main | clean |
Suggested branch: feature/workspace-version-config-check
Worktree root: ~/Code/PyAutoLabs-wt/workspace-version-config-check/ (created by /start_library)
Implementation Steps
1. PyAutoConf — extend autoconf/workspace.py::check_version()
-
Source-of-truth precedence: read
<workspace_root>/config/general.yamlfirst; ifversion.workspace_versionis set, use it. Fall back to<workspace_root>/version.txt. Skip with warning if neither is found. -
Bypass precedence:
PYAUTO_SKIP_WORKSPACE_VERSION_CHECK=1env var (existing) orversion.workspace_version_check: Falseingeneral.yaml(new) → return early. -
New mismatch error message:
Workspace version (X.Y.Z) at /path does not match the installed library version (A.B.C). This usually means your installed library was upgraded but your workspace clone is from an older release tag. Re-clone the workspace at the matching tag: git clone --branch A.B.C <workspace-repo-url> To bypass this check, edit `config/general.yaml`: version: workspace_version_check: False IMPORTANT: If you cloned the workspace from `main` rather than a release tag, you should set `workspace_version_check: False`. The `main` branch updates much more frequently than library releases, so version mismatches are expected and not actionable for `main`-branch users. You can also set the environment variable PYAUTO_SKIP_WORKSPACE_VERSION_CHECK=1 to disable temporarily. -
Same friendly text for the missing-config / missing-version-file warning — point at the YAML override and explain the
mainbranch case.
2. PyAutoConf — extend test_autoconf/test_workspace.py
New tests for: YAML version source, YAML bypass flag, YAML override beats env, both sources missing → warning, only version.txt present (legacy fallback), YAML and version.txt disagree (YAML wins).
3. PyAutoFit, PyAutoGalaxy, PyAutoLens — call check on import
In each library's __init__.py, after __version__ is defined:
from autoconf import check_version
check_version(__version__)PyAutoArray is NOT modified — no autoarray-only workspace exists; the check fires through autofit/autogalaxy/autolens.
4. Workspace config/general.yaml updates (7 repos)
Add to existing version: block in each of:
- autofit_workspace, autogalaxy_workspace, autolens_workspace
- HowToFit, HowToGalaxy, HowToLens
- euclid_strong_lens_modeling_pipeline
version:
python_version_check: True
workspace_version: 2026.4.13.6 # NEW — must match the installed library version
workspace_version_check: True # NEW — set to False on main-branch clones5. welcome.py cleanup
Remove the now-redundant check_version(...) call from each welcome.py (autofit/autogalaxy/autolens workspaces + HowToLens).
6. PyAutoBuild release pipeline updates
release.yml: extend theWrite workspace version.txtstep to also patchconfig/general.yaml'sversion.workspace_version(Python shim — sed-based YAML edits are too fragile).verify_workspace_versions.sh: preferconfig/general.yaml'sworkspace_versionwhen present, fall back toversion.txt. If both exist and disagree, fail.- Update
PyAutoBuild/CLAUDE.mdto describe the new precedence.
Key Files
PyAutoConf/autoconf/workspace.py— core check logicPyAutoConf/test_autoconf/test_workspace.py— new testsPyAutoFit/autofit/__init__.py— add 2 lines at endPyAutoGalaxy/autogalaxy/__init__.py— add 2 lines at endPyAutoLens/autolens/__init__.py— add 2 lines at end<7 workspaces>/config/general.yaml— add twoversion:keys<4 workspaces>/welcome.py— remove duplicate checkPyAutoBuild/.github/workflows/release.yml— pipeline patch general.yamlPyAutoBuild/verify_workspace_versions.sh— read from config firstPyAutoBuild/CLAUDE.md— document precedence
Testing approach
- PyAutoConf: pytest covers all branches of
check_version. - Libraries: import each in a workspace dir → no error;
cd /tmp && python -c "import autolens"→ warning (no config). Setworkspace_version_check: False→ silenced. Mutategeneral.yamlto a bogus version → raises with friendly message. - Workspaces:
python welcome.pyand a representative script (scripts/imaging/modeling/start_here.py) both work withPYAUTO_TEST_MODE=1. - PyAutoBuild: dry-run
verify_workspace_versions.shagainst current state — must still pass.
Original Prompt
Click to expand starting prompt
A common problem is users pair a workspace with a different version to their installed software, leaidng to API
inconsistencies and config mismatches.
What do you think we can do about this? One option would be if they are running inside a workspace, it has its
version stored somewhere which is compared to their source code on import. However, you could still end up
with users doing work outside their workspace and copy and pasting old code and API and whatnot. This version number
could be put in configs to be a bit more secure (e.g. even in their own drive they probably need a config)
but not clear cut.
Activity
Jammy2211 commentedon Apr 30, 2026
Library PRs Created — 2026-04-30
PRs
Status
Workspace changes needed. Next:
/start_workspace.API Changes
autoconf.workspace.check_versionis unchanged in signature but its resolution and bypass behaviour are extended:config/general.yaml→version.txt→ warn.version.workspace_version_check: Falseingeneral.yaml(intended formain-branch clones where mismatches are expected).main-branch case.import autofit/autogalaxy/autolensnow triggers the check on import, not just fromwelcome.py.Workspace Impact
welcome.pyfiles contain a now-redundantcheck_version(...)call to remove.version.workspace_version+version.workspace_version_check: Trueadded toconfig/general.yamlso the config-aware path becomes the active source of truth (legacyversion.txtfallback continues to work in the meantime).Jammy2211 commentedon Apr 30, 2026
Smoke Test Results — 2026-04-30
All 7 smoke tests passed across autolens_workspace.
This run served as the canonical gate for the config-only change across all 7 workspaces (workspace_version embed + welcome.py duplicate check removal). No script logic was touched.
Jammy2211 commentedon Apr 30, 2026
Shipped — 2026-04-30
PRs
Workspace (7):
Upstream PRs (library, 5)
Summary
Workspace/library version mismatches now surface on every script run, not just
welcome.py.autoconf.workspace.check_versionwas extended to readconfig/general.yaml'sversion.workspace_version(withversion.txtas legacy fallback) and a newversion.workspace_version_check: FalseYAML override mirrors the existingpython_version_checkpattern. PyAutoFit, PyAutoGalaxy, and PyAutoLens now call the check on import. The release pipeline writes the new YAML key alongsideversion.txt, andverify_workspace_versions.shreportsokfor all 7 workspaces (euclid_pipeline went fromSKIPtook).Session Notes
__init__readsversion.txt) because the user explicitly wanted the version to survive users copy-pasting scripts out of the workspace into their own drive — they still need a config dir to run anything, so the config travels.PYAUTO_SKIP_WORKSPACE_VERSION_CHECK=1env var plus the new YAML flag. The new error/warning text explicitly recommends the YAML route and calls out themain-branch case ("mainupdates faster than releases, so mismatches are expected and not actionable formain-branch users").release.ymluse a regex-based Python shim instead of PyYAML round-trip — PyYAML strips comments, and the workspacegeneral.yamlfiles are heavily commented. The shim handles both "key present (in-place replace)" and "key missing (insert under existingversion:block, or append new block at end)".verify_workspace_versions.sh = ok. CI smoke tests on the PRs were the final gate.version.txtso was always SKIPped byverify_workspace_versions.sh— now joins the standard flow.Jammy2211 commentedon Jul 23, 2026
Closing — shipped 2026-04-30, verified 2026-07-23
This was fully delivered and simply never closed on GitHub. Re-verified today rather than taken on the record's word:
All 12 PRs merged (
merged=trueon each):Behaviour live on
main:autonerves/workspace.pycarries the config-aware resolution and theversion.workspace_version_checkYAML bypass; PyAutoFit, PyAutoGalaxy and PyAutoLens each callcheck_versionfrom__init__.py.Ledger:
PyAutoMind/complete/2026/04/workspace-version-config-check.md.One note on how the design has moved since:
check_versionis now a compatibility floor rather than an exact pin (version.minimum_library_version), following the wheels+tags-only release model in PyAutoBuild#118/#120. The mechanism this issue introduced is intact; only its comparison semantics were relaxed.Closed as part of #137.