Skip to content

Commit b183d0d

Browse files
committed
feat: support for testing qtl reheat idempotence
- add `--submit` option to `qtl reheat`, to submit slurm jobs right away, or not - add `util/run-here.sh` to run a list of jobs on the local interactive node; for development testing only, not for chefs
1 parent e7663b2 commit b183d0d

2 files changed

Lines changed: 74 additions & 3 deletions

File tree

bin/qtl-reheat

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ declare -A REHEAT_METHODS=(
1616

1717
# default options
1818
dataset=train
19+
declare -A modes
20+
for key in submit; do
21+
modes[$key]=false
22+
done
1923

2024
# usage
2125
sep="================================================================"
@@ -37,6 +41,8 @@ $(for key in "${!REHEAT_METHODS[@]}"; do printf "%24s %-11s %-s\n" "" "$key" "${
3741
OPTIONAL OPTIONS:
3842
-d [DATASET] unique name for this dataset
3943
default: $dataset
44+
--submit submit the slurm jobs, rather than just
45+
printing the \`sbatch\` command
4046
""" >&2
4147
}
4248
if [ $# -lt 1 ]; then
@@ -48,7 +54,7 @@ fi
4854
inputDir=""
4955
outputDir=""
5056
cmd=""
51-
while getopts "i:o:c:d:h" opt; do
57+
while getopts "i:o:c:d:h-:" opt; do
5258
case $opt in
5359
i) inputDir=$OPTARG ;;
5460
o) outputDir=$OPTARG ;;
@@ -61,6 +67,12 @@ while getopts "i:o:c:d:h" opt; do
6167
usage
6268
exit 101
6369
;;
70+
-)
71+
for key in "${!modes[@]}"; do
72+
[ "$key" == "$OPTARG" ] && modes[$OPTARG]=true && break
73+
done
74+
[ -z "${modes[$OPTARG]-}" ] && printError "unknown option --$OPTARG" && exit 100
75+
;;
6476
*) exit 100 ;;
6577
esac
6678
done
@@ -159,6 +171,12 @@ EOF
159171
echo """
160172
SLURM SCRIPT: $slurmScript
161173
JOB LIST: $jobList
162-
Now submitting!
163174
"""
164-
sbatch $slurmScript
175+
if ${modes['submit']}; then
176+
echo "Now submitting!"
177+
sbatch $slurmScript
178+
else
179+
echo """Run this command to submit:
180+
sbatch $slurmScript
181+
"""
182+
fi

util/run-here.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
offset=0
4+
usage() {
5+
echo """
6+
Run jobs from a slurm submission script's job list on
7+
the current interactive node; be nice and keep NUM_JOBS
8+
low, since this is only meant for rapid testing
9+
10+
USAGE: $0 [JOB_LIST] [LOG_DIR] [NUM_JOBS] [OFFSET]
11+
JOB_LIST file with job scripts, one per line
12+
LOG_DIR directory for log files (clobbered)
13+
NUM_JOBS the number of parallel jobs to run
14+
OFFSET offset of the first job; NUM_JOBS
15+
consecutive lines will be used
16+
default: $offset
17+
"""
18+
}
19+
20+
if [ $# -lt 3 ]; then
21+
usage
22+
exit 2
23+
fi
24+
job_list=$1
25+
log_dir=$2
26+
num_jobs=$3
27+
[ $# -ge 4 ] && offset=$4
28+
29+
if [ ! -f "$job_list" ]; then
30+
echo "ERROR: File '$job_list' not found"
31+
exit 1
32+
fi
33+
34+
if [ $num_jobs -gt 16 ]; then
35+
echo "ERROR: too many jobs!"
36+
exit 1
37+
fi
38+
39+
mkdir -p $log_dir
40+
41+
i=0
42+
echo "SUBMITTING:"
43+
tail -n +$((offset + 1)) $job_list | head -n $num_jobs | while IFS= read -r cmd; do
44+
echo "JOB $i: $cmd"
45+
# $cmd > $log_dir/job.$i.out 2> $log_dir/job.$i.err &
46+
i=$((i+1))
47+
done
48+
echo """
49+
JOBS SUBMITTED.
50+
- They are running in the backround
51+
- Monitor with \`htop -u $(whoami)\`
52+
- Logs written to \`$log_dir\`
53+
"""

0 commit comments

Comments
 (0)