Skip to content

Commit

Permalink
update LSF support, add PBS support (untested) #88
Browse files Browse the repository at this point in the history
  • Loading branch information
skoren committed Jul 25, 2024
1 parent 40126bd commit bba6f8d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
22 changes: 22 additions & 0 deletions src/profiles/slurm-sge-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ sge=$SGE_ROOT
# Test for LSF: if LSF_ENVDIR exists in the environment, assume LSF works.
lsf=$LSF_ENVDIR

# Test for PBS; if we have pbsnodes binary
pbs=$(which pbsnodes 2> /dev/null)

# Check Slurm status.
#
Expand Down Expand Up @@ -126,6 +128,26 @@ elif [ "x$lsf" != "x" ] ; then
} \
END { print stat }')

elif [ "x$pbs" != "x" ]; then
jobstatus=$(qstat -f "$jobid" | \
awk \
'BEGIN { stat="running" } \
/job_state/ {state=$NF} /exit_status/ {exit_status=$NF} \
END { \
if (state == "R") { stat="running" } \
else if (state == "Q") { stat="running" } \
else if (state == "H") { stat="running" } \
else if (state == "T") { stat="running" } \
else if (state == "W") { stat="running" } \
else if (state == "S") { stat="running" } \
else if (state == "B") { stat="running" } \
else if (state == "E") { stat="running" } \
else if (state == "C") { \
if (exit_status == 0) { stat="success" } \
else { stat="failed" } \
} \
else { stat="failed" } \
print stat }')

# Otherwise, do what? Fail!
else
Expand Down
28 changes: 26 additions & 2 deletions src/profiles/slurm-sge-submit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ mkdir -p batch-scripts/
# Slurm: if sinfo is present, assume slurm works.
# SGE: if SGE_ROOT exists in the environment, assume SGE works.
# LSF: if LSF_ENVDIR exists in the environment, assume LSF works.
# PBS: if pbsnodes present, assume PBS works
#
slurm=$(which sinfo 2> /dev/null)
sge=$SGE_ROOT
lsf=$LSF_ENVDIR
pbs=$(which pbsnodes 2> /dev/null)

##########
#
Expand Down Expand Up @@ -141,17 +143,39 @@ elif [ "x$lsf" != "x" ] ; then
else
mem=$(dc -e "3 k ${mem_gb} 1048576 * p")
fi
mem_per_thread=$(dc -e "0 k ${mem} ${n_cpus} / p")

jobid=$(bsub -R "span[hosts=1] rusage[mem=${mem}]" -n ${n_cpus} -oo batch-scripts/${jobid}.${rule_n}.${jobidx}.out "$@" | grep -oE "Job <[0-9]+>" | awk '{print $2}' | tr -d '<>')
jobid=$(bsub -R \"span[hosts=1] rusage[mem=${mem_per_thread}]\" -n ${n_cpus} -oo batch-scripts/${jobid}.${rule_n}.${jobidx}.out "$@" | sed -E 's/.*<([0-9]+)>.*/\1/')
if [ "x$jobid" = "x" ]; then
exit 1
fi

echo > batch-scripts/${jobid}.${rule_n}.${jobidx}.submit \
bsub -R \"span[hosts=1] rusage[mem=${mem_per_thread}]\" -n ${n_cpus} -oo batch-scripts/${jobid}.${rule_n}.${jobidx}.out "$@"

# Submit to PBS.
# Other options:
# -A account
# -q queue
# -N job name
# -e err-out
# -o out-out
#
elif [ "x$pbs" != "x" ] ; then
jobid=$(qsub -j oe -l select=1:ncpus=${n_cpus}:mem=${mem_gb}gb:walltime=${time_h}:00:00 -o batch-scripts/${jobid}.${rule_n}.${jobidx}.out "$@" | cut -d. -f1)
if [ "x$jobid" = "x" ]; then
exit 1
fi

echo > batch-scripts/${jobid}.${rule_n}.${jobidx}.submit \
bsub -R "span[hosts=1] rusage[mem=${mem}]" -n ${n_cpus} -oo batch-scripts/${jobid}.${rule_n}.${jobidx}.out "$@"
qsub -j oe -l select=1:ncpus=${n_cpus}:mem=${mem_gb}gb:walltime=${time_h}:00:00 -o batch-scripts/${jobid}.${rule_n}.${jobidx}.out "$@"

##########
#
# Otherwise, fail.
#
else
echo "Error: unknown grid, only Slurm, SGE, LSF, and PBS are supported. Please check your environment or use --local instead"
exit 1
fi

Expand Down
9 changes: 3 additions & 6 deletions src/verkko.sh
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,8 @@ while [ $# -gt 0 ] ; do
elif [ "$opt" = "--bwa" ] ; then bwa=$arg; shift
elif [ "$opt" = "--samtools" ] ; then samtools=$arg; shift
elif [ "$opt" = "--local" ] ; then grid="local";
elif [ "$opt" = "--sge" ] ; then grid="slurm-sge";
elif [ "$opt" = "--slurm" ] ; then grid="slurm-sge";
elif [ "$opt" = "--lsf" ] ; then grid="lsf";
elif [ "$opt" = "--grid" ] ; then grid="slurm-sge-lsf-pbs";
elif [ "$opt" = "--slurm" ] ; then grid="slurm-sge-lsf-pbs";
elif [ "$opt" = "--local-memory" ] ; then local_mem=$arg; shift
elif [ "$opt" = "--local-cpus" ] ; then local_cpus=$arg; shift
elif [ "$opt" = "--snakeopts" ] ; then snakeopts=$arg; shift
Expand Down Expand Up @@ -888,9 +887,7 @@ if [ "x$help" = "xhelp" -o "x$errors" != "x" ] ; then
echo " --local-memory Specify the upper limit on memory to use, in GB, default 64"
echo " --local-cpus Specify the number of CPUs to use, default 'all'"
echo ""
echo " --sge Enable Sun Grid Engine support."
echo " --slurm Enable Slurm support."
echo " --lsf Enable IBM Spectrum LSF support."
echo " --grid Enable Grid support (SGE, Slurm, PBS, and LSF are supported)."
echo ""
echo " --snakeopts <string> Append snakemake options in \"string\" to the"
echo " snakemake command. Options MUST be quoted."
Expand Down

0 comments on commit bba6f8d

Please sign in to comment.