From ca2d24a89c0025f42b7b773d347cc4ea9db02155 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Aug 2026 23:39:13 +0000 Subject: [PATCH] feat: use ac.util.dataset.should_simulate for auto-simulate guards Migrate all 22 dataset auto-simulation guards (21 scripts) from the raw 'if not path.exists(dataset_path):' idiom to 'if ac.util.dataset.should_simulate(dataset_path):'. should_simulate restores the PYAUTO_SMALL_DATASETS=1 force-regeneration behaviour: it deletes an existing dataset directory so the simulator re-runs at capped resolution, instead of silently reusing a full-resolution dataset. This depends on the PyAutoCTI ac.util.dataset export (alias of autoarray's dataset_util) landing on the same-named branch. Also: - fix simulate_datasets_missing.sh, which referenced the nonexistent simulators/overview/non_uniform_charge_injection.py (real file: non_uniform_cosmic_rays.py) - drop the dead first dataset_name assignments (immediately overwritten) in imaging_ci/extract.py and imaging_ci/data_preparation/examples/cosmic_ray_flagging.py Notebooks are not regenerated here: autocti is not registered in PyAutoHands COLAB_PROJECTS, so regeneration happens via the PyAutoHands release pipeline. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01Vu1p9rcDQGRrYddB6VWcxN --- scripts/imaging_ci/advanced/chaining/pipelines/parallel.py | 2 +- .../advanced/chaining/pipelines/parallel_x2__serial_x2.py | 2 +- scripts/imaging_ci/advanced/chaining/pipelines/serial.py | 2 +- .../imaging_ci/advanced/chaining/x1_species_to_x2_species.py | 2 +- scripts/imaging_ci/correction/start_here.py | 2 +- .../imaging_ci/data_preparation/examples/bias_subtraction.py | 2 +- .../data_preparation/examples/cosmic_ray_flagging.py | 3 +-- scripts/imaging_ci/data_preparation/examples/pre_cti.py | 2 +- .../data_preparation/examples/pre_cti_and_cosmics.py | 2 +- scripts/imaging_ci/data_preparation/examples/serial_cti.py | 2 +- scripts/imaging_ci/data_preparation/start_here.py | 4 ++-- scripts/imaging_ci/extract.py | 3 +-- scripts/imaging_ci/modeling/features/cosmic_rays.py | 2 +- scripts/imaging_ci/modeling/features/non_uniform.py | 2 +- scripts/imaging_ci/modeling/features/serial_cti.py | 2 +- scripts/imaging_ci/modeling/features/visualize_full.py | 2 +- scripts/imaging_ci/modeling/start_here.py | 2 +- scripts/plot/diagnostics/imaging_ci/well_filling.py | 2 +- scripts/plot/plotters/FitImagingCIPlotter.py | 2 +- scripts/plot/plotters/ImagingCIPlotter.py | 2 +- scripts/plot/plotters/MultiFigurePlotter.py | 2 +- simulate_datasets_missing.sh | 2 +- 22 files changed, 23 insertions(+), 25 deletions(-) diff --git a/scripts/imaging_ci/advanced/chaining/pipelines/parallel.py b/scripts/imaging_ci/advanced/chaining/pipelines/parallel.py index 0c0354c..49d131f 100644 --- a/scripts/imaging_ci/advanced/chaining/pipelines/parallel.py +++ b/scripts/imaging_ci/advanced/chaining/pipelines/parallel.py @@ -29,7 +29,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/advanced/chaining/pipelines/parallel_x2__serial_x2.py b/scripts/imaging_ci/advanced/chaining/pipelines/parallel_x2__serial_x2.py index a79071e..f01992f 100644 --- a/scripts/imaging_ci/advanced/chaining/pipelines/parallel_x2__serial_x2.py +++ b/scripts/imaging_ci/advanced/chaining/pipelines/parallel_x2__serial_x2.py @@ -29,7 +29,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/advanced/chaining/pipelines/serial.py b/scripts/imaging_ci/advanced/chaining/pipelines/serial.py index 1e26981..bdeb71e 100644 --- a/scripts/imaging_ci/advanced/chaining/pipelines/serial.py +++ b/scripts/imaging_ci/advanced/chaining/pipelines/serial.py @@ -29,7 +29,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/advanced/chaining/x1_species_to_x2_species.py b/scripts/imaging_ci/advanced/chaining/x1_species_to_x2_species.py index 119a2a7..1e50981 100644 --- a/scripts/imaging_ci/advanced/chaining/x1_species_to_x2_species.py +++ b/scripts/imaging_ci/advanced/chaining/x1_species_to_x2_species.py @@ -48,7 +48,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/correction/start_here.py b/scripts/imaging_ci/correction/start_here.py index 9c84615..7b1eb9b 100644 --- a/scripts/imaging_ci/correction/start_here.py +++ b/scripts/imaging_ci/correction/start_here.py @@ -34,7 +34,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/data_preparation/examples/bias_subtraction.py b/scripts/imaging_ci/data_preparation/examples/bias_subtraction.py index 660a971..e0d842f 100644 --- a/scripts/imaging_ci/data_preparation/examples/bias_subtraction.py +++ b/scripts/imaging_ci/data_preparation/examples/bias_subtraction.py @@ -41,7 +41,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/data_preparation/examples/cosmic_ray_flagging.py b/scripts/imaging_ci/data_preparation/examples/cosmic_ray_flagging.py index 84f0b8a..a0471ef 100644 --- a/scripts/imaging_ci/data_preparation/examples/cosmic_ray_flagging.py +++ b/scripts/imaging_ci/data_preparation/examples/cosmic_ray_flagging.py @@ -31,7 +31,6 @@ You should be familiar with the **PyAutoCTI** API below, if not check out other scripts throughout the workspace. """ -dataset_name = "parallel_x2__serial_x3" dataset_name = "cosmic_rays" dataset_path = path.join("dataset", "imaging_ci", dataset_name) @@ -41,7 +40,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/data_preparation/examples/pre_cti.py b/scripts/imaging_ci/data_preparation/examples/pre_cti.py index 3894bf0..38da13c 100644 --- a/scripts/imaging_ci/data_preparation/examples/pre_cti.py +++ b/scripts/imaging_ci/data_preparation/examples/pre_cti.py @@ -52,7 +52,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/data_preparation/examples/pre_cti_and_cosmics.py b/scripts/imaging_ci/data_preparation/examples/pre_cti_and_cosmics.py index 942847e..06c0d0c 100644 --- a/scripts/imaging_ci/data_preparation/examples/pre_cti_and_cosmics.py +++ b/scripts/imaging_ci/data_preparation/examples/pre_cti_and_cosmics.py @@ -51,7 +51,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/data_preparation/examples/serial_cti.py b/scripts/imaging_ci/data_preparation/examples/serial_cti.py index 17e9ba7..8a833f1 100644 --- a/scripts/imaging_ci/data_preparation/examples/serial_cti.py +++ b/scripts/imaging_ci/data_preparation/examples/serial_cti.py @@ -42,7 +42,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/data_preparation/start_here.py b/scripts/imaging_ci/data_preparation/start_here.py index 12f9fb4..bbb99c4 100644 --- a/scripts/imaging_ci/data_preparation/start_here.py +++ b/scripts/imaging_ci/data_preparation/start_here.py @@ -42,7 +42,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys @@ -253,7 +253,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/extract.py b/scripts/imaging_ci/extract.py index 8563381..0fe1243 100644 --- a/scripts/imaging_ci/extract.py +++ b/scripts/imaging_ci/extract.py @@ -26,7 +26,6 @@ You should be familiar with the **PyAutoCTI** API below, if not check out other scripts throughout the workspace. """ -dataset_name = "parallel_x2__serial_x2" dataset_name = "simple" dataset_path = path.join("dataset", "imaging_ci", dataset_name) @@ -36,7 +35,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/modeling/features/cosmic_rays.py b/scripts/imaging_ci/modeling/features/cosmic_rays.py index 6400df6..b094ab9 100644 --- a/scripts/imaging_ci/modeling/features/cosmic_rays.py +++ b/scripts/imaging_ci/modeling/features/cosmic_rays.py @@ -66,7 +66,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/modeling/features/non_uniform.py b/scripts/imaging_ci/modeling/features/non_uniform.py index b26646f..5a620af 100644 --- a/scripts/imaging_ci/modeling/features/non_uniform.py +++ b/scripts/imaging_ci/modeling/features/non_uniform.py @@ -36,7 +36,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/modeling/features/serial_cti.py b/scripts/imaging_ci/modeling/features/serial_cti.py index 4862895..b353103 100644 --- a/scripts/imaging_ci/modeling/features/serial_cti.py +++ b/scripts/imaging_ci/modeling/features/serial_cti.py @@ -36,7 +36,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/modeling/features/visualize_full.py b/scripts/imaging_ci/modeling/features/visualize_full.py index e728e29..294f49d 100644 --- a/scripts/imaging_ci/modeling/features/visualize_full.py +++ b/scripts/imaging_ci/modeling/features/visualize_full.py @@ -39,7 +39,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/imaging_ci/modeling/start_here.py b/scripts/imaging_ci/modeling/start_here.py index 4cd7713..331cbd3 100644 --- a/scripts/imaging_ci/modeling/start_here.py +++ b/scripts/imaging_ci/modeling/start_here.py @@ -50,7 +50,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/plot/diagnostics/imaging_ci/well_filling.py b/scripts/plot/diagnostics/imaging_ci/well_filling.py index f41f85d..c19425c 100644 --- a/scripts/plot/diagnostics/imaging_ci/well_filling.py +++ b/scripts/plot/diagnostics/imaging_ci/well_filling.py @@ -31,7 +31,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/plot/plotters/FitImagingCIPlotter.py b/scripts/plot/plotters/FitImagingCIPlotter.py index 0eb80dc..ed2f8e0 100644 --- a/scripts/plot/plotters/FitImagingCIPlotter.py +++ b/scripts/plot/plotters/FitImagingCIPlotter.py @@ -30,7 +30,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/plot/plotters/ImagingCIPlotter.py b/scripts/plot/plotters/ImagingCIPlotter.py index 331af24..c0382bf 100644 --- a/scripts/plot/plotters/ImagingCIPlotter.py +++ b/scripts/plot/plotters/ImagingCIPlotter.py @@ -30,7 +30,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/scripts/plot/plotters/MultiFigurePlotter.py b/scripts/plot/plotters/MultiFigurePlotter.py index 274da05..d9db3c1 100644 --- a/scripts/plot/plotters/MultiFigurePlotter.py +++ b/scripts/plot/plotters/MultiFigurePlotter.py @@ -37,7 +37,7 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if not path.exists(dataset_path): +if ac.util.dataset.should_simulate(dataset_path): import subprocess import sys diff --git a/simulate_datasets_missing.sh b/simulate_datasets_missing.sh index 428ae0a..e80a983 100644 --- a/simulate_datasets_missing.sh +++ b/simulate_datasets_missing.sh @@ -1,2 +1,2 @@ -python scripts/imaging_ci/simulators/overview/non_uniform_charge_injection.py +python scripts/imaging_ci/simulators/overview/non_uniform_cosmic_rays.py python scripts/imaging_ci/simulators/overview/uniform.py \ No newline at end of file