Generate htcondor submit files to make bias curves#2248
Conversation
…m/gammasim/simtools into generate-overwrite-parameter-grid
|
Thanks @EshitaJoshi for the draft on the HTCondor / overwrite model parameter scanning. I think there is too much duplication - parameter_scan_generator.py is a variation of htcondor_script_generator.py and we would have to maintain in several places the same functionality. My suggestion is to combine this and get a job list file (as discussed yesterday), but with the overwrite model parameter as parameter: To use as much of the existing code (and also what the user is familiar with), the workflow would be: This way you don't need to duplicate the basic job preparation, and the job scripts only needs to be extended to use (if available) the I paste below the diagnostic of the AI: Yes. parameter_scan_generator.py is largely a second HTCondor generator beside htcondor_script_generator.py. The unique part is only the scan logic: cartesian parameter combinations and overwrite YAML generation. The submit file, params file, executable script, image resolution, log directories, and queue-from handling should stay in the existing HTCondor path. Main concerns with the new diff:
My suggested implementation plan:
And for full clarity, this is the prompt I've used: |
…m/gammasim/simtools into generate-overwrite-parameter-grid
There was a problem hiding this comment.
Pull request overview
This PR adds a parameter-scan workflow that expands an existing production job grid into a scan grid with per-combination overwrite YAMLs, and updates the HTCondor submit generator to optionally pass --overwrite_model_parameters, --scan_label, and --telescope per queued job. On top of that, it introduces a new “bias curve” helper application that generates NSB (gamma) and proton submission bundles via an internal scan definition.
Changes:
- Added
parameter_scan_generator+ CLI (simtools-generate-parameter-scan-grid) to expand job grids and generate overwrite YAMLs per scan combination. - Extended HTCondor script generation to accept optional queue fields (
overwrite_model_parameters,scan_label,telescope) and forward them tosimtools-simulate-prod. - Added
bias_curve_submissions+ CLI (simtools-generate-bias-curve-submissions) to generate NSB/proton scan configs, workflow configs, and submission directories.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit_tests/job_execution/test_parameter_scan_generator.py | Unit tests for scan config parsing, combo naming, overwrite generation, and grid expansion behavior. |
| tests/unit_tests/job_execution/test_job_manager.py | Additional unit tests for job_manager edge cases (retry, env propagation, stream prep). |
| tests/unit_tests/job_execution/test_htcondor_script_generator.py | Updated/extended tests for optional HTCondor queue fields and script rendering. |
| tests/unit_tests/job_execution/test_bias_curve_submissions.py | Unit tests for the bias-curve workflow config, telescope resolution rules, and scan config creation. |
| src/simtools/production_configuration/job_grid_io.py | Adds optional string-column support for job grids (used by scan expansions). |
| src/simtools/job_execution/parameter_scan_generator.py | New scan-grid expander that generates overwrite YAMLs and duplicates base rows per combination. |
| src/simtools/job_execution/htcondor_script_generator.py | Adds optional queue fields and forwards them to simtools-simulate-prod. |
| src/simtools/job_execution/bias_curve_submissions.py | New bias-curve submission workflow builder (NSB + proton). |
| src/simtools/applications/generate_parameter_scan_grid.py | New CLI wrapper around parameter_scan_generator.expand_job_grid_with_scan. |
| src/simtools/applications/generate_bias_curve_submissions.py | New CLI wrapper around bias_curve_submissions.generate_bias_curve_submissions. |
| pyproject.toml | Registers the two new CLI entry points. |
| docs/source/user-guide/applications/simtools-generate-parameter-scan-grid.rst | Adds user-guide page for the new parameter-scan grid generator CLI. |
| docs/source/user-guide/applications/simtools-generate-bias-curve-submissions.rst | Adds user-guide page for the new bias-curve submissions CLI. |
| docs/source/user-guide/applications.md | Adds both new application docs pages to the toctree list. |
| docs/source/api-reference/job_execution.md | Adds API reference entries for the two new job_execution modules. |
| docs/changes/2248.feature.md | Changelog fragment describing the added bias-curve workflow feature. |
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
GernotMaier
left a comment
There was a problem hiding this comment.
Very nice!! I have minor comments below plus the separation of configuration and submission. But in general, this is a nice implementation - especially as simtools-production-generate-grid is a generic base-grid generator.
I didn't test the submission step yet (as I had to do this first review offline without HT Condor). Will do this after the updates.
|
|
||
| Reads a base job grid ECSV from ``simtools-production-generate-grid``, generates | ||
| one overwrite YAML file per scan parameter combination, and writes an expanded | ||
| ``scan_grid.ecsv``. The resulting file is passed directly to |
There was a problem hiding this comment.
Why do need to pass it directly to the HT Condor generator? This mixes a bit configuration steps and the actual backend.
There was a problem hiding this comment.
Will stop the application after the scan_grid.ecsv is generated. The user can then pass this on themselves, making this backend agnostic.
| return combinations | ||
|
|
||
|
|
||
| def expand_job_grid_with_scan(base_grid_file, scan_config_path, output_file): |
There was a problem hiding this comment.
Public functions should have numpy doc style description of parameters.
|
|
||
| def _generate_parameter_combinations(param_specs): | ||
| """Generate all cartesian combinations of parameter values.""" | ||
| value_lists = [p["values"] for p in param_specs] |
There was a problem hiding this comment.
Use
values = general.ensure_list(param_spec["values"])
if not values:
raise ValueError("'values' must contain at least one scan value.")
Otherwise a "220" is expanded to [2,2,0]
| energy_range_tag="{energy_range_tag}" | ||
| job_label="{label}_${{corsika_he_interaction}}-${{corsika_le_interaction}}_${{energy_range_tag}}" | ||
| job_label="{label}" | ||
| {scan_label_block}{overwrite_parameters_block}{telescope_block} |
There was a problem hiding this comment.
Does this break the original functionality? e.g. preparing a grid with different interaction models or a list of fixed energies?
| --site {args_dict["site"]} \\ | ||
| --array_layout_name "$array_layout_name" \\ | ||
| --primary "$primary" \\ | ||
| {telescope_argument} --primary "$primary" \\ |
| --run_number_offset {run_number_offset} \\ | ||
| --save_reduced_event_lists \\ | ||
| --output_path /tmp/simtools-output \\ | ||
| {overwrite_parameters_argument} --output_path /tmp/simtools-output \\ |
|
|
||
| if "overwrite_model_parameters" in params_fields: | ||
| row.append( | ||
| _format_param_value( |
There was a problem hiding this comment.
job_spec.get("overwrite_model_parameters") is a path? Would _format_param_value change the path? e.g. if there it is something like "my path"?
| HTCondor submit script content. | ||
| """ | ||
| # Map _PARAMS_FIELDS to bash positional indices ($3, $4, etc.) | ||
| params_fields = params_fields or _PARAMS_FIELDS |
There was a problem hiding this comment.
Is this needed? It seems to me that params_field is always set when _get_submit_file is called.
Remove unused code in job_grid_io.py




Give it the apptainer image path and run with:
It will then generate
bias_curves/nsb/htcondor_submitandbias_curves/proton/htcondor_submitwith the .condor and .sh files respectively that can be submitted. Remember to copy theenv.txtfile into each htcondor_submit folder!