Skip to content

Add CORSIKA CLI path and interaction arguments#2137

Merged
GernotMaier merged 11 commits into
mainfrom
corsika-cli
Apr 29, 2026
Merged

Add CORSIKA CLI path and interaction arguments#2137
GernotMaier merged 11 commits into
mainfrom
corsika-cli

Conversation

@GernotMaier
Copy link
Copy Markdown
Contributor

@GernotMaier GernotMaier commented Apr 26, 2026

Summary

Add explicit CORSIKA CLI options for runtime paths and interaction models, and centralize all simulation software defaults into a single module.

What changed

New configuration/defaults.py module — single source of truth for configurable fallback values:

  • CORSIKA_PATH, CORSIKA_INTERACTION_TABLE_PATH
  • CORSIKA_HE_INTERACTION (epos), CORSIKA_LE_INTERACTION (urqmd)
  • SIMULATION_SOFTWARE_CHOICES, SIMULATION_SOFTWARE_DEFAULT
  • CURVED_ATMOSPHERE_MIN_ZENITH_ANGLE_DEG

CLI (commandline_parser.py):

  • Add --corsika_path and --corsika_interaction_table_path to the paths argument group (no parser-level defaults; resolved via settings.py so env vars work)
  • Add a new corsika configuration argument group with --corsika_he_interaction and --corsika_le_interaction
  • Replace literal simulation-software choices/default and curved-atmosphere angle with defaults constants

Settings (settings.py):

  • Fix _get_config_value to skip None arg values, so environment variables are not shadowed by unset CLI args
  • Use defaults constants for CORSIKA path and interaction fallbacks
  • Guard CORSIKA executable resolution with Path.is_dir() to avoid errors on non-existent default paths
  • Fix docstring: priority order is CLI arg > env var > built-in default

simulator.py: replace literal simulation-software default and choices list with defaults constants

Integration test configs (simulate_prod_*.yml): add corsika_he_interaction and corsika_le_interaction to all 8 configs

CI (CI-integrationtests.yml): remove SIMTOOLS_CORSIKA_HE_INTERACTION / SIMTOOLS_CORSIKA_LE_INTERACTION echo lines — these variables were never set in the template, so they wrote empty strings that silently shadowed the built-in defaults

Docs: add defaults module to docs/source/api-reference/configuration_module.md

Validation

pytest tests/unit_tests/configuration/test_commandline_parser.py tests/unit_tests/test_settings.py tests/unit_tests/corsika/ tests/unit_tests/test_simulator.py

203 tests pass.

@GernotMaier GernotMaier self-assigned this Apr 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds explicit CLI/configuration support for CORSIKA runtime paths and interaction models, and centralizes simulation-software defaults in a single module.

Changes:

  • Introduce simtools.configuration.defaults as the centralized source for simulation defaults (CORSIKA paths/models, simulation-software choices, curved-atmosphere threshold).
  • Update CLI parsing and settings resolution to use centralized defaults and improve precedence handling for unset CLI args.
  • Update simulator wiring plus integration-test configs/docs/CI templates to reflect the new configuration surface.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/simtools/configuration/defaults.py Adds centralized default constants for CORSIKA and simulation configuration.
src/simtools/configuration/commandline_parser.py Adds CORSIKA path + interaction CLI args and replaces inline literals with defaults.
src/simtools/settings.py Uses defaults, fixes config precedence for None args, and guards CORSIKA path resolution.
src/simtools/simulator.py Switches simulation-software defaults/choices and curved-atmosphere threshold to defaults.
tests/unit_tests/test_settings.py Adds unit coverage for default CORSIKA paths and default interaction-model-based executable naming.
tests/integration_tests/config/simulate_prod_proton_20_deg_north_check_output.yml Adds explicit corsika_*_interaction fields to integration config.
tests/integration_tests/config/simulate_prod_htcondor_generator_gamma_20_deg_north.yml Adds explicit corsika_*_interaction fields to integration config.
tests/integration_tests/config/simulate_prod_gamma_62_deg_south_check_output.yml Adds explicit corsika_*_interaction fields to integration config.
tests/integration_tests/config/simulate_prod_gamma_40_deg_south_sim_telarray_only.yml Adds explicit corsika_*_interaction fields to integration config.
tests/integration_tests/config/simulate_prod_gamma_40_deg_south_corsika_only.yml Adds explicit corsika_*_interaction fields to integration config.
tests/integration_tests/config/simulate_prod_gamma_40_deg_south_check_output.yml Adds explicit corsika_*_interaction fields to integration config.
tests/integration_tests/config/simulate_prod_gamma_40_deg_north_check_output.yml Adds explicit corsika_*_interaction fields to integration config.
tests/integration_tests/config/simulate_prod_gamma_20_deg_south_multiple_model_versions.yml Adds explicit corsika_*_interaction fields to integration config.
docs/source/api-reference/configuration_module.md Adds API-reference entry for the new defaults module.
docs/changes/2137.feature.md Adds changelog fragment for the new CLI options.
.github/workflows/CI-integrationtests.yml Stops echoing unset CORSIKA interaction env vars into .env during CI.
.github/copilot-instructions.md Documents requirement to add new modules to API reference.
.env_template Removes interaction-model env vars from template (defaults now provided in code).

Comment thread src/simtools/configuration/commandline_parser.py Outdated
Comment thread src/simtools/configuration/commandline_parser.py
@GernotMaier GernotMaier marked this pull request as ready for review April 27, 2026 07:26
@orelgueta orelgueta self-requested a review April 29, 2026 10:46
@ctao-sonarqube
Copy link
Copy Markdown

@GernotMaier GernotMaier merged commit 35f4545 into main Apr 29, 2026
17 checks passed
@GernotMaier GernotMaier deleted the corsika-cli branch April 29, 2026 14:15
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.

3 participants