Skip to content

Ensure reproducibility of tests/resources directory#2211

Draft
GernotMaier wants to merge 49 commits into
mainfrom
tests-resources
Draft

Ensure reproducibility of tests/resources directory#2211
GernotMaier wants to merge 49 commits into
mainfrom
tests-resources

Conversation

@GernotMaier
Copy link
Copy Markdown
Contributor

@GernotMaier GernotMaier commented May 28, 2026

work in progress

Ensure reproducibility of files used in tests:

Resource file generation

Add a resources_generation with all necessary config file to generate or retrieve tests files. All config files can be executed using the simtools-run-application functionality:

  • model parameter files are retrieved from the model parameter database (tests/resources_generation/model_parameters)
  • files generated by simtools are configured by the configuration files in tests/resources_generation/application_config

Addresses #1600

@GernotMaier GernotMaier self-assigned this May 28, 2026
GernotMaier and others added 9 commits May 28, 2026 11:09
Remove 11 files from tests/resources that are not referenced
in any unit or integration test (confirmed by grep across all
.py, .yml, .yaml, .json files excluding __pycache__):

- CTA-North-LSTN-01-Released_test-telescope-model.cfg
- derive_mirror_rnda_psf_{mean,measurement,no_tuning,random_flen}.ecsv
- flasher_full_simulation_lst_north/{simulate_*.yml,*.simtel.log}
- gamma_run000007_za40deg.../{corsika_config_*.input,simulate_prod_*.yml}
- log_sub_corsika_run000001_gamma_North_test_layout_test-production.out
- production_grid_generation_axes_definition_ra_dec.yml

Addresses #1600

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove redundant FileNotFoundError from except clause (S5713):
  FileNotFoundError is a subclass of OSError, making it redundant
- Reduce cognitive complexity of _copy_collection_files (S3776):
  Extract _collect_source_directories and _find_collection_file helpers
  to bring complexity from 18 down to within the allowed 15
- Update camera efficiency reference file for MSTx-FlashCam South:
  nsb field now reflects Benn_LaPalma_sky_converted.lis spectrum used
  in the integration test configuration

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add workflow configs to fetch the following test resource files from the
simulation model database instead of storing them in the repository:

- pm_photoelectron_spectrum.config.yml: spe_LST_2022-04-27_AP2.0e-4.dat
  (pm_photoelectron_spectrum v2.0.0, LSTN-design)
- mirror_list.config.yml: mirror_list-2.0.0.json
  (mirror_list v2.0.0, LSTN-01, JSON metadata)
- mirror_list_simtel_dat.config.yml: mirror_list_CTA-N-LST1_v2019-03-31_rotated_simtel.dat
  (mirror_list v2.0.0, LSTN-01, physical file)
- array_element_position_ground.config.yml: array_element_position_ground-2.0.0.json
  (array_element_position_ground v2.0.0, MSTN-09)
- array_element_position_utm.config.yml: array_element_position_utm-2.0.0.json
  (array_element_position_utm v2.0.0, MSTN-09)

Part of issue #1600.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace derive_mirror_rnda_psf_random_flen.ecsv (deleted in previous commit)
with the existing ray_tracing_North_LSTN-01_d10.0km_za20.0deg_validate_optics.ecsv
in the developer testing guide example.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Move mirror .dat resource to tests/resources/model_parameters/ using
  canonical DB filename (mirror_CTA-N-LST1_v2019-03-31_rotated.dat)
- Merge mirror_list_simtel_dat.config.yml into mirror_list.config.yml
  (both files now share the same collection output_path)
- Update test_mirrors.py fixture to use the new path

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove unreferenced test resource files
GernotMaier and others added 21 commits May 29, 2026 15:12
- Mock HTTP requests globally (urlretrieve) to serve local repo files
- Cache pyproj Transformer construction with lru_cache (layout/telescope_position.py)
- Write stub PNG bytes instead of real matplotlib renders for file saves
- Patch Figure.tight_layout to no-op (eliminates text-extent rendering)
- Patch Figure.colorbar to MagicMock (eliminates quad-mesh rendering)
- Add session-scoped ERFA warm-up fixture to pre-initialise astropy
  coordinate transforms before any test measures them

Typical improvements on slow test hardware (original -> new):
  test_plot_writes_per_type_comparison_figures:  1.96s -> ~0.25s
  test_plot_incident_angles_debug_plots_true:    1.73s -> ~0.25s
  test_generate_simulation_grid (ERFA):          1.12s -> ~0.30s
  test_build_layout (pyproj):                    1.56s -> ~0.10s
  test_read_table_from_file_and_validate:        1.24s -> ~0.25s

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ctao-sonarqube
Copy link
Copy Markdown

ctao-sonarqube Bot commented Jun 3, 2026

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.

1 participant