Skip to content

Commit f6fdd0f

Browse files
Merge pull request #246 from RoanKanninga/master
added custom header (containing projectname in the submitted job)
2 parents 6f804b6 + 639d434 commit f6fdd0f

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
#SBATCH --job-name=${project}_${taskId}
3+
#SBATCH --output=${taskId}.out
4+
#SBATCH --error=${taskId}.err
5+
#SBATCH --partition=${queue}
6+
#SBATCH --time=${walltime}
7+
#SBATCH --cpus-per-task ${ppn}
8+
#SBATCH --mem ${mem}
9+
#SBATCH --nodes ${nodes}
10+
#SBATCH --open-mode=append
11+
12+
ENVIRONMENT_DIR="."
13+
set -e
14+
set -u
15+
#-%j
16+
17+
function errorExitandCleanUp()
18+
{
19+
echo "TRAPPED"
20+
printf "${taskId}\n" > /groups/umcg-gaf/tmp05/logs/${project}.failed
21+
tail -50 ${taskId}.err >> /groups/umcg-gaf/tmp05/logs/${project}.failed
22+
rm /groups/umcg-gaf/tmp05/tmp/${project}/*/tmp_${taskId}*
23+
}
24+
25+
declare MC_tmpFolder="tmpFolder"
26+
declare MC_tmpFile="tmpFile"
27+
28+
function makeTmpDir {
29+
base=$(basename $1)
30+
dir=$(dirname $1)
31+
echo "dir $dir"
32+
echo "base $base"
33+
if [[ -d $1 ]]
34+
then
35+
dir=$dir/$base
36+
fi
37+
myMD5=$(md5sum $0)
38+
IFS=' ' read -a myMD5array <<< "$myMD5"
39+
MC_tmpFolder=$dir/tmp_${taskId}_$myMD5array/
40+
mkdir -p $MC_tmpFolder
41+
if [[ -d $1 ]]
42+
then
43+
MC_tmpFile="$MC_tmpFolder"
44+
else
45+
MC_tmpFile="$MC_tmpFolder/$base"
46+
fi
47+
}
48+
49+
trap "errorExitandCleanUp" ERR
50+
51+
# For bookkeeping how long your task takes
52+
MOLGENIS_START=$(date +%s)
53+
54+
touch ${taskId}.sh.started
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# First cd to the directory with the *.sh and *.finished scripts
2+
<#noparse>
3+
MOLGENIS_scriptsDir=$( cd -P "$( dirname "$0" )" && pwd )
4+
echo "cd $MOLGENIS_scriptsDir"
5+
cd $MOLGENIS_scriptsDir
6+
cd ../
7+
runnumber=`pwd`
8+
echo basename $runnumber
9+
run=$(basename $runnumber)
10+
11+
cd ..
12+
project=`pwd`
13+
projectName=$(basename $project)
14+
cd $MOLGENIS_scriptsDir
15+
if [ -f /groups/umcg-gaf/tmp05/logs/${projectName}.failed ]
16+
then
17+
rm /groups/umcg-gaf/tmp05/logs/${projectName}.failed
18+
rm /groups/umcg-gaf/tmp05/logs/${projectName}.mailed.failed
19+
fi
20+
21+
</#noparse>
22+
23+
touch molgenis.submit.started
24+
25+
26+
# Use this to indicate that we skip a step
27+
skip(){
28+
echo "0: Skipped --- TASK '$1' --- ON $(date +"%Y-%m-%d %T")" >> molgenis.skipped.log
29+
}
30+
31+
<#foreach t in tasks>
32+
#
33+
##${t.name}
34+
#
35+
36+
# Skip this step if step finished already successfully
37+
if [ -f ${t.name}.sh.finished ]; then
38+
skip ${t.name}.sh
39+
echo "Skipped ${t.name}.sh"
40+
else
41+
# Build dependency string
42+
dependenciesExist=false
43+
dependencies="--dependency=afterok"
44+
<#foreach d in t.previousTasks>
45+
if [[ -n "$${d}" ]]; then
46+
dependenciesExist=true
47+
dependencies="<#noparse>${dependencies}</#noparse>:$${d}"
48+
fi
49+
</#foreach>
50+
if ! $dependenciesExist; then
51+
unset dependencies
52+
fi
53+
output=$(sbatch $dependencies ${t.name}.sh)
54+
id=${t.name}
55+
${t.name}=<#noparse>${output##"Submitted batch job "}</#noparse>
56+
echo "$id:$${t.name}"
57+
echo "$id:$${t.name}" >> submitted_jobIDs.txt
58+
fi
59+
60+
61+
62+
</#foreach>
63+
chmod g+w submitted_jobIDs.txt
64+
touch molgenis.submit.finished

0 commit comments

Comments
 (0)