Skip to content

Commit bba6f8d

Browse files
committed
update LSF support, add PBS support (untested) #88
1 parent 40126bd commit bba6f8d

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

src/profiles/slurm-sge-status.sh

+22
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ sge=$SGE_ROOT
1616
# Test for LSF: if LSF_ENVDIR exists in the environment, assume LSF works.
1717
lsf=$LSF_ENVDIR
1818

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

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

131+
elif [ "x$pbs" != "x" ]; then
132+
jobstatus=$(qstat -f "$jobid" | \
133+
awk \
134+
'BEGIN { stat="running" } \
135+
/job_state/ {state=$NF} /exit_status/ {exit_status=$NF} \
136+
END { \
137+
if (state == "R") { stat="running" } \
138+
else if (state == "Q") { stat="running" } \
139+
else if (state == "H") { stat="running" } \
140+
else if (state == "T") { stat="running" } \
141+
else if (state == "W") { stat="running" } \
142+
else if (state == "S") { stat="running" } \
143+
else if (state == "B") { stat="running" } \
144+
else if (state == "E") { stat="running" } \
145+
else if (state == "C") { \
146+
if (exit_status == 0) { stat="success" } \
147+
else { stat="failed" } \
148+
} \
149+
else { stat="failed" } \
150+
print stat }')
129151

130152
# Otherwise, do what? Fail!
131153
else

src/profiles/slurm-sge-submit.sh

+26-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ mkdir -p batch-scripts/
5252
# Slurm: if sinfo is present, assume slurm works.
5353
# SGE: if SGE_ROOT exists in the environment, assume SGE works.
5454
# LSF: if LSF_ENVDIR exists in the environment, assume LSF works.
55+
# PBS: if pbsnodes present, assume PBS works
5556
#
5657
slurm=$(which sinfo 2> /dev/null)
5758
sge=$SGE_ROOT
5859
lsf=$LSF_ENVDIR
60+
pbs=$(which pbsnodes 2> /dev/null)
5961

6062
##########
6163
#
@@ -141,17 +143,39 @@ elif [ "x$lsf" != "x" ] ; then
141143
else
142144
mem=$(dc -e "3 k ${mem_gb} 1048576 * p")
143145
fi
146+
mem_per_thread=$(dc -e "0 k ${mem} ${n_cpus} / p")
144147

145-
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 '<>')
148+
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/')
149+
if [ "x$jobid" = "x" ]; then
150+
exit 1
151+
fi
152+
153+
echo > batch-scripts/${jobid}.${rule_n}.${jobidx}.submit \
154+
bsub -R \"span[hosts=1] rusage[mem=${mem_per_thread}]\" -n ${n_cpus} -oo batch-scripts/${jobid}.${rule_n}.${jobidx}.out "$@"
155+
156+
# Submit to PBS.
157+
# Other options:
158+
# -A account
159+
# -q queue
160+
# -N job name
161+
# -e err-out
162+
# -o out-out
163+
#
164+
elif [ "x$pbs" != "x" ] ; then
165+
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)
166+
if [ "x$jobid" = "x" ]; then
167+
exit 1
168+
fi
146169

147170
echo > batch-scripts/${jobid}.${rule_n}.${jobidx}.submit \
148-
bsub -R "span[hosts=1] rusage[mem=${mem}]" -n ${n_cpus} -oo batch-scripts/${jobid}.${rule_n}.${jobidx}.out "$@"
171+
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 "$@"
149172

150173
##########
151174
#
152175
# Otherwise, fail.
153176
#
154177
else
178+
echo "Error: unknown grid, only Slurm, SGE, LSF, and PBS are supported. Please check your environment or use --local instead"
155179
exit 1
156180
fi
157181

src/verkko.sh

+3-6
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,8 @@ while [ $# -gt 0 ] ; do
326326
elif [ "$opt" = "--bwa" ] ; then bwa=$arg; shift
327327
elif [ "$opt" = "--samtools" ] ; then samtools=$arg; shift
328328
elif [ "$opt" = "--local" ] ; then grid="local";
329-
elif [ "$opt" = "--sge" ] ; then grid="slurm-sge";
330-
elif [ "$opt" = "--slurm" ] ; then grid="slurm-sge";
331-
elif [ "$opt" = "--lsf" ] ; then grid="lsf";
329+
elif [ "$opt" = "--grid" ] ; then grid="slurm-sge-lsf-pbs";
330+
elif [ "$opt" = "--slurm" ] ; then grid="slurm-sge-lsf-pbs";
332331
elif [ "$opt" = "--local-memory" ] ; then local_mem=$arg; shift
333332
elif [ "$opt" = "--local-cpus" ] ; then local_cpus=$arg; shift
334333
elif [ "$opt" = "--snakeopts" ] ; then snakeopts=$arg; shift
@@ -888,9 +887,7 @@ if [ "x$help" = "xhelp" -o "x$errors" != "x" ] ; then
888887
echo " --local-memory Specify the upper limit on memory to use, in GB, default 64"
889888
echo " --local-cpus Specify the number of CPUs to use, default 'all'"
890889
echo ""
891-
echo " --sge Enable Sun Grid Engine support."
892-
echo " --slurm Enable Slurm support."
893-
echo " --lsf Enable IBM Spectrum LSF support."
890+
echo " --grid Enable Grid support (SGE, Slurm, PBS, and LSF are supported)."
894891
echo ""
895892
echo " --snakeopts <string> Append snakemake options in \"string\" to the"
896893
echo " snakemake command. Options MUST be quoted."

0 commit comments

Comments
 (0)