Skip to content

fix: guard the point-source parity scripts against the SMALL_DATASETS cap - #265

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/point-source-dataset-cap-guard
Aug 23, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/point-source-dataset-cap-guard

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Workspace leg of PyAutoLabs/PyAutoLens#710. Library-first merge gate: PyAutoLabs/PyAutoLens#711 must merge before this one.

What this fixes

Follows #264, which found that should_simulate rmtrees the committed, gitignore-allowlisted, JSON-only dataset/point_source/simple whenever PYAUTO_SMALL_DATASETS=1 is in force — and that no SMALLDAT stamp exists on JSON data for PyAutoArray#471's library guard to read. Two gaps remained after it.

1. That sweep missed a site. point_source/visualization/modeling_visualization_jit.py declared ENV: real_output — a marker that does not release the cap — while its own __Env__ prose claimed "full-resolution data". It calls should_simulate on the committed dataset, making it the same defect #264 fixed next door in visualization.py.

2. The parity scripts had no defence of their own. Five scripts pin absolute likelihood literals against this dataset and would happily compare them to capped-regime output. Under the cap PointSolver.solve short-circuits to a position pair identical for every lens model, so the comparison measures nothing. That is how it presented: an assert failing with a different value on every run — once the -1e99 sentinel, once a finite-but-wrong 16.131221.

Scripts Changed

Script Change
point_source/visualization/modeling_visualization_jit.py ENV: real_output → ENV: full_datasets real_output, prose corrected
point_source/jax_likelihood/point.py cap guard
point_source/jax_likelihood/image_plane.py cap guard
point_source/jax_likelihood/source_plane.py cap guard
point_source/jax_likelihood/fluxes_time_delays.py cap guard (worded for its dataset_file.exists() bootstrap — it cannot delete, but it does read what a sibling poisoned)
point_source/jax_grad/gradient.py cap guard

The guard follows the interferometer/nufft.py precedent. Two deliberate choices:

  • Reads the env var, not grid geometry. nufft.py can assert its mask shape because it owns a FITS dataset with detectable capped geometry. A JSON dataset has no capped shape to detect.
  • Runs before the bootstrap. The should_simulate call is what destroys the data, so a misconfigured run now fails naming the cause instead of first destroying what the next run depends on.

Evidence

Measured in-session against libraries 2026.8.23.1 + PyAutoLens#711:

Check Result
should_simulate('dataset/point_source/simple'), cap on True — directory deleted, all 3 tracked JSON files gone
same call, cap off False — intact
PointSolver.solve at einstein_radius 1.0 / 1.6 / 2.5 under cap identical [(1.0, 0.0), (0.0, 1.0)]
point.py under the correct profile PASS — -83.38049778 and -82.33883111, both pins exact
image_plane.py, source_plane.py, fluxes_time_delays.py PASS with guards in place
point.py with PYAUTO_SMALL_DATASETS=1 fails on the guard, dataset untouched

So the originally reported failure is fully explained and no library numerical bug exists — the script passes on current main with an intact dataset.

Corrected sweep

Re-ran #264's audit — every !dataset/** allowlisted directory against every should_simulate call site whose ENV: lacks full_datasets. No at-risk sites remain in this workspace.

Two limits on that, stated plainly: it covers this repo only, so #264's "every workspace in the organism" claim is still unverified elsewhere; and full_datasets real_output is a marker combination that did not previously exist (every existing combo pairs full_datasets with real_plots). The derivation lives in PyAutoHands, so the smoke run is what confirms the harness accepts it.


Generated by Claude Code

… cap

Follows #264, which found that `should_simulate` rmtree's the committed,
gitignore-allowlisted, JSON-only `dataset/point_source/simple` whenever
`PYAUTO_SMALL_DATASETS=1` is in force, and that no `SMALLDAT` stamp exists on
JSON data for PyAutoArray#471's library guard to read. Two gaps remained.

First, that sweep missed a site. `point_source/visualization/modeling_visualization_jit.py`
declared `ENV: real_output` — which does not release the cap — while its own
`__Env__` prose claimed "full-resolution data". It calls `should_simulate` on the
committed dataset, so it is the same defect fixed next door in `visualization.py`.
Now declares `full_datasets real_output`.

Second, the parity scripts had no defence of their own. Five scripts pin absolute
likelihood literals against this dataset and would happily compare them to
capped-regime output. Under the cap `PointSolver.solve` short-circuits to a fixed
position pair identical for every lens model, so such a comparison measures
nothing — that is how it presented: an assert failing with a different value on
every run, once as the `-1e99` sentinel and once as a finite-but-wrong 16.131221.

Each of the five now asserts the cap is off before anything touches the dataset
directory, following the `interferometer/nufft.py` precedent. The check reads the
env var rather than inferring from grid geometry, because a JSON dataset has no
capped shape to detect. It runs before the bootstrap deliberately: a misconfigured
run now fails naming the cause instead of first destroying data the next run
depends on.

Verified in-session against libraries 2026.8.23.1 + PyAutoLens main:

- `should_simulate('dataset/point_source/simple')` returns True and deletes the
  directory under the cap; returns False and leaves it intact with the cap unset.
- `PointSolver.solve` returns [(1.0, 0.0), (0.0, 1.0)] at einstein_radius 1.0,
  1.6 and 2.5 alike.
- All four runnable parity scripts pass under the correct profile with the guards
  in place (point.py pins exact at -83.38049778 / -82.33883111).
- With `PYAUTO_SMALL_DATASETS=1`, point.py now fails on the guard and leaves the
  dataset untouched.

A corrected sweep of every allowlisted dataset against every `should_simulate`
call site in this workspace now reports no at-risk sites.

Refs PyAutoLens#710, PyAutoArray#470

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JJSb9kydhAgMgCCKh26ai2
@Jammy2211
Jammy2211 merged commit 051b051 into main Aug 23, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/point-source-dataset-cap-guard branch August 25, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants