File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ declare -A REHEAT_METHODS=(
1616
1717# default options
1818dataset=train
19+ declare -A modes
20+ for key in submit; do
21+ modes[$key ]=false
22+ done
1923
2024# usage
2125sep=" ================================================================"
@@ -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}
4248if [ $# -lt 1 ]; then
4854inputDir=" "
4955outputDir=" "
5056cmd=" "
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
6678done
159171echo " " "
160172SLURM SCRIPT: $slurmScript
161173JOB 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
Original file line number Diff line number Diff line change 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+ " " "
You can’t perform that action at this time.
0 commit comments