Repository navigation
fix: normalise the four hand-rolled auto-simulate guards onto should_simulate - #463
Merged
Merged
Conversation
…simulate Four scripts guarded their auto-simulate step by hand instead of calling `al.util.dataset.should_simulate`, which the other 249 sites use. The two are not equivalent: under `PYAUTO_SMALL_DATASETS=1` (a `profile_smoke.yaml` default) `should_simulate` deletes the dataset so the simulator rebuilds it at the reduced resolution, whereas a bare `.exists()` check reuses whatever is on disk. The four scripts would therefore read a full-resolution dataset left by an earlier uncapped run inside a run that is meant to be capped — the exact shape mismatch `should_simulate` was written to prevent. Verified on `cluster/likelihood_function.py` with a stale 1000x1000 dataset on disk: capped run now rebuilds it to 16x16 and exits 0. `cluster/likelihood_function.py` also reads the truth-model CSVs, so its stricter `mass.csv` clause is kept alongside `should_simulate` rather than dropped; `should_simulate` is evaluated first so its rebuild always runs. Two of the four never worked at all: `slam_source_parametric.py` and `slam_source_pixelized.py` guarded on `dataset_Path()`, an undefined name, so they raised `NameError` whenever the dataset was absent. Both are `no_run` in `config/build/no_run.yaml`, which is why CI never caught it. Notebooks regenerated; navigator catalogue unchanged. Closes #462
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 #462. Follow-up left open by choice from #455 / #460.
What changed
Four scripts guarded their auto-simulate step by hand instead of calling
al.util.dataset.should_simulate, which the other 249 sites use:scripts/cluster/likelihood_function.pynot (dataset_path / "data.fits").exists() or not (dataset_path / "mass.csv").exists()should_simulate(...) or not (dataset_path / "mass.csv").exists()scripts/interferometer/features/pixelization/many_visibilities_preparation.pynot (dataset_path / "data.fits").exists()should_simulate(...)scripts/imaging/features/advanced/subhalo/sensitivity/slam_source_parametric.pynot dataset_Path().exists()should_simulate(...)scripts/imaging/features/advanced/subhalo/sensitivity/slam_source_pixelized.pynot dataset_Path().exists()should_simulate(...)The two idioms are not equivalent. Under
PYAUTO_SMALL_DATASETS=1(aconfig/build/profile_smoke.yamldefault)should_simulatedeletes the dataset so the simulator rebuilds it at reduced resolution; a bare.exists()check reuses whatever is on disk. The four scripts therefore read a full-resolution dataset left by an earlier uncapped run inside a run that is meant to be capped.cluster/likelihood_function.pyalso reads the truth-model CSVs, so its strictermass.csvclause is kept rather than dropped.should_simulateis evaluated first so its rebuild side-effect always runs beforeorshort-circuits.The failure mode is silent, not loud
The prompt (and this PR's first draft) predicted a shape-mismatch crash. Measured, it is quieter and worse. Controlled run of
cluster/likelihood_function.pyunder the capped profile, with a stale (1000, 1000) dataset on disk, pre-change vs post-change — the only variable is whether the dataset gets rebuilt:-2.3951e+071.7518e+01-3.1784e+071.7518e+01Match (rtol=1e-2)So a capped run silently computed on full-resolution data, the script's hand-rolled likelihood disagreed with the library's by ~33%, its own consistency check reported
False— and it exited 0 anyway, so nothing surfaced it. A teaching script demonstrating a wrong result while reporting success. Running from an empty dataset dir givesMatch (rtol=1e-2): True, confirming the stale dataset is the cause.Two of the four never worked at all
slam_source_parametric.pyandslam_source_pixelized.pyguarded ondataset_Path()— an undefined name — so they raisedNameErrorwhenever the dataset was absent. Confirmed before/after on a clean checkout:Nobody noticed because
config/build/no_run.yamlexcludes every sensitivity script, and none of the four is insmoke_tests.txt— so the premise that they "currently pass smoke" was wrong; they were never run.Both still fail further down on pre-existing, unrelated stale-API faults —
'Model' object has no attribute 'centre'(parametric) andmodule 'autolens' has no attribute 'MapperValued'(pixelized). Those are the standingno_runreason and are out of scope; this PR strictly improves both and does not claim to fix them.Verification
Capped profile (
PYAUTO_TEST_MODE=2 PYAUTO_SMALL_DATASETS=1+ the rest ofprofile_smoke.yaml), from an empty dataset dir and from a stale full-resolution one:cluster/likelihood_function.pyMatch (rtol=1e-2): TrueMatch: Trueinterferometer/.../many_visibilities_preparation.pydata.fitsmd52d36bc69…→ee334711…)subhalo/sensitivity/slam_source_parametric.pyNameErrorat 876)no_runsubhalo/sensitivity/slam_source_pixelized.pyno_runGuard semantics isolated old-vs-new:
Uncapped behaviour is unchanged, so the prompt's "can only make them slower" caution applies only to capped runs, where rebuilding is the point — and both timed cases are 12–22s.
Also run:
scripts/check_sizes.sh(clean) and the fullrun_smoke.pysuite.Scope note
Growing
should_simulatean optionalrequired_files=[...]argument (a PyAutoArray change) is not done — only 1 of 249 call sites needs a stricter check, so a library API for a single caller is not yet earned. Recorded on #462 rather than silently dropped.A sweep confirms the class is now closed: no hand-rolled auto-simulate guards remain. The other
.exists()checks inscripts/are deliberately different and were left alone — aFileNotFoundErrorfor the committed SDP.81 dataset (interferometer/start_here.py), a path fallback (guides/hpc/example_cpu_and_gpu.py), and secondary-artifact guards (positions.json,point_dataset_*.json) that correctly sit after a primaryshould_simulatecall (converting those wouldrmtreethe dataset twice).Notebooks
Regenerated via PyAutoHands; exactly the four corresponding
.ipynbfiles changed, diffs confined to the guard lines. Navigator catalogue (llms-full.txt,workspace_index.json) unchanged.