Repository navigation
fix: add auto-simulate guards to unguarded dataset loads - #460
Merged
Merged
Conversation
Fixes 3 of the 4 missing-dataset smoke failures from PyAutoHeart run 30790463134 (the 4th, group/data_preparation/start_here, is deleted by #456). All three were reproduced on a clean checkout before any edit, and every paired simulator already existed. Two of the three already carried a correct guard for their FIRST dataset; the load that failed was a SECOND dataset further down the same file that nobody guarded. mask_irregular.py had no guard at all. 14 guards added across autolens_workspace, each dispatching to its existing paired simulator. delaunay.py takes ONE guard at :932 — the second unguarded block at :1041 resolves to the same dataset/imaging/simple later in the same linear script. Retires the dead dataset/imaging/lens_sersic path, which no simulator anywhere writes. gui/lens_light_centre.py and guides/results/database/start_here.py are repointed at dataset/imaging/simple (built by scripts/imaging/simulator.py with a Sersic bulge on the lens galaxy). database/start_here DROPS the dead name rather than duplicating `simple` twice, which would give two identically-named database entries. queries.py:60 had stale prose naming lens_sersic while the code beneath already queried simple__no_lens_light. guides/results/database/start_here leaves no_run. It had THREE faults, not the one its NEEDS_FIX marker named: 1. missing dataset -> auto-simulate guard (in the loop, per name) 2. missing info.json -> built inline; the sole producer, data_preparation/ examples/optional/info.py, writes it for `simple` ALONE, so nothing wrote simple__no_lens_light/info.json in any run order. Dead `import json` removed. No downstream key dependency: aggregator/data_fitting.py:76 reads agg.values("info") generically. 3. unbounded real search -> n_like_max=300. It declares ENV: real_search (so PYAUTO_TEST_MODE is unset and the sampler genuinely runs) but was the ONLY such script in the workspace without a cap; its four siblings in guides/results/ all use 300. Invariant now holds with zero exceptions. Runtime: unbounded (>9min, not converging) -> EXIT 0 in 245s. Verified under real smoke envs built via autohands.env_config.build_env_for_ script, not hand-set vars. PYAUTO_SMALL_DATASETS=1 makes should_simulate rmtree and re-simulate, so every guard was genuinely exercised. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…/missing-auto-simulate-guards
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #455
Summary
Fixes 3 of the 4 missing-dataset smoke failures from PyAutoHeart run
30790463134(the 4th,group/data_preparation/start_here, is deleted by #456 — this branch is merged onto that). All three were reproduced on a clean checkout before any edit, and every paired simulator already existed — the fix is an auto-simulate guard in each case, nothing was missing.A sweep then showed the failures were the tip of a class: dataset loads that reach
from_fitswith no guard pass smoke only because an earlier script in the run happens to simulate the same dataset first. Any of them run standalone in a clean checkout still break. After this branch, zero unguarded dataset loads remain in either repo.Root cause shape
Two of the three failing scripts already carried a correct guard — for their first dataset. The load that failed was a second dataset further down the same file that nobody guarded.
mask_irregular.pyhad no guard at all.Scripts Changed
scripts/imaging/data_preparation/manual/mask_irregular.pyimaging/features/no_lens_light/simulator.pyscripts/multi_dataset/features/imaging_and_interferometer/modeling.pymulti_dataset/simulator.pyscripts/guides/results/start_here.pyno_lens_light/simulator.pyscripts/guides/results/latent_variables.pyno_lens_light/simulator.pyscripts/imaging/data_preparation/start_here.pyimaging/simulator.pyscripts/imaging/data_preparation/examples/psf.pyimaging/simulator.pyscripts/imaging/features/linear_light_profiles/likelihood_function.pyimaging/simulator.pyscripts/imaging/features/pixelization/delaunay.py:932— the 2nd unguarded block at:1041is the same dataset later in the same linear scriptscripts/imaging/data_preparation/gui/mask.pyno_lens_light/simulator.pyscripts/imaging/data_preparation/gui/positions.pyno_lens_light/simulator.pyscripts/imaging/data_preparation/gui/extra_galaxies_centres.pyextra_galaxies/simulator.pyscripts/imaging/data_preparation/gui/mask_extra_galaxies.pyextra_galaxies/simulator.pyscripts/imaging/data_preparation/gui/lens_light_centre.pylens_sersicpath + guardscripts/guides/results/database/start_here.pyscripts/guides/results/aggregator/queries.pylens_sersic→simple__no_lens_light, matching the code beneath)config/build/no_run.yamlguides/results/database/start_hereNEEDS_FIX entry removed★ = one of the reported smoke failures.
The dead
dataset/imaging/lens_sersicpathNo simulator anywhere writes it. Three references:
gui/lens_light_centre.py:32,guides/results/database/start_here.py:73, andaggregator/queries.py:60(prose only — the code already queriedsimple__no_lens_light).Repointing at
dataset/multi_dataset/imaging/lens_sersic(the only reallens_sersicdataset) was rejected: it is multi-band withg_data.fits/g_psf.fitsprefixes, so a plainfrom_fits(data_path=dataset_path / "data.fits")cannot load it. Both consumers now usedataset/imaging/simple, whichscripts/imaging/simulator.pybuilds with a Sersic bulge on the lens galaxy (:184) — single-band imaging that genuinely has lens light, which is what a "click the lens light centre" GUI needs.database/start_here.pydrops the dead name rather than duplicatingsimpletwice, which would give two identically-named database entries and defeat the guide's own point.guides/results/database/start_here.pyleavesno_runIts NEEDS_FIX marker named one fault. It had three:
info.json→ built inline. The sole producer,data_preparation/examples/optional/info.py, writes it forsimplealone, so nothing wrotesimple__no_lens_light/info.jsonin any run order, and it isn't shipped. The inline dict matchesinfo.py's contents and a prose cross-reference to it is kept. Deadimport jsonremoved. No downstream key dependency —aggregator/data_fitting.py:76readsagg.values("info")generically.n_like_max=300. The script declaresENV: real_search(soPYAUTO_TEST_MODEis unset and the sampler genuinely runs) but was the only such script in the workspace without a cap. Its four siblings inguides/results/all use 300, and_quick_fit.py:16documents the rationale: "hard-capped atn_like_max=300likelihood evaluations rather than running to convergence… fast enough to fit inside the per-script CI timeout."The invariant
real_search⟹n_like_maxnow holds with zero exceptions — exactly 5 scripts declarereal_searchand useaf.Nautilus, and all 5 carry a cap.Runtime: unbounded (>9 min on one core, fit 1 of 2 not converging) → EXIT 0 in 245s.
Validation
Every changed script that can run, run under its real smoke env — built via
autohands.env_config.build_env_for_scriptagainstconfig/build/profile_smoke.yaml, not hand-set variables. Those envs setPYAUTO_SMALL_DATASETS=1, which makesshould_simulatermtreeand re-simulate, so every guard was genuinely exercised rather than skipped over pre-existing data.mask_irregular.py★multi_dataset/.../modeling.py★guides/results/database/start_here.pyguides/results/aggregator/queries.pyimaging/features/pixelization/delaunay.pylinear_light_profiles/likelihood_function.pyguides/results/start_here.pydata_preparation/examples/psf.pyguides/results/latent_variables.pyimaging/data_preparation/start_here.pyNot verified by execution: the 5 GUI scripts — they cannot run headless and are
no_run. Their guards use the same idiom and are syntax- and import-checked, but were not executed.Also:
check_sizes.shclean; all changed scripts compile; all importal; fullgenerate.py autolensregeneration leftworkspace_index.jsonandllms-full.txtbyte-identical (so no generated-index collision with #453 or #459).Note on the reported evidence
The triage said NEEDS_FIX markers existed "for several start_here scripts".
no_run.yamlcarried 4 NEEDS_FIX entries, of which exactly one was dataset-related.imaging/data_preparation/start_hereandguides/results/start_herewere not inno_run— they were unguarded and passed only by run-ordering luck. Both are now guarded.Ship gate
Heart
redat ship time (2026-08-03T17:44:16Z). Shipped under the corrective-PR exception, human-authorized in session, scoped to the YELLOW reason"workspace validation not passing (19 failed, 1 timeout, cloud#30790463134: …)"— the run this task was filed from, 3 of whose failures this removes.None of the three RED reasons relate to this change:
"PyAutoFit: 1 commit(s) behind origin","install verification FAILED (testpypi; checks D)"(chased by PyAutoLens#687),"release validation FAILED (stage integrate)"(chased by PyAutoFit#1442). The exception permits commit/push/PR-open only — merge and release stay human.Follow-up filed (not in this PR)
Two guard idioms coexist and are not equivalent:
should_simulatealso deletes-and-rebuilds underPYAUTO_SMALL_DATASETS=1, while the hand-rollednot (dataset_path / "data.fits").exists()variants in 4 scripts do not — so those keep full-resolution data on disk in a capped run. Deliberately not folded in, since it is a behaviour change to scripts that currently pass. Prompt drafted in PyAutoMind.🤖 Generated with Claude Code