-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbubba
executable file
·86 lines (72 loc) · 1.98 KB
/
bubba
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
#!/bin/bash
# primitive bsub convenience wrapper, see below.
set -euo pipefail
thequeue=long
themem=5000
thetag="bubba"
usegroup=""
nproc=1
logdir=logs
TEST=
while getopts :q:n:m:g:l:t:hT opt
do
case "$opt" in
q)
thequeue=$OPTARG
;;
l)
logdir=$OPTARG
;;
g)
usegroup="-g /$OPTARG"
;;
m)
themem=$OPTARG
;;
n)
nproc=$OPTARG
;;
t)
thetag=$OPTARG
;;
T)
TEST=echo
;;
h)
cat <<EOU
Usage: bubba [options] thecommand [with] [optional] [arguments]
● Primitive bsub wrapper.
● Options can change things like queues, memory, and log file names/destination.
● Use -T to just print the bsub command.
● The command thecommand is checked for existence.
-q queue (default $thequeue)
-m memory (default $themem)
-n nproc (default $nproc)
-g group (default none)
-t thetag (default $thetag)
-l logdir (default $logdir, use "." for current directory)
-T test: show the bsub command, do not run it
EOU
exit
;;
:) echo "Flag $OPTARG needs argument"
exit 1;;
?) echo "Flag $OPTARG unknown" # Yes that's right, $OPTARG. bash bish bosh.
exit 1;;
esac
done
# The OPTIND lines below ensure that the opt-parsed arguments are removed from $@
# (the name of the array where command line arguments are stored in a bash script).
# The remaining trailing arguments are the only ones left; we pass those on to bsub, below.
OPTIND=$(($OPTIND-1))
shift $OPTIND
(( $# == 0 )) && echo "No command to run" && false
! command -v "$1" > /dev/null && echo "Command $1 not found" && false
[[ $thetag =~ " " ]] && echo "No space please: [$thetag]" && false
[[ ! -d $logdir ]] && echo "Not a directory: $logdir" && false
$TEST bsub -n$nproc -R'span[hosts=1]' \
-e "$logdir/eee.$thetag.%J.txt" \
-o "$logdir/ooo.$thetag.%J.txt" \
-q $thequeue $usegroup \
-R"'select[mem>$themem] rusage[mem=$themem]'" -M$themem \
"$@"