Skip to content

Commit e57da37

Browse files
Jammy2211claude
authored andcommitted
fix(howtolens): should_simulate every dataset load; run under SMALL_DATASETS
Make every HowToLens tutorial run under PYAUTO_SMALL_DATASETS=1 (16x16) so smoke/CI stays fast, instead of relying on a dead unset-workaround. - Migrate all 22 raw `if not dataset_path.exists():` guards to `al.util.dataset.should_simulate(str(dataset_path))` — the drop-in idiom that ALSO deletes + re-simulates stale data under the cap (so on-disk full-res data can't mismatch the 16x16 masks/grids). - Add missing guards: tutorial_0_visualization (simple__no_lens_light) and tutorial_7_fitting's second load (simple__no_lens_light__mass_sis). - Fix tutorial_7_fitting's first-load guard: it pointed at the wrong simulator (no_lens_light__mass_sis) for the `howtolens` dataset, which is produced by tutorial_6_data.py — a latent bug the migration exposed. - Add guard for tutorial_6_lens_modeling's second load (lens_sersic). - Remove the dead `howtolens/` + `guides/` PYAUTO_SMALL_DATASETS-unset overrides from config/build/env_vars.yaml (they matched zero files here). - Regenerate notebooks + navigator catalogue. Verified: every chapter passes on a FRESH dataset/ dir (cloud shard isolation) under SMALL_DATASETS=1 — ch1 9/9, ch2 8/8, ch3 6/6, ch4 all green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent c403606 commit e57da37

48 files changed

Lines changed: 136 additions & 60 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config/build/env_vars.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,10 @@ overrides:
3030
unset: [PYAUTO_SMALL_DATASETS]
3131
- pattern: "multi/start_here"
3232
unset: [PYAUTO_SMALL_DATASETS]
33-
# Non-simulator scripts that load committed FITS data need full-size
34-
# datasets to avoid shape mismatch with pre-existing 100x100 data.
35-
# Simulators run first and regenerate data at the capped size, but
36-
# scripts using the old `if not dataset_path.exists()` pattern skip
37-
# re-simulation when data already exists.
38-
- pattern: "howtolens/"
39-
unset: [PYAUTO_SMALL_DATASETS]
40-
- pattern: "guides/"
41-
unset: [PYAUTO_SMALL_DATASETS]
33+
# (Removed the dead `howtolens/` + `guides/` PYAUTO_SMALL_DATASETS-unset
34+
# workarounds: they matched no files here, and the tutorials now use
35+
# `al.util.dataset.should_simulate` which deletes + re-simulates stale
36+
# data under the cap, so the chapters run correctly at 16x16.)
4237
# guides/results/start_here.py must produce real samples so the example
4338
# scripts that read from `output/results_folder` afterwards
4439
# (data_fitting, queries, models, samples_via_aggregator) find a

notebooks/chapter_1_introduction/tutorial_0_visualization.ipynb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,32 @@
116116
"outputs": [],
117117
"execution_count": null
118118
},
119+
{
120+
"cell_type": "markdown",
121+
"metadata": {},
122+
"source": [
123+
"__Dataset Auto-Simulation__\n",
124+
"\n",
125+
"If the dataset does not already exist on your system, it is created by running the corresponding\n",
126+
"simulator script. This ensures every example script can be run without manually simulating data first."
127+
]
128+
},
129+
{
130+
"cell_type": "code",
131+
"metadata": {},
132+
"source": [
133+
"if al.util.dataset.should_simulate(str(dataset_path)):\n",
134+
" import subprocess\n",
135+
" import sys\n",
136+
"\n",
137+
" subprocess.run(\n",
138+
" [sys.executable, \"scripts/simulator/no_lens_light.py\"],\n",
139+
" check=True,\n",
140+
" )"
141+
],
142+
"outputs": [],
143+
"execution_count": null
144+
},
119145
{
120146
"cell_type": "markdown",
121147
"metadata": {},

notebooks/chapter_1_introduction/tutorial_7_fitting.ipynb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,21 @@
129129
"source": [
130130
"__Dataset Auto-Simulation__\n",
131131
"\n",
132-
"If the dataset does not already exist on your system, it will be created by running the corresponding\n",
133-
"simulator script. This ensures that all example scripts can be run without manually simulating data first."
132+
"The `howtolens` dataset is the one built up and saved in tutorial 6 (`tutorial_6_data.py`). If it does\n",
133+
"not already exist on your system, it is created by running that script. This ensures every example\n",
134+
"script can be run without manually simulating data first."
134135
]
135136
},
136137
{
137138
"cell_type": "code",
138139
"metadata": {},
139140
"source": [
140-
"if not dataset_path.exists():\n",
141+
"if al.util.dataset.should_simulate(str(dataset_path)):\n",
141142
" import subprocess\n",
142143
" import sys\n",
143144
"\n",
144145
" subprocess.run(\n",
145-
" [sys.executable, \"scripts/simulator/no_lens_light__mass_sis.py\"],\n",
146+
" [sys.executable, \"scripts/chapter_1_introduction/tutorial_6_data.py\"],\n",
146147
" check=True,\n",
147148
" )\n",
148149
"\n",
@@ -1025,6 +1026,15 @@
10251026
"dataset_name = \"simple__no_lens_light__mass_sis\"\n",
10261027
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
10271028
"\n",
1029+
"if al.util.dataset.should_simulate(str(dataset_path)):\n",
1030+
" import subprocess\n",
1031+
" import sys\n",
1032+
"\n",
1033+
" subprocess.run(\n",
1034+
" [sys.executable, \"scripts/simulator/no_lens_light__mass_sis.py\"],\n",
1035+
" check=True,\n",
1036+
" )\n",
1037+
"\n",
10281038
"dataset = al.Imaging.from_fits(\n",
10291039
" data_path=dataset_path / \"data.fits\",\n",
10301040
" psf_path=dataset_path / \"psf.fits\",\n",

notebooks/chapter_2_lens_modeling/tutorial_1_non_linear_search.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@
281281
"cell_type": "code",
282282
"metadata": {},
283283
"source": [
284-
"if not dataset_path.exists():\n",
284+
"if al.util.dataset.should_simulate(str(dataset_path)):\n",
285285
" import subprocess\n",
286286
" import sys\n",
287287
"\n",

notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
"cell_type": "code",
192192
"metadata": {},
193193
"source": [
194-
"if not dataset_path.exists():\n",
194+
"if al.util.dataset.should_simulate(str(dataset_path)):\n",
195195
" import subprocess\n",
196196
" import sys\n",
197197
"\n",

notebooks/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
"cell_type": "code",
130130
"metadata": {},
131131
"source": [
132-
"if not dataset_path.exists():\n",
132+
"if al.util.dataset.should_simulate(str(dataset_path)):\n",
133133
" import subprocess\n",
134134
" import sys\n",
135135
"\n",

notebooks/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"cell_type": "code",
126126
"metadata": {},
127127
"source": [
128-
"if not dataset_path.exists():\n",
128+
"if al.util.dataset.should_simulate(str(dataset_path)):\n",
129129
" import subprocess\n",
130130
" import sys\n",
131131
"\n",

notebooks/chapter_2_lens_modeling/tutorial_5_linear_profiles.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
"cell_type": "code",
140140
"metadata": {},
141141
"source": [
142-
"if not dataset_path.exists():\n",
142+
"if al.util.dataset.should_simulate(str(dataset_path)):\n",
143143
" import subprocess\n",
144144
" import sys\n",
145145
"\n",

notebooks/chapter_2_lens_modeling/tutorial_6_masking_and_positions.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"cell_type": "code",
113113
"metadata": {},
114114
"source": [
115-
"if not dataset_path.exists():\n",
115+
"if al.util.dataset.should_simulate(str(dataset_path)):\n",
116116
" import subprocess\n",
117117
" import sys\n",
118118
"\n",

notebooks/chapter_2_lens_modeling/tutorial_7_results.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"cell_type": "code",
108108
"metadata": {},
109109
"source": [
110-
"if not dataset_path.exists():\n",
110+
"if al.util.dataset.should_simulate(str(dataset_path)):\n",
111111
" import subprocess\n",
112112
" import sys\n",
113113
"\n",

0 commit comments

Comments
 (0)