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

add dry-run option for testing

parent ce113376
No related branches found
No related tags found
6 merge requests!24Release v0.2.0,!22Update main to rel_v0.1.1-1,!21Fix some merge errors,!20Refactoring run-mmpol scripts,!19BUGFIX: Change ownership to executing USER and group to atlab. Also automatically gzip the log output,!18ENH: Change log storage organization and correctly apply log prefix and metadata to file name
......@@ -12,6 +12,7 @@ outdir="/data/rc/gpfs-policy/data"
policy_file="./policy-def/list-path-external"
device="scratch"
output_log_prefix=""
dry_run=""
############################################################
# Help #
......@@ -33,7 +34,9 @@ Runs mmapplypolicy on the specified device/fileset. The policy file dictates the
Usage: $0 [ -h ] [ -o | --outdir ] [ -f | --output-prefix ] [ -P | --policy-file ] device
options:
-h|--help Print this Help.
-h|--help Print this Help.
--dry-run Do not run the policy command or any command that modifies any files or directories such as
mkdir
Required:
device GPFS fileset/directory apply the policy to. Can be
......@@ -53,7 +56,7 @@ EOF
exit 0
}
args=$(getopt -a -o ho:f:P: --long help,outdir:,output-prefix:,policy-file: -- "$@")
args=$(getopt -a -o ho:f:P: --long help,outdir:,output-prefix:,policy-file:,dry-run -- "$@")
if [[ $? -gt 0 ]]; then
usage
......@@ -67,7 +70,8 @@ do
-h | --help) help ;;
-o | --outdir) outdir=$2 ; shift 2 ;;
-f | --output-prefix) output_log_prefix=$2 ; shift 2 ;;
-P | --policy-file) policy_file=$2 ; shift 2 ;;
-P | --policy-file) policy_file=$2 ; shift 2 ;;
--dry-run) dry_run=true ; shift 1 ;;
--) shift; break ;;
*) >&2 echo Unsupported option: $1
usage ;;
......@@ -86,7 +90,7 @@ if [[ -z "$device" ]]; then
usage
fi
# create default output_log_prefix if not specified in the arguments
# set default output_log_prefix if not specified in the arguments
if [[ -z "$output_log_prefix"]]; then
modified_device=$(echo "$device" | sed -e 's|^/||' -e 's|/$||' -e 's|/|-|g')
output_log_prefix="list-policy_${modified_device}"
......@@ -95,7 +99,6 @@ fi
# create temporary working directory for list aggregation
tmpglobal=$outdir/slurm-tmp-${SLURM_JOBID}
tmpscratch=$outdir/slurm-tmp-${SLURM_JOBID}
mkdir -p $tmpglobal
nodes=`scontrol show hostnames "${SLURM_JOB_NODELIST}" | tr '\n' ',' | sed -e 's/,$//'`
cores="${SLURM_CPUS_PER_TASK}"
......@@ -118,13 +121,17 @@ cmd="mmapplypolicy ${device} -I defer \
# report final command in job log
echo $cmd
# run policy command
$cmd
# tag output file with run metadata
outfile=`ls -t $tmpglobal | head -1`
if [[ "$outfile" != "" ]]
then
mv -n $tmpglobal/$outfile $tmpglobal/../${output_log_prefix}_$filetag
fi
rmdir $tmpglobal
if [[ -z "${dry_run}" ]]; then
mkdir -p $tmpglobal
# run policy command
$cmd
# tag output file with run metadata
outfile=`ls -t $tmpglobal | head -1`
if [[ "$outfile" != "" ]]
then
mv -n $tmpglobal/$outfile $tmpglobal/../${output_log_prefix}_$filetag
fi
rmdir $tmpglobal
fi
\ No newline at end of file
......@@ -14,6 +14,7 @@ partition="amd-hdr100,medium"
outdir="/data/rc/gpfs-policy/data"
policy="./policy-def/list-path-external"
outfile=""
dry_run=""
############################################################
# Help #
......@@ -23,7 +24,7 @@ usage()
>&2 cat << EOF
Usage: $0 [ -h ] [ -o | --outdir ] [ -f | --outfile ] [ --with-dirs ]
[ -N | --nodes ] [ -c | --cores ] [ -p | --partition]
[ -t | --time ] [ -m | --mem-per-cpu ]
[ -t | --time ] [ -m | --mem-per-cpu ] [ --dry_run ]
device
EOF
exit 1
......@@ -38,11 +39,13 @@ as root or via the run-submit-pol-job.py script. The default policy file is
Usage: $0 [ -h ] [ -o | --outdir ] [ -f | --outfile ] [ -P | --policy ]
[ -N | --nodes ] [ -c | --cores ] [ -p | --partition ]
[ -t | --time ] [ -m | --mem ]
[ -t | --time ] [ -m | --mem ] [ --dry-run ]
device
options:
-h|--help Print this Help.
-h|--help Print this Help.
--dry-run Do not submit a Slurm job running the policy. Instead, pass --dry-run to run-mmpol.sh and call
it normally to just print the output to STDOUT
Required:
device GPFS fileset/directory apply the policy to. Can be
......@@ -69,7 +72,8 @@ EOF
exit 0
}
args=$(getopt -a -o ho:f:P:N:c:p:t:m: --long help,outdir:,outfile:,policy:,nodes:,cores:,partition:,time:,mem: -- "$@")
args=$(getopt -a -o ho:f:P:N:c:p:t:m: \
--long help,outdir:,outfile:,policy:,nodes:,cores:,partition:,time:,mem:,dry-run -- "$@")
if [[ $? -gt 0 ]]; then
usage
......@@ -89,6 +93,7 @@ do
-p | --partition) partition=$2 ; shift 2 ;;
-t | --time) time=$2 ; shift 2 ;;
-m | --mem-per-cpu) mem_per_cpu=$2 ; shift 2 ;;
--dry-run) dry_run=true ; shift 1 ;;
--) shift; break ;;
*) >&2 echo Unsupported option: $1
usage ;;
......@@ -108,15 +113,23 @@ if [[ -z "$device" ]]; then
fi
slurm_out="out/pol-%A-$(basename ${policy})-$(basename ${device}).out"
mkdir -p out
run_mmpol_cmd="./run-mmpol.sh -o ${outdir} -f ${outfile} -P ${policy} ${device}"
sbatch \
-N $nodes \
-c $cores \
-t $time \
--mem-per-cpu=$mem_per_cpu \
-p $partition \
-o ${slurm_out} \
"${run_mmpol_cmd}
run_mmpol_cmd_base="./run-mmpol.sh -o ${outdir} -f ${outfile} -P ${policy}"
if [[ -z "${dry_run}" ]]; then
mkdir -p out
run_mmpol_cmd="${run_mmpol_cmd_base} ${device}"
sbatch \
-N $nodes \
-c $cores \
-t $time \
--mem-per-cpu=$mem_per_cpu \
-p $partition \
-o ${slurm_out} \
"${run_mmpol_cmd}"
else
run_mmpol_cmd="${run_mmpol_cmd_base} --dry-run ${device}"
${run_mmpol_cmd}
fi
\ No newline at end of file
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