forked from se2p/FlaPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
array_job.sh
59 lines (49 loc) · 1.93 KB
/
array_job.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
#!/bin/bash
#SBATCH --partition=anywhere
#SBATCH --job-name=flapy
#SBATCH --time=24:00:00
#SBATCH --mem=16GB
#SBATCH --nodes=1-1
#SBATCH --ntasks=1
#SBATCH --array=1-1
n=${SLURM_ARRAY_TASK_ID}
csv_file=$1
csv_line=$(sed "${n}q;d" "${csv_file}")
PROJECT_NAME=$(echo "${csv_line}" | cut -d',' -f1)
PROJECT_URL=$(echo "${csv_line}" | cut -d',' -f2)
PROJECT_HASH=$(echo "${csv_line}" | cut -d',' -f3)
FUNCS_TO_TRACE=$(echo "${csv_line}" | cut -d',' -f4)
TESTS_TO_BE_RUN=$(echo "${csv_line}" | cut -d',' -f5)
NUM_RUNS=$(echo "${csv_line}" | cut -d',' -f6)
LOCAL="/local/hdd/${USER}"
mkdir -p "${LOCAL}/${PROJECT_NAME}"
# Pick a postfix for the repo-dir to allow multiple runs of the same project and the same machine
if [[ ${FUNCS_TO_TRACE} == "" ]]; then
# In case tracing is deactivated, the postfix is a random number.
# (It would be better to choose an unused name within the target directory)
LOCAL_PROJECT_DIR=$(mktemp -d "${LOCAL}/${PROJECT_NAME}/XXXXX")
REPO_POSTFIX=$(basename "${LOCAL_PROJECT_DIR}")
else
# In case tracing is activated, postfix should be consistent accross multiple executions
# , because it might influence the trace -> use hash of funcs-to-trace
REPO_POSTFIX=$(echo "$FUNCS_TO_TRACE" | md5sum | head -c 8)
LOCAL_PROJECT_DIR="${LOCAL}/${PROJECT_NAME}/${REPO_POSTFIX}"
fi
mkdir -p "${LOCAL_PROJECT_DIR}"
echo "Run Jobs for ${PROJECT_NAME}"
echo "URL ${PROJECT_URL}"
echo "Functions to trace: ${FUNCS_TO_TRACE}"
function sighdl {
kill -INT "${srunPid}" || true
}
mkdir -p "/scratch/${USER}/flapy-results/run"
OUT_FILE="/scratch/${USER}/flapy-results/run/${PROJECT_NAME}-${REPO_POSTFIX}.txt"
srun \
--user-cgroups=on \
--output="${OUT_FILE}" \
--error="${OUT_FILE}" \
-- \
./run_execution.sh "${PROJECT_NAME}" "${PROJECT_URL}" "${PROJECT_HASH}" "${FUNCS_TO_TRACE}" "${TESTS_TO_BE_RUN}" "${NUM_RUNS}" "${LOCAL_PROJECT_DIR}" \
& srunPid=$!
trap sighdl INT TERM HUP QUIT
while ! wait; do true; done