-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_submission.sh
executable file
·145 lines (119 loc) · 3.65 KB
/
check_submission.sh
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
#! /bin/bash
###
### Macro to check the stderr and stderr files of the ntuple submission on HTCondor to see if errors have occurred.
###
Errors=0
function clusternumber {
n_size=7
end_size=6
let sum=$n_size+$end_size
let start=${#1}-$sum
echo ${1:$start:$n_size}
}
function join {
local IFS="$1"
shift
echo "$*"
}
function err_to_out {
let n=${#1}-3
echo "${1:0:$n}out"
}
function remove_procId {
let n=${#1}-5
echo "${1:0:$n}"
}
function err_checker {
err_check=$(./output_checker.py -i $1 -e)
if [[ $(join $err_check) != $(join c l e a n) ]]; then #not proud of this, but it works
echo "An unknown error has been detected in ${1}:"
echo $err_check
let Errors=$Errors+1
fi
}
function out_checker {
high_out=$(err_to_out $1)
out_check=$(./output_checker.py -i $high_out -o)
if [[ $(join $out_check) != $(join c l e a n) ]]; then #stil not proud of this, but it works
echo "Unexpected behavior has been detected in ${high_out}:"
echo $out_check
let Errors=$Errors+1
fi
}
function log_checker {
log_file=$1
log_check=$(./output_checker.py -i $log_file -l)
if [[ $(join $log_check) != $(join c l e a n) ]]; then #stil not proud of this, but it works
echo "Unexpected behavior has been detected in ${log_file}:"
echo $log_check
let Errors=$Errors+1
fi
}
echo "checking status of submitted files"
read -p "year: " year
read -p "isMC [y/n]: " isMC
if [ $isMC = "y" ]; then
read -p "isBkg [y/n]: " isBkg
if [ $isBkg = "y" ]; then
read -p "isQCD [y/n]: " isQCD
if [ $isQCD = "y" ]; then
sample="MC_QCD_${year}"
else
sample="MC_TTbar_${year}"
fi
else
sample="MC_signal_${year}"
fi
else
read -p "isData (JetHT) [y/n]: " isData
if [ $isData = "y" ]; then
sample="data_${year}"
else
sample="SingleMuon_${year}"
fi
fi
echo "sample = ${sample}"
p=$(./global_paths.py -g SUBMISSIONLOGS) ## get location of submission logs via global_paths.py
dirs=$(ls -d "${p}tmp_${sample}_"*)
for dir in $dirs; do
echo "checking sample: ${dir}"
let n=${#dir}
#errs=$(ls ${dir}"/"*".err")
errs=$(ls ${dir}"/"*".0.err")
max=-1
high_err=""
for err in $errs; do
num=$(clusternumber $err)
[[ $num -gt $max ]] && max=$num
if [[ $max -eq $num ]]; then
high_err=$err
fi
done
if [ $max -eq -1 ]; then
echo "no maximal cluster number could be deduced!"
exit 1
fi
err_files=$(ls $(remove_procId ${high_err})*.err)
n_errs=0
for errf in $err_files; do
err_checker $errf ## check stderr
out_checker $errf ## check stdout
let n_errs=$n_errs+1
done
logf=$(remove_procId ${high_err})log
log_checker $logf ## check log
n_files=$(./output_checker.py -i ${dir}/submit.sub -n)
if [ $n_errs -ne $n_files ]; then
echo
echo "----------------------------------------------------------------------------------------------------------------------------------"
echo "WARNING!! The number of foreseen output files (${n_files}) is different that the number of stderr/stdout files (${n_errs}) !!"
echo "----------------------------------------------------------------------------------------------------------------------------------"
echo
fi
echo
done
if [[ $Errors -ne 0 ]]; then
echo "There were ${Errors} issues found in the latest submission of ${sample}!"
else
echo "The last submission of ${sample} returned no errors!"
fi