forked from Waxpardo/Hadronization
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit_status_analysis.sh
More file actions
executable file
·188 lines (150 loc) · 5.53 KB
/
Copy pathsubmit_status_analysis.sh
File metadata and controls
executable file
·188 lines (150 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/bin/bash
set -euo pipefail
# Submit Paul's THnSparse status analysis for one HF tune or for all paper tunes.
#
# Usage:
# ./submit_status_analysis.sh TUNE [NUMBER_OF_FILES] [JOB_TAG]
# ./submit_status_analysis.sh ALL 100 Job700
#
# TUNE can be MONASH, JUNCTIONS, CLOSEPACKING, or ALL.
# NUMBER_OF_FILES is the number of available raw ROOT files to process per tune.
#
# Environment overrides:
# RAW_INPUT_BASE default: /data/alice/ipardoza/Hadronization/RootFiles/HF
# ANALYSIS_OUTPUT_BASE default: /data/alice/pveen_new/PanosPaper/RootFiles/AnalysisResults/HF
# HADRONIZATION_BASE default: directory containing this script
# STATUS_ANALYSIS_REQUEST_MEMORY default: 8GB
# DRY_RUN set to 1/true to write the submit file without condor_submit
usage() {
cat <<'USAGE'
Usage:
./submit_status_analysis.sh TUNE [NUMBER_OF_FILES] [JOB_TAG]
./submit_status_analysis.sh ALL 100 Job700
TUNE:
MONASH
JUNCTIONS
CLOSEPACKING
ALL
Defaults:
NUMBER_OF_FILES = 1
JOB_TAG = Job700
NUMBER_OF_FILES selects the first N available raw ROOT files for each tune,
sorted by the numeric job id in the filename. This means validation runs can
use, for example, 50 completed files per tune even if some low job ids are
still running.
Environment overrides:
RAW_INPUT_BASE Raw HF ROOT input base directory.
ANALYSIS_OUTPUT_BASE Per-job THnSparse analysis output base directory.
HADRONIZATION_BASE Hadronization checkout containing AnalysisScripts.
STATUS_ANALYSIS_REQUEST_MEMORY
Condor memory request for each status-analysis job.
DRY_RUN Set to 1/true to write the submit file without condor_submit.
USAGE
}
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
project_base="${HADRONIZATION_BASE:-${script_dir}}"
project_base="${project_base%/}"
export HADRONIZATION_BASE="${project_base}"
raw_input_base="${RAW_INPUT_BASE:-/data/alice/ipardoza/Hadronization/RootFiles/HF}"
analysis_output_base="${ANALYSIS_OUTPUT_BASE:-/data/alice/pveen_new/PanosPaper/RootFiles/AnalysisResults/HF}"
analysis_scripts_dir="${project_base}/AnalysisScripts"
dry_run="${DRY_RUN:-0}"
request_memory="${STATUS_ANALYSIS_REQUEST_MEMORY:-8GB}"
requested_tune="${1:-}"
number_of_files="${2:-1}"
job_tag="${3:-Job700}"
if [[ -z "${requested_tune}" || "${requested_tune}" == "-h" || "${requested_tune}" == "--help" ]]; then
usage
exit 0
fi
requested_tune="$(printf '%s' "${requested_tune}" | tr '[:lower:]' '[:upper:]')"
if ! [[ "${number_of_files}" =~ ^[0-9]+$ ]]; then
echo "ERROR: NUMBER_OF_FILES must be an integer, got '${number_of_files}'" >&2
exit 1
fi
if [[ ! -d "${analysis_scripts_dir}" ]]; then
echo "ERROR: AnalysisScripts directory not found: ${analysis_scripts_dir}" >&2
exit 1
fi
resolve_tunes() {
case "$1" in
MONASH|JUNCTIONS|CLOSEPACKING)
printf '%s\n' "$1"
;;
ALL)
printf '%s\n' MONASH JUNCTIONS CLOSEPACKING
;;
*)
echo "ERROR: unknown tune '$1'. Expected MONASH, JUNCTIONS, CLOSEPACKING, or ALL." >&2
exit 1
;;
esac
}
tunes=($(resolve_tunes "${requested_tune}"))
subfile="submit_status_analysis_${requested_tune}_${job_tag}.sub"
cat > "${subfile}" <<EOF
universe = vanilla
executable = ${project_base}/run_status_analysis.sh
request_cpus = 1
request_memory = ${request_memory}
request_disk = 2GB
+UseOS = "el9"
+JobCategory = "short"
environment = "HADRONIZATION_BASE=${project_base}"
should_transfer_files = NO
EOF
queued_jobs=0
for tune in "${tunes[@]}"; do
input_directory="${raw_input_base}/${tune}"
output_directory="${analysis_output_base}/${tune}/${job_tag}"
output_logs_directory="${output_directory}/Logs"
mkdir -p "${output_directory}"
mkdir -p "${output_logs_directory}"
if [[ ! -d "${input_directory}" ]]; then
echo "WARNING: input directory not found for ${tune}: ${input_directory}" >&2
continue
fi
queued_for_tune=0
while IFS=$'\t' read -r job_id file; do
if [[ -z "${job_id}" || -z "${file}" ]]; then
continue
fi
cat >> "${subfile}" <<EOF
arguments = ${job_id} ${file} ${output_directory} ${analysis_scripts_dir}
output = ${output_logs_directory}/job_${job_id}.out
error = ${output_logs_directory}/job_${job_id}.err
log = ${output_logs_directory}/job_${job_id}.log
queue 1
EOF
queued_jobs=$((queued_jobs + 1))
queued_for_tune=$((queued_for_tune + 1))
done < <(
find "${input_directory}" -maxdepth 1 -type f -name "*.root" -print |
while IFS= read -r candidate; do
job_id=$(printf '%s\n' "${candidate}" | sed -n 's/.*job\([0-9][0-9]*\)\.root$/\1/p')
if [[ -n "${job_id}" ]]; then
printf '%s\t%s\n' "${job_id}" "${candidate}"
fi
done |
sort -n -k1,1 |
head -n "${number_of_files}"
)
if [[ "${queued_for_tune}" -lt "${number_of_files}" ]]; then
echo "WARNING: requested ${number_of_files} files for ${tune}, but only queued ${queued_for_tune}" >&2
fi
done
if [[ "${queued_jobs}" -eq 0 ]]; then
echo "ERROR: no status-analysis jobs were queued. Check input directories and job count." >&2
exit 1
fi
echo "Prepared ${queued_jobs} status-analysis jobs in ${subfile}"
echo "Tunes: ${tunes[*]}"
echo "Raw input base: ${raw_input_base}"
echo "Analysis output base: ${analysis_output_base}"
case "${dry_run}" in
1|true|TRUE|yes|YES)
echo "DRY_RUN=${dry_run}; not submitting to Condor."
exit 0
;;
esac
condor_submit "${subfile}"