Skip to content

test: assert every Colab project installs all three samplers - #166

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/autonerves-colab-sampler-deps
Sep 14, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/autonerves-colab-sampler-deps

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Adds the regression test that #164 shipped without.

The Colab bootstrap installs its package list with pip install *packages --no-deps, so a sampler that is not named in the list never lands — nothing
arrives transitively via autofit. dynesty and emcee were missing, and
every Colab notebook running af.DynestyStatic or af.Emcee died with
ModuleNotFoundError at fit time, across all six _PROJECTS entries
(observed in HowToFit chapter 1 tutorials 4, 5 and 6).

#164 (merged, 8336939) fixed the list. It did not add a test:
TestRegistry asserted only spec["packages"][0] == "autonerves", so nothing
stopped a future edit dropping a sampler again — which is exactly how the bug
arose. This PR closes that gap.

TestRegistry.test_every_project_installs_every_sampler asserts that for
every key in _PROJECTS ("autofit", "autogalaxy", "autolens", "howtofit",
"howtogalaxy", "howtolens") the resolved packages list contains dynesty,
emcee and nautilus-sampler. It matches on the requirement name with
any version specifier split off, so a future re-pin does not break it.

Release caveat — the main point of this PR's context. Colab notebooks
pip install autonerves fresh on every run, so #164's fix reaches users only
once a new autonerves is released to PyPI. Merging this PR (or #164)
changes nothing user-visible; Colab users keep hitting the
ModuleNotFoundError until that release ships.

autonerves/setup_colab.py is untouched by this PR. The existing
emcee>=3.1.6 / dynesty==2.1.5 pins track PyAutoFit's pyproject.toml and
are left exactly as #164 shipped them; the _SAMPLERS regrouping floated in
the issue plan was deliberately not taken, as unrequested churn on
freshly-merged code — the test asserts on the resolved packages, so it
holds either way if that refactor is ever made.

--no-deps runtime-requirement check

Because of --no-deps, each named sampler's own runtime requirements must
already exist in a stock Colab image:

Package Runtime requires In stock Colab?
dynesty==2.1.5 numpy, scipy (declares no install-requires in its metadata) yes
emcee>=3.1.6 numpy (h5py/scipy only under the extras extra) yes
nautilus-sampler==1.0.4 numpy>=1.18.0, scipy>=1.4.0, scikit-learn>=0.22.0, threadpoolctl>=3.0.0 yes (threadpoolctl arrives with scikit-learn)

Nothing further needs adding to the install list.

Flagged follow-up (not fixed here)

setup_colab.py pins nautilus-sampler==1.0.4, while PyAutoFit's
pyproject.toml declares nautilus-sampler==1.0.5. Every other sampler
specifier in the list matches autofit exactly, so this one looks like drift
rather than intent. Because the install is --no-deps, Colab therefore gets
1.0.4 against an autofit that expects 1.0.5.

Deliberately left alone: this PR is test-only and the new assertion matches on
package name, so it passes either way. Worth its own prompt.

API Changes

None — test-only changes.

Test Plan

  • python3 -m pytest test_autonerves/test_setup_colab.py -q → 21 passed
  • python3 -m pytest test_autonerves -q → 184 passed (183 before this PR)
  • Control test: dropping each of dynesty, emcee, nautilus-sampler
    from a copy of the registry makes the new assertion fail (it is not a
    tautology); substituting dynesty==9.9.9 and a bare unpinned emcee
    keeps it passing (a future re-pin will not break it).

Closes #165.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

https://claude.ai/code/session_011DMhAYrJ6m2spkTVEWcSKg

The Colab bootstrap installs with `pip install *packages --no-deps`, so any
sampler absent from the list never lands and the notebook cell constructing
that search dies with `ModuleNotFoundError` at fit time. That is how #164's
bug reached users: `dynesty` and `emcee` were missing from `_SHARED_EXTRAS`
and HowToFit chapter 1 tutorials 4 (dynesty), 5 and 6 (emcee) died on Colab.

#164 fixed the list but shipped no test — `TestRegistry` asserted only
`packages[0] == "autonerves"`, so nothing stops a future edit dropping a
sampler again.

Adds `TestRegistry.test_every_project_installs_every_sampler`: for every
`_PROJECTS` entry ("autofit", "autogalaxy", "autolens", "howtofit",
"howtogalaxy", "howtolens") the resolved `packages` list must contain
`dynesty`, `emcee` and `nautilus-sampler`. Matched on requirement name with
the version specifier split off, so a future re-pin does not break the test.

Test-only; `autonerves/setup_colab.py` is untouched.

Closes #165

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DMhAYrJ6m2spkTVEWcSKg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: regression-test the Colab sampler install (dynesty/emcee)

1 participant