Skip to content
Snippets Groups Projects
Commit 696bdc91 authored by Matthew K Defenderfer's avatar Matthew K Defenderfer
Browse files

add help, usage, default values, and more robust option handling

parent 668670d7
No related branches found
No related tags found
1 merge request!11Add submit pol wrapper
#!/bin/bash
# schedule a policy run on gpfs
outdir=$1
policy=$2
nodes=$3
cores=$4
ram=$5
partition=$6
filesystem=${7:-scratch}
time=${8:-60}
outfile=${9}
DIR=$outdir POLICYFILE=$policy FILESYSTEM=${filesystem} OUTFILE=${outfile} && \
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 \
-c $cores \
-n $ntasks \
-t $time \
--mem-per-cpu=$ram \
--mem-per-cpu=$mem_per_cpu \
-p $partition \
./run-mmpol.sh
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment