From 65e76e598d8537917bbf3027e4ac0a07ebac2ad4 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 15 Sep 2026 00:17:23 +0100 Subject: [PATCH] test: assert every Colab project installs all three samplers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) Claude-Session: https://claude.ai/code/session_011DMhAYrJ6m2spkTVEWcSKg --- test_autonerves/test_setup_colab.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test_autonerves/test_setup_colab.py b/test_autonerves/test_setup_colab.py index db46b80..d8af892 100644 --- a/test_autonerves/test_setup_colab.py +++ b/test_autonerves/test_setup_colab.py @@ -1,4 +1,5 @@ import logging +import re import subprocess import sys import types @@ -89,6 +90,20 @@ def test_all_projects_have_required_fields(self): "https://github.com/PyAutoLabs/" ), project + def test_every_project_installs_every_sampler(self): + # Regression: `--no-deps` means a sampler absent from the install list + # never lands, and the notebook cell constructing that search dies with + # ModuleNotFoundError at fit time (HowToFit chapter 1 tutorials 4, 5 + # and 6 on Colab). Match on the package name only, so a future re-pin + # of any of them does not break this test. + required = {"dynesty", "emcee", "nautilus-sampler"} + for project, spec in setup_colab._PROJECTS.items(): + names = { + re.split(r"[<>=!~\[]", package, maxsplit=1)[0].strip() + for package in spec["packages"] + } + assert required <= names, (project, sorted(names)) + def test_every_project_has_a_wrapper(self): for project in setup_colab._PROJECTS: assert hasattr(setup_colab, f"for_{project}"), project