Skip to content

fix(config): prior yaml drift — stale classes, paths, params + walker test #618

Closed

Description

@Jammy2211

Overview

autonerves.JSONPriorConfig resolves a prior by testing whether {cls.__module__}.{cls.__name__}.{param} ends with the dotted path of a yaml under config/priors/ plus its key (PyAutoNerves/autonerves/json_prior/config.py:226-244). A file at the wrong path, a typo'd key or a param the class does not take is therefore silently dead — the MRO family walk (config.py:195-202) usually finds a parent's file and nothing errors. The euclid pipeline's config-drift sweep (euclid#43 / PR #44) found rows that reproduce identically in the packaged PyAutoGalaxy/autogalaxy/config/ and in autolens_workspace/config/ + autogalaxy_workspace/config/. One row is a live runtime failure: af.Model(NFWTruncatedMCRScatterLudlowSph).instance_from_prior_medians() raises ConfigException because its yaml sits under the sibling module's filename. This task fixes the packaged config, adds a walker test so the class of bug cannot recur, and re-syncs the workspace copies.

Re-verified 2026-09-15 against main (PyAutoGalaxy 840ffde, PyAutoFit 27d41e7c8, PyAutoNerves fac8b17). Two corrections to the prompt: cosmology.yaml::model.FlatLambdaCDM is not drift (the dotted key is the correct suffix and resolves), and general.yaml::fits.flip_for_ds9 exists only in the workspaces, not in the packaged config. PyAutoFit's packaged plots_search.yaml is already correct, so PyAutoFit needs no change; PyAutoLens ships no priors/.

Plan

  • Fix the nine packaged PyAutoGalaxy prior-config rows (rename the ersic typo, move the NFWTruncatedMCRScatterLudlowSph block to nfw_truncated_mcr_scatter.yaml, delete the orphan linear chameleon.yaml / eff.yaml, drop the PointSourceChi block, drop the dead SersicCoreSph.mass_to_light_ratio and linear-operated Gaussian.intensity keys, reword the mesh README).
  • Add a PyAutoGalaxy test that walks autogalaxy/config/priors/** and asserts every top-level key suffix-matches a real class and every declared param is an __init__ argument.
  • Add a regression test that af.Model(NFWTruncatedMCRScatterLudlowSph).instance_from_prior_medians() succeeds.
  • Ship the library PR first.
  • Apply the same edits to autolens_workspace/config and autogalaxy_workspace/config (as edits, not blind copies), remove fits.flip_for_ds9 from both general.yaml, and replace the stale per-search plots_search.yaml in autolens_workspace, HowToLens and autolens_workspace_test with the nest/mcmc/mle form.
  • Ship one workspace PR per repo behind the library-first gate.
  • File two out-of-scope side findings via intake afterwards (SersicCoreSph.__init__ never accepts mass_to_light_ratio; light/linear_operated/ config lacks a sersic.yaml for the existing sersic.py).
Detailed implementation plan

Work Classification

Both — library (PyAutoGalaxy) first, workspaces follow.

Affected Repositories

  • PyAutoGalaxy (primary, library)
  • autolens_workspace (workspace: priors rows 1–9, plots_search.yaml, general.yaml)
  • autogalaxy_workspace (workspace: priors rows 1–9, general.yaml)
  • HowToLens (workspace: plots_search.yaml only)
  • autolens_workspace_test (workspace: plots_search.yaml only)

Branch Survey (2026-09-15)

Repository Current Branch Dirty? Worktree guard
./PyAutoGalaxy main clean clear
./autolens_workspace main clean claimed by multi-galaxy-j1011-real-data (scripts/multi_galaxy/**, disjoint) → own parallel worktree approved
./autogalaxy_workspace main clean (1 behind origin, ff-pull first) clear
./HowToLens main clean clear
./autolens_workspace_test main clean claimed by jax-runtime-and-parity (JAX runtime/parity scripts, disjoint) → own parallel worktree approved

Suggested branch: feature/config-priors-drift
Worktree root: ~/Code/PyAutoLabs-wt/config-priors-drift/

Findings (verified)

# File (rel. config/priors/ unless noted) Verdict Fix
1 light/operated/sersic.yaml key ersic typo; operated Sersic priors dead, fall back to standard rename key → Sersic (diff values vs light/standard/sersic.yaml and surface any difference)
2 mass/dark/nfw_truncated_mcr.yaml key NFWTruncatedMCRScatterLudlowSph class module is nfw_truncated_mcr_scatter; model construction raises ConfigException move block verbatim to new mass/dark/nfw_truncated_mcr_scatter.yaml
3 light/linear/chameleon.yaml orphan: no lp_linear.Chameleon delete file
4 light/linear/eff.yaml orphan: no lp_linear.ElsonFreeFall delete file
5 point_sources.yaml key PointSourceChi class gone (only Point, PointFlux) delete block
6 cosmology.yaml key model.FlatLambdaCDM not drift — resolves no change
7 mass/stellar/sersic_core.yaml SersicCoreSph.mass_to_light_ratio dead key, not in __init__ delete key
8 light/linear_operated/gaussian.yaml Gaussian.intensity dead key; linear Gaussian hard-codes intensity delete key
9 mesh/README.md "…or Voronoi mesh" stale prose "rectangular grid or Delaunay triangulation"
10 config/visualize/plots_search.yaml dynesty:/emcee:/nautilus:/zeus: readers (abstract_nest.py:72, abstract_mcmc.py:53, abstract_mle.py:33) read nest/mcmc/mle only; stale only in autolens_workspace, HowToLens, autolens_workspace_test replace with the PyAutoFit packaged file
11 config/general.yaml fits.flip_for_ds9 no reader anywhere; workspace-only delete key (and empty fits: header) in both workspaces

Implementation Steps

  1. PyAutoGalaxy config (autogalaxy/config/priors/): apply rows 1–9 as listed. cosmology.yaml untouched.
  2. PyAutoGalaxy test test_autogalaxy/config/test_priors_config.py:
    • test_every_prior_key_resolves_to_a_class — walk Path(autogalaxy.__file__).parent / "config" / "priors" with rglob("*.yaml"); rel = ".".join(path.relative_to(priors).with_suffix("").parts) (mirrors autonerves/json_prior/config.py:157-160); target suffix f"{rel}.{key}". Class census via pkgutil.walk_packages over autogalaxy, autoarray, autofit (inspect.getmembers(mod, inspect.isclass) filtered to cls.__module__ == mod.__name__) → {f"{cls.__module__}.{cls.__name__}": cls}. Assert exactly one census entry ends with the suffix; report all misses in one message.
    • test_every_prior_param_is_an_init_argument — every top-level param key under a class block must be in inspect.signature(cls.__init__).parameters minus self (skip when **kwargs is present).
    • A module-level ALLOWLIST dict (key → one-line reason) for anything that legitimately cannot resolve; the goal is an empty allowlist and any entry is reported for review.
    • test_nfw_truncated_mcr_scatter_ludlow_sph_model_resolves — af.Model(ag.mp.NFWTruncatedMCRScatterLudlowSph).instance_from_prior_medians() succeeds; prior_count matches the yaml.
  3. Run pytest test_autogalaxy/config -q, then the full pytest test_autogalaxy -q. Ship via ship_library.
  4. Workspaces: apply rows 1–9 as edits in autolens_workspace/config/priors and autogalaxy_workspace/config/priors; byte-diff each edited file against the packaged one (expected residual: autolens_workspace sersic_core.yaml keeps SersicCoreSph.radius_break: Constant 0.025). Remove fits.flip_for_ds9 from both general.yaml. Replace config/visualize/plots_search.yaml in autolens_workspace, HowToLens, autolens_workspace_test with the nest/mcmc/mle form (PyAutoFit/autofit/config/visualize/plots_search.yaml; autogalaxy_workspace already has it).
  5. Verify from each workspace cwd: af.Model(al.mp.NFWTruncatedMCRScatterLudlowSph).instance_from_prior_medians() succeeds; grep -rn "PointSourceChi\|flip_for_ds9\|Voronoi\|^ersic" config/ is empty. Ship one PR per repo via ship_workspace.

Key Files

  • PyAutoNerves/autonerves/json_prior/config.py:226-244 — the suffix matcher (mechanism; not modified)
  • PyAutoNerves/autonerves/json_prior/config.py:157-160 — file path → dotted top-level key
  • PyAutoGalaxy/autogalaxy/config/priors/** — the packaged config being fixed
  • PyAutoGalaxy/autogalaxy/profiles/mass/dark/nfw_truncated_mcr_scatter.py — the class whose priors are currently unresolvable
  • PyAutoGalaxy/test_autogalaxy/config/test_priors_config.py — new walker + regression tests
  • autolens_workspace/config/, autogalaxy_workspace/config/, HowToLens/config/visualize/plots_search.yaml, autolens_workspace_test/config/visualize/plots_search.yaml

Original Prompt

Click to expand starting prompt

Config priors drift: stale class names, paths and params shared by PyAutoGalaxy and autolens_workspace

Type: bug
Target: autogalaxy
Repos:

  • PyAutoGalaxy
  • PyAutoFit
  • autolens_workspace
  • autogalaxy_workspace
    Themes:
  • config
  • hygiene
    Difficulty: small
    Autonomy: safe
    Priority: medium
    Status: draft
    Consequence: judge
    Review-minutes: 20
    Unattended: ready
    Filed: 2026-08-29

Found by the euclid_strong_lens_modeling_pipeline config drift sweep (euclid#43 / PR #44,
2026-08-29). These findings reproduce identically in the packaged
PyAutoGalaxy/autogalaxy/config/priors/ and in autolens_workspace/config/priors/, so they
were deliberately left alone in the euclid repo (fixing them there would fork files in parity)
and belong upstream. Mechanism that makes several of these silent: JSONPriorConfig matches
cls.__module__ + cls.__name__ + param by suffix against the yaml path relative to
config/priors/, so a file at the wrong path is dead, not an error — the packaged default wins.

User request (verbatim): "voronoi was removed so we should remove voronoi.yaml and things with
similar references. I guess this implies for the euclid repo we should do a general config drift
sweet" — the euclid-local half shipped in PR #44; this prompt is the upstream half.

Findings (all verified against installed 2026.8.17.1 via dir() / __init__ signatures)

File Key Finding
priors/light/operated/sersic.yaml ersic Typo (leading S missing) — the operated Sersic priors are dead
priors/mass/dark/nfw_truncated_mcr.yaml NFWTruncatedMCRScatterLudlowSph path ≠ class module → dead
priors/light/linear/chameleon.yaml Chameleon, ChameleonSph path mismatch → dead
priors/light/linear/eff.yaml ElsonFreeFall, ElsonFreeFallSph path mismatch → dead
priors/point_sources.yaml PointSourceChi class no longer exists
priors/cosmology.yaml model.FlatLambdaCDM dotted key, no matching class path
priors/mass/stellar/sersic_core.yaml SersicCoreSph.mass_to_light_ratio param not in __init__
priors/light/linear_operated/gaussian.yaml Gaussian.intensity linear profiles have no intensity
priors/mesh/README.md prose still says "…Delaunay triangulation or Voronoi mesh" — Voronoi removed
visualize/plots_search.yaml dynesty:, emcee:, nautilus:, zeus: autofit reads only the three family-level sections; per-search blocks unread
general.yaml fits.flip_for_ds9 no reader in any library or autonerves

Deliverable

  • Fix or delete each row in the packaged PyAutoGalaxy (and PyAutoFit for plots_search/general)
    config, then propagate to autolens_workspace / autogalaxy_workspace config/ so the copies
    stay in parity.
  • Consider a small test in PyAutoFit/PyAutoGalaxy that walks config/priors/** and asserts every
    top-level key resolves to a class whose module path suffix-matches the file path and whose
    declared params are in __init__ — the check that found these is ~40 lines and would stop the
    class of bug recurring.

Activity

  1. Jammy2211 commented on Sep 16, 2026

    @Jammy2211
    CollaboratorAuthor

    Library PR Created — 2026-09-16

    What shipped

    All eleven dead rows in the packaged autogalaxy/config/priors/ fixed, plus test_autogalaxy/test_priors_config.py — a walker over config/priors/** asserting every top-level key suffix-matches a real PyAuto class (census of autogalaxy, autoarray, autofit) and every parameter is an __init__ argument, with model-construction regressions for NFWTruncatedMCRScatterLudlowSph and EllipseMultipoleScaled.

    Red witness (yaml stashed, test kept): 4 failed / 1 passed — the walker listed 9 dead keys and 2 dead params; NFWTruncatedMCRScatterLudlowSph had 2 of 6 priors, EllipseMultipoleScaled 0 of 2. With the fix: 5 passed; full pytest test_autogalaxy 1212 passed.

    Two rows the plan did not list, found by the walker: ellipse/ellipse_multipole.yaml (EllipseMultipoleRelative → EllipseMultipoleScaled, gaussian_limits → limits) and mesh/delaunay.yaml (empty DelaunayNN key under the delaunay file; module is delaunay_nn). cosmology.yaml::model.FlatLambdaCDM confirmed not drift, untouched.

    API changes

    None — packaged configuration and tests only. Behaviour change for users: operated Sersic and EllipseMultipoleScaled priors now load from their own yaml (the operated Sersic ellipticity prior becomes TruncatedGaussian(-1, 1) rather than the standard file's Gaussian + limits).

    Workspace impact → option (ii), /start_workspace

    The same rows exist verbatim in the config/priors/ copies of autolens_workspace, autogalaxy_workspace, HowToLens and autolens_workspace_test (the plan assumed the last two had no priors folder — they carry full copies, and autolens_workspace_test still ships the removed mesh/voronoi.yaml). All four get the prior edits; autolens_workspace, HowToLens and autolens_workspace_test also get the packaged nest/mcmc/mle plots_search.yaml; all four drop the readerless general.yaml::fits.flip_for_ds9.

    Out of this task's scope, to be filed via intake as a follow-up: the same typo'd/dead rows also exist in HowToGalaxy/config/priors, autogalaxy_workspace_test/config/priors (and its scripts/misc/aggregator/config/priors copy), autolens_assistant/config/priors, autogalaxy_assistant/config/priors, autocti_assistant/config/priors. euclid_strong_lens_modeling_pipeline keeps its copy by design (euclid#43).

    Next: workspace PRs, one per repo, behind the library-first merge gate.

  2. Jammy2211 commented on Sep 16, 2026

    @Jammy2211
    CollaboratorAuthor

    Workspace PRs Created — 2026-09-16

    Behind the library-first gate (merge #619 first):

    All four carry pending-release. Every edited config/priors/ file is byte-identical to the fixed packaged PyAutoGalaxy copy (only residual: the workspace-deliberate Delaunay.areas_factor in autolens_workspace / HowToLens mesh/delaunay.yaml, untouched). Two decisions beyond the plan: a duplicated SersicCore.radius_break block (same key twice in one mapping) was removed in three repos, and autogalaxy_workspace's plots_search.yaml was replaced too because its mle: block carried a corner_cornerpy key the MLE reader never looks up.

    Smoke Test Results — 2026-09-16

    pyauto-heart smoke autolens autogalaxy howtolens autolens_test --root <task worktree> (live source = this task's branches), exit 0, ~23 min:

    Workspace Passed Failed Total
    autolens (37 scripts + 2 notebooks) 39 0 39
    autogalaxy (14 scripts + 2 notebooks) 16 0 16
    howtolens 50 0 50
    autolens_test 31 0 31
    total 136 0 136

    Follow-ups filed on the Mind dashboard: draft/bug/autogalaxy/sersiccoresph_has_no_mass_to_light_ratio.md, draft/maintenance/autogalaxy/linear_operated_sersic_has_no_prior_yaml.md, draft/maintenance/workspaces/sync_remaining_workspace_config_priors_copies.md (HowToGalaxy, autogalaxy_workspace_test ×2, autolens/autogalaxy/autocti assistants still carry the same rows).

    Side observation (not this task): the smoke runner deleted the tracked autolens_workspace_test/output/.gitignore when wiping output/; restored by hand before the PR.

    Next: /prm once CI is green — library PR first, then the four workspace PRs.

  3. Jammy2211 commented on Sep 16, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped — 2026-09-16

    PRs

    Summary

    Eleven dead rows in the packaged autogalaxy/config/priors/ (typo'd, mis-pathed, orphan and dead-param keys that JSONPriorConfig's suffix matcher silently ignored) are fixed, and test_autogalaxy/test_priors_config.py now walks the packaged priors asserting every key resolves to a real class and every param is an __init__ argument, so the class of bug cannot recur. The four workspace config/ copies are re-synced to byte parity, their stale per-search plots_search.yaml replaced with the nest/mcmc/mle form autofit reads, and the readerless fits.flip_for_ds9 removed. Red witness 4 failed on the old config; full suite 1212 passed; smoke 136/136 across the four workspaces; CI green on every leg of all five PRs.

    Session Notes

    • The walker found two rows the plan missed (EllipseMultipoleRelative→EllipseMultipoleScaled + gaussian_limits→limits; empty DelaunayNN key). cosmology.yaml::model.FlatLambdaCDM is not drift.
    • HowToLens and autolens_workspace_test carry full config/priors/ copies (the plan assumed only plots_search.yaml); they got the full re-sync, including the removed mesh/voronoi.yaml.
    • Beyond the plan: a duplicated SersicCore.radius_break block removed in three repos; autogalaxy_workspace's plots_search.yaml replaced too (mle: carried an unread corner_cornerpy).
    • Library PR merged is not released: pending-release: PyAutoGalaxy@#619 carried into the record.
    • Follow-ups filed: draft/bug/autogalaxy/sersiccoresph_has_no_mass_to_light_ratio.md, draft/maintenance/autogalaxy/linear_operated_sersic_has_no_prior_yaml.md, draft/maintenance/workspaces/sync_remaining_workspace_config_priors_copies.md (heuristic sizes the last too-large; re-size or split before starting).
    • Smoke-runner defect observed: it deleted the tracked autolens_workspace_test/output/.gitignore while wiping output/ (restored before the PR).
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