Skip to content

Commit 150d001

Browse files
committed
feat: dry run
1 parent b183d0d commit 150d001

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

util/run-here.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33
offset=0
4+
dry=false
45
usage() {
56
echo """
67
Run jobs from a slurm submission script's job list on
78
the current interactive node; be nice and keep NUM_JOBS
89
low, since this is only meant for rapid testing
910
10-
USAGE: $0 [JOB_LIST] [LOG_DIR] [NUM_JOBS] [OFFSET]
11+
USAGE: $0 [JOB_LIST] [LOG_DIR] [NUM_JOBS] [OFFSET] [DRY]
1112
JOB_LIST file with job scripts, one per line
1213
LOG_DIR directory for log files (clobbered)
1314
NUM_JOBS the number of parallel jobs to run
1415
OFFSET offset of the first job; NUM_JOBS
1516
consecutive lines will be used
1617
default: $offset
18+
DRY set to '1' for a dry-run (no submission)
19+
default: run immediately
1720
"""
1821
}
1922

@@ -25,6 +28,7 @@ job_list=$1
2528
log_dir=$2
2629
num_jobs=$3
2730
[ $# -ge 4 ] && offset=$4
31+
[ $# -ge 5 ] && dry=true
2832

2933
if [ ! -f "$job_list" ]; then
3034
echo "ERROR: File '$job_list' not found"
@@ -42,12 +46,18 @@ i=0
4246
echo "SUBMITTING:"
4347
tail -n +$((offset + 1)) $job_list | head -n $num_jobs | while IFS= read -r cmd; do
4448
echo "JOB $i: $cmd"
45-
# $cmd > $log_dir/job.$i.out 2> $log_dir/job.$i.err &
49+
if ! $dry; then
50+
$cmd > $log_dir/job.$i.out 2> $log_dir/job.$i.err &
51+
fi
4652
i=$((i+1))
4753
done
48-
echo """
54+
if $dry; then
55+
echo "THIS WAS A DRY-RUN; no jobs submitted"
56+
else
57+
echo """
4958
JOBS SUBMITTED.
5059
- They are running in the backround
5160
- Monitor with \`htop -u $(whoami)\`
5261
- Logs written to \`$log_dir\`
53-
"""
62+
"""
63+
fi

0 commit comments

Comments
 (0)