Refactor: shared job submission utility (eliminates duplication across 22 scripts)#148
Merged
Conversation
- Add helper_scripts/UTILITY.submitJob.sh with submit_job() and run_parallel_jobs() functions - Replace duplicated 15-20 line if-elif submission blocks in 22 scripts with a single submit_job() call - Eliminate all remaining SC2086 shellcheck warnings (word-split $SUBC string converted to array inside the function) - Fix condor/condor_submit handling: condor_submit is now only invoked when the user selects condor_submit mode in submissionCommands.dat - Net: -318 lines across the codebase Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors repeated scheduler submission logic across analysis/IRF/SPANALYSIS shell scripts into a shared helper, reducing duplicated code and centralizing qsub/condor/sbatch/parallel/simple handling.
Changes:
- Adds
scripts/helper_scripts/UTILITY.submitJob.shwithsubmit_jobandrun_parallel_jobs. - Replaces inline job-submission conditionals in converted scripts with calls to the shared utility.
- Adds a maintenance changelog entry for the refactor.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/helper_scripts/UTILITY.submitJob.sh |
Adds shared submission and parallel execution helpers. |
scripts/ANALYSIS.anasum.sh |
Replaces inline submission logic with utility calls. |
scripts/ANALYSIS.anasum_combine.sh |
Replaces inline submission logic with utility calls. |
scripts/ANALYSIS.anasum_parallel_from_runlist.sh |
Uses shared submission and parallel runner. |
scripts/ANALYSIS.dispXGB.sh |
Uses shared submission helper. |
scripts/ANALYSIS.evndisp.sh |
Uses shared submission helper and writes shared parallel runner into Run_me.sh. |
scripts/ANALYSIS.evndisp_laser.sh |
Uses shared submission and parallel runner. |
scripts/ANALYSIS.evndisp_muon.sh |
Uses shared submission and parallel runner. |
scripts/ANALYSIS.mscw_energy.sh |
Uses shared submission and parallel runner. |
scripts/ANALYSIS.v2dl3.sh |
Uses shared submission and parallel runner. |
scripts/IRF.combine_effective_area_parts.sh |
Uses shared submission helper. |
scripts/IRF.combine_lookup_table_parts.sh |
Uses shared submission helper. |
scripts/IRF.compress_evndisp_MC.sh |
Uses shared submission helper. |
scripts/IRF.generate_effective_area_parts.sh |
Uses shared submission helper. |
scripts/IRF.generate_lookup_table_parts.sh |
Uses shared submission helper. |
scripts/IRF.generate_radial_acceptance.sh |
Uses shared submission and parallel runner. |
scripts/IRF.mscw_energy_MC.sh |
Uses shared submission helper. |
scripts/IRF.optimizeTMVAforGammaHadronSeparation.sh |
Uses shared submission and parallel runner. |
scripts/IRF.trainTMVAforAngularReconstruction.sh |
Uses shared submission helper. |
scripts/IRF.trainTMVAforGammaHadronSeparation.sh |
Uses shared submission and parallel runner. |
scripts/IRF.trainXGBforAngularReconstructionBinned.sh |
Uses shared submission helper. |
scripts/SPANALYSIS.lowgainped.sh |
Uses shared submission and parallel runner. |
scripts/SPANALYSIS.make_DST.sh |
Uses shared submission and parallel runner. |
docs/changes/148.maintenance.md |
Adds changelog fragment for the submission refactor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove duplicate submit_job/run_parallel_jobs calls in ANALYSIS.anasum.sh
and ANALYSIS.anasum_combine.sh (agent left the old block alongside the new)
- Fix simple-mode log name: use ${fscript%.sh}.log to avoid *.sh.log suffix
- Restore script-specific HTCondor priority args via CONDOR_SUBMIT_ARGS env var
(ANALYSIS.v2dl3.sh: 'submit 5', ANALYSIS.anasum_parallel_from_runlist.sh: 'submit 50')
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the duplicated job submission logic found in all analysis scripts into a single shared utility, eliminating ~320 lines of duplicated code and all remaining SC2086 shellcheck warnings.
Problem
Every one of the 22 analysis/IRF/SPANALYSIS scripts contained an identical (or nearly identical) 15–20 line
if/elifblock for job submission:This caused:
# shellcheck disable=SC2086suppressions (for$SUBC)Solution
New file:
scripts/helper_scripts/UTILITY.submitJob.shProvides two functions sourced by all scripts:
submit_job <fscript> [parallel_line [parallel_file]]— handles all scheduler types (qsub, condor, condor_submit, sbatch, parallel, simple, test)run_parallel_jobs [parallel_file]— runs collected jobs with GNU parallel after the main loopInside the function,
$SUBCis split into an array withread -ra subc_arr <<< "$SUBC", which is equivalent to the previously unquoted usage but shellcheck-clean.Each of the 22 scripts now does
Changes
Scripts updated (22):
ANALYSIS.anasum,ANALYSIS.anasum_combine,ANALYSIS.anasum_parallel_from_runlist,ANALYSIS.dispXGB,ANALYSIS.evndisp,ANALYSIS.evndisp_laser,ANALYSIS.evndisp_muon,ANALYSIS.mscw_energy,ANALYSIS.v2dl3,IRF.combine_effective_area_parts,IRF.combine_lookup_table_parts,IRF.compress_evndisp_MC,IRF.generate_effective_area_parts,IRF.generate_lookup_table_parts,IRF.generate_radial_acceptance,IRF.mscw_energy_MC,IRF.optimizeTMVAforGammaHadronSeparation,IRF.trainTMVAforAngularReconstruction,IRF.trainTMVAforGammaHadronSeparation,IRF.trainXGBforAngularReconstructionBinned,SPANALYSIS.lowgainped,SPANALYSIS.make_DSTBug fix (bonus)
The
condor/condor_submitdistinction insubmissionCommands.datwas not consistently respected. Some scripts always calledcondor_submitregardless of which condor variant the user had selected. The shared function now correctly checks*condor_submit*before*condor*, so automatic submission only happens when the user explicitly selectscondor_submitmode.Testing
shellcheck --severity=info scripts/*.sh scripts/helper_scripts/*.sh→ 0 violations ✅# shellcheck disable=SC2086lines remain anywhere ✅