Newer
Older
#!/bin/bash
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
set -euxo pipefail
############################################################
# Default Values #
############################################################
nodes=1
ntasks=16
mem_per_cpu="8G"
time="24:00:00"
partition="amd-hdr100,medium"
outdir="/data/rc/gpfs-policy/data"
policy="./policy/list-path-external"
############################################################
# Help #
############################################################
usage()
{
>&2 cat << EOF
Usage: $0 [ -h ] [ -o | --outdir ] [ -f | --outfile ] [ --with-dirs ]
[ -N | --nodes ] [ -n | --ntasks ] [ -p | --partition]
[ -t | --time ] [ -m | --mem-per-cpu ]
device
EOF
exit 1
}
help()
{
>&2 cat << EOF
Wraps the run-mmpol.sh script for applying a policy file. Must be run directly
as root or via the run-submit-pol-job.py script. The default policy file is
./policy/list-path-external
Usage: $0 [ -h ] [ -o | --outdir ] [ -f | --outfile ] [ --with-dirs ]
[ -N | --nodes ] [ -n | --ntasks ] [ -p | --partition ]
[ -t | --time ] [ -m | --mem ]
device
options:
-h|--help Print this Help.
Required:
device GPFS fileset/directory apply the policy to. Can be
specified as either the name of the fileset or the
full path to the directory
(Examples: scratch, /data/user/[username])
Path:
-o|--outdir Parent directory to save policy output to
(default: /data/rc/gpfs-policy/data)
-f|--outfile Name of the policy output file
(default: "")
Policy Options:
--with-dirs Change to ./policy/list-path-dirplus (default: False)
sbatch options:
-N|--nodes Number of nodes to run the job on (default: 1)
-n|--ntasks Number of tasks (default: 16)
-p|--partition Partition to submit tasks to
(default: amd-hdr100,medium)
-t|--time Max walltime (default: 24:00:00)
-m|--mem-per-cpu RAM per task (default: 8G)
EOF
exit 0
}
args=$(getopt -a -o ho:f:N:n:p:t:m: --long help,outdir:,outfile:,with-dirs,nodes:,ntasks:,partition:,time:,mem: -- "$@")
if [[ $? -gt 0 ]]; then
usage
fi
eval set -- ${args}
while :
do
case $1 in
-h | --help) help ;;
-o | --outdir) outdir=$2 ; shift 2 ;;
-f | --outfile) outfile=$2 ; shift 2 ;;
--with-dirs) policy="./policy/list-path-dirplus" ; shift 1 ;;
-N | --nodes) nodes=$2 ; shift 2 ;;
-n | --ntasks) ntasks=$2 ; shift 2 ;;
-p | --partition) partition=$2 ; shift 2 ;;
-t | --time) time=$2 ; shift 2 ;;
-m | --mem-per-cpu) mem_per_cpu=$2 ; shift 2 ;;
--) shift; break ;;
*) >&2 echo Unsupported option: $1
usage ;;
esac
done
if [[ $# -eq 0 ]]; then
usage
fi
device="$1"
# Ensure gpfs_logdir is set
if [[ -z "$device" ]]; then
echo "Error: Specify either the name of a fileset or a directory path"
usage
fi
DIR=$outdir POLICYFILE=$policy FILESYSTEM=${device} OUTFILE=${outfile} && \
DIR=$DIR POLICYFILE=$POLICYFILE FILESYSTEM=${FILESYSTEM} OUTFILE=${OUTFILE} \
sbatch \
-N $nodes \
-n $ntasks \
--mem-per-cpu=$mem_per_cpu \
-p $partition \
./run-mmpol.sh