-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_after.sh
executable file
·89 lines (67 loc) · 2.15 KB
/
run_after.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
#!/bin/bash
usage (){
echo
echo "usage: $0 create log report for all pipelines ran in interation testing"
echo
echo " -h Print this help "
echo " -j Sends the report to jenkins"
echo " -p Path to the directory containing the cit result"
}
while getopts "p:jh" opt; do
case $opt in
j)
JENKINS=1
;;
p)
path="$OPTARG"
;;
h)
usage
exit 0
;;
\?)
usage
exit 1
;;
esac
done
job_list=$(cat "$path"/scriptTestOutputs/*/chunk/*out | awk -F'=' '{printf(":%s",$2)}'| sed 's/ //g')
tmp_script=$(mktemp)
# for debuging
# job_list=$(cat /tmp/all | awk -F'=' '{printf(":%s",$2)}'| sed 's/ //g')
# tmp_script=/tmp/tata
if [[ -n $JENKINS ]] ; then
## curl call to jenkens server via ssh
SEND_TO_J=$(cat << EOF
JENKINS_URL=https://jenkins.c3g-app.sd4h.ca/job/report_on_full_run/buildWithParameters
ssh ${HOSTNAME} curl -k -X GET --form logfile=@${path}/scriptTestOutputs/cit_out/digest.log "\$JENKINS_URL?token=\$API_TOKEN"
EOF
)
fi
cat > "$tmp_script" << EOF
#!/bin/bash
#SBATCH -d afterany${job_list}
#SBATCH --mem 500M
#SBATCH --time 00:30:00
#SBATCH --output=log_report.log
module load python/3
control_c() {
exit 0
}
latest_dev=$(realpath "${path}/scriptTestOutputs")
mkdir -p \${latest_dev}/cit_out && cd \${latest_dev}/cit_out
trap control_c SIGINT
list=\$(find \${latest_dev} -maxdepth 3 -type d -name 'job_output' | xargs -I@ sh -c "ls -t1 @/*job* | head -n 1 ")
for jl in \$list ; do
out=\$( echo "\$jl" | sed 's|.*scriptTestOutputs/\(.*\)/job_output.*|\1|g' )
echo processing \$out
${path}/genpipes/genpipes/utils/log_report.py --loglevel CRITICAL --tsv \$out.tsv \$jl
done
echo "########################################################" > digest.log
grep -v "COMPLETED\+[[:space:]]\+COMPLETED\+[[:space:]]\+COMPLETED" *tsv \
| grep -v "log_from_job" | grep -e 'TIMEOUT' -e 'FAILED' -e 'OUT_OF_MEMORY' >> digest.log
echo "########################################################" >> digest.log
cat \${SLURM_SUBMIT_DIR}/log_report.log >> digest.log
${SEND_TO_J}
EOF
sbatch -A "${RAP_ID:-def-bourqueg}" "$tmp_script"