Repository navigation
Description
Overview
Phase 4 of the nss_first_class_sampler roadmap — make installing af.NSS a single safe command, eliminating the multi-step install saga documented in z_projects/profiling/FINDINGS_v3.md. Closes the install-pain barrier so Phase 5 (workspace tutorial scripts) can recommend af.NSS to users without a 3-hour adventure.
Approach (after audit): Option C from the original prompt — a pyproject.toml extra autofit[nss] listing pinned git+ URLs in dependency order — is the lightest path that works with modern pip. Original prompt assumed pip extras couldn't sequence properly; modern pip 23+ handles URL-direct deps well, and pinning the handley-lab/blackjax fork as the primary blackjax in our extra means pip never installs mainline blackjax in the first place. Fallback to Option D (python -m autofit.install_nss helper) if C fails the fresh-venv smoke.
Plan
- Add
[project.optional-dependencies]entrynss = [...]inPyAutoFit/pyproject.tomllisting four pinned URL deps in install order:fastprogress<1.1,handley-lab/blackjaxfork (git+URL),yallup/nss(git+URL), plus any transitive deps the fork needs. - Pin specific commit SHAs (not branch heads) for both git+ URLs so installs are reproducible and we control upgrade timing.
- Fresh-venv smoke:
python -m venv tmp_venv && tmp_venv/bin/pip install -e PyAutoFit[nss] && tmp_venv/bin/python -c "import autofit as af; af.NSS()"must succeed end-to-end in CI. - Add a GitHub Actions workflow
.github/workflows/nss_install_smoke.ymlthat runs the fresh-venv smoke on every PR — catches install regressions before users see them. - If Option C trips on pip resolver issues (mainline blackjax wins despite the URL pin, or transitive dep conflict), fall back to Option D: ship a
autofit/install_nss.pyhelper that subprocess-calls the install commands in order. - Update
af.NSS'sImportErrormessage to reference the newpip install autofit[nss]command (currently points at the manual git+URL install). - Document the install in
PyAutoFit/README.md(or wherevernautilus-samplerinstall is documented) so users find it via the standard PyAutoFit docs.
Detailed implementation plan
Affected Repositories
- PyAutoFit (primary — library)
Work Classification
Library
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoFit | main | clean |
worktree_check_conflict (exit=0): no active task claims PyAutoFit.
Suggested branch: feature/nss-install-extra
Worktree root: ~/Code/PyAutoLabs-wt/nss-install-extra/ (created by /start_library)
Implementation Steps
-
Audit upstream commit SHAs. Pull current HEAD from
handley-lab/blackjaxandyallup/nss. Verify those exact commits work with our pinned JAX 0.4.x. Record SHAs for pinning. -
Add the
nssextra toPyAutoFit/pyproject.toml:[project.optional-dependencies] nss = [ "fastprogress<1.1", "blackjax @ git+https://github.com/handley-lab/blackjax.git@<COMMIT_SHA>", "nss @ git+https://github.com/yallup/nss.git@<COMMIT_SHA>", ]
-
Fresh-venv smoke locally to validate before touching CI:
python -m venv /tmp/nss_install_smoke source /tmp/nss_install_smoke/bin/activate pip install -e PyAutoFit[nss] python -c "import autofit as af; s = af.NSS(); print('NSS import + instantiate OK')" deactivate && rm -rf /tmp/nss_install_smoke
If this succeeds → Option C is viable; proceed to CI. If it fails → diagnose, possibly fall back to Option D.
-
Add a CI workflow at
PyAutoFit/.github/workflows/nss_install_smoke.yml:- Triggers:
pull_request(any path) + weekly cron (catches upstream regressions on unchanged code). - Job: fresh ubuntu venv,
pip install .[nss], run the same import smoke as step 3.
- Triggers:
-
Update
af.NSS.__init__'sImportErrormessage to reference the new install command:raise ImportError( "af.NSS requires the optional `nss` package. Install via\n" " pip install autofit[nss]\n" "(see PyAutoFit's pyproject.toml for the pinned upstream commits)." )
-
Document the install in README.md alongside the existing
nautilus-samplerinstall pointer. -
Smoke test on a fresh venv end-to-end —
pip install autofit[nss]from scratch, then runautolens_workspace_developer/searches_minimal/nss_first_class_gaussian.py(Phase 1's Gaussian smoke) to confirm the full path works without any manual install steps.
Fallback path (Option D)
If step 3 fails, add PyAutoFit/autofit/install_nss.py:
"""Helper to install `af.NSS`'s dependencies in the right order."""
import subprocess
import sys
_COMMANDS = [
["pip", "install", "fastprogress<1.1"],
["pip", "install", "git+https://github.com/handley-lab/blackjax.git@<SHA>"],
["pip", "install", "git+https://github.com/yallup/nss.git@<SHA>", "--no-deps"],
]
def main():
for cmd in _COMMANDS:
print(f"Running: {' '.join(cmd)}")
subprocess.check_call([sys.executable, "-m"] + cmd)
print("af.NSS dependencies installed.")
if __name__ == "__main__":
main()User runs pip install autofit && python -m autofit.install_nss. Same smoke gate applies.
Key Files
PyAutoFit/pyproject.toml— add[project.optional-dependencies] nss = [...]PyAutoFit/.github/workflows/nss_install_smoke.yml— new CI workflowPyAutoFit/autofit/non_linear/search/nest/nss/search.py— updateImportErrormessagePyAutoFit/README.md— install documentationPyAutoFit/autofit/install_nss.py— fallback only, ship only if Option C fails
Out of scope
- Vendoring nss / blackjax (Option A) — heavy maintenance commitment; only revisit if Option C and D both fail
- Upstream coordination with yallup (Option B) — pursue informally in parallel; not gating this PR
nss_grad/ HMC variant install — separate prompt when that lands- conda / mamba install instructions — pip-first
- pocomc / numpyro install pain — those are separate samplers, not in scope here
Risks / open questions
-
Pip resolver may install mainline blackjax anyway despite our URL-direct pin. Verify in step 3's fresh-venv smoke. If it does, the workaround is
--no-depson the nss install line, which works as apip installflag but I need to confirm it works inside a pyproject.toml extra. If pyproject.toml can't express--no-deps, that's the Option D fallback trigger. -
Commit SHA staleness. Pinning specific commits insulates from upstream churn but means we miss bug fixes. Mitigation: periodically (e.g. quarterly) bump the pins, run the smoke, and ship a CHANGELOG note.
-
License audit. Verify
yallup/nss(BSD-3-Clause per latest check) andhandley-lab/blackjax(Apache-2.0 from the file headers) licenses are compatible with PyAutoFit before pinning. They are, but document it in a top-of-file comment in the extra. -
CI cost. The fresh-venv install pulls JAX, JAX deps, fastprogress, optax, chex, equinox, jaxtyping, etc. — likely 5-10 min CI step. Run on a single Python version (3.12) in this workflow to keep cost bounded.
Original Prompt
Click to expand starting prompt
Make installing af.NSS a single safe command for a science user
installing PyAutoFit fresh — eliminate the multi-hour multi-step
install saga that the profiling project survived in session-of-2026-05-11.
This is Phase 4 of z_features/nss_first_class_sampler.md.
Depends on Phase 1 (so we know what API surface to vendor or
pin against), and informs Phase 5 (workspace tutorials can only
recommend af.NSS to users if installation isn't a 3-hour adventure).
[... full prompt as authored — see PyAutoPrompt/issued/nss_install_simplification.md for the verbatim source.]
Activity
Jammy2211 commentedon May 16, 2026
Shipped — 2026-05-16
PR
Summary
`pip install autofit[nss]` is now the single command that installs `af.NSS` and all its dependencies. Replaces the multi-step install saga documented in FINDINGS_v3.md.
```bash
pip install autofit[nss]
python -c "import autofit as af; af.NSS()" # just works
```
Approach (Option C from the prompt)
The Phase 4 prompt recommended Option A (full vendoring of ~1300 LOC). Investigation revealed modern pip 23+ handles URL-direct deps cleanly, so the lighter Option C path (pyproject.toml extra with pinned git+ URLs) works without ongoing re-vendor maintenance burden. Verified empirically on a fresh venv.
Critical pin: `ef45acd2f` for handley-lab/blackjax
First attempt with HEAD (`5dbf89a9`) failed: HEAD adds `numpy>=1.25` which conflicts with PyAutoFit's `anesthetic==2.8.14` (numpy<2.0). Pinned to `ef45acd2f` instead — the May 2026 "Merge PR #60 — double_compile" commit, validated through Phases 1-3. Bump only when the anesthetic numpy cap moves (likely when Python 3.13 anesthetic>=2.9 takes over).
Validation
nss_first_class_sampler roadmap status
Only Phase 5 remains. With install now `pip install autofit[nss]`, the workspace tutorials can recommend af.NSS without any disclaimers.