-
Notifications
You must be signed in to change notification settings - Fork 2
/
create_cromwell_config
executable file
·201 lines (191 loc) · 7.51 KB
/
create_cromwell_config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
set -o errexit
function usage
{
echo ""
echo "usage: create_cromwell_config -o <output.config> -d <outdir> -l <logdir> -G <compute_group> -g <lsf_group> -v <volumes> -h"
echo ""
echo " -o | --output_file output file (required)"
echo " -d | --outdir output directory for workflow (required)"
echo " -l | --logdir logfile directory for workflow (required)"
echo " -G | --compute-group compute group to use for LSF jobs. If not provided,"
echo " will look in the LSF_COMPUTE_GROUP env variable"
echo " -q | --compute-queue LSF queue to run jobs in. If not provided, will"
echo " look in the LSF_COMPUTE_QUEUE env variable"
echo " -g | --lsf-job-group LSF job group to place jobs into"
echo " -v | --volumes disk volumes to mount in LSF jobs. If not provided,"
echo " will look in the LSF_DOCKER_VOLUMES env variable"
echo " -h | --help show help/options"
echo ""
exit 1
}
if [ $# -eq 0 ]; then
echo "No arguments provided"
usage
fi
while [[ ! -z "$1" ]]; do
case $1 in
-o | --outfile ) shift
outfile=$1
;;
-d | --outdir ) shift
outdir=$1
;;
-l | --logdir ) shift
logdir=$1
;;
-G | --compute-group ) shift
compute_group=$1
;;
-q | --compute-queue ) shift
compute_queue=$1
;;
-g | --lsf-job-group ) shift
lsf_group=$1
;;
-v | --volumes ) shift
volumes=$1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
#resolve full paths, make dirs if needed
if [[ ! -d $outdir ]];then
mkdir -p $outdir/cromwell-db
fi
outdir=$(readlink -f $outdir)
if [[ ! -d $logdir ]];then
mkdir -p $logdir
fi
outdir=$(readlink -f $outdir)
#if volumes not provided, then look for env variable
if [[ -z $volumes ]];then
if [[ ! -z $LSF_DOCKER_VOLUMES ]];then
volumes="$LSF_DOCKER_VOLUMES"
fi
fi
#if compute group not provided, then look for env variable
if [[ $compute_group == "" ]];then
if [[ ! -z $LSF_COMPUTE_GROUP ]];then
compute_group=$LSF_COMPUTE_GROUP
else
echo "compute group must be provided if LSF_COMPUTE_GROUP env variable is not set"
exit 1;
fi
fi
#if compute queue not provided, then look for env variable
if [[ $compute_queue == "" ]];then
if [[ ! -z $LSF_COMPUTE_QUEUE ]];then
compute_queue=$LSF_COMPUTE_QUEUE
else
echo "compute queue must be provided if LSF_COMPUTE_QUEUE env variable is not set"
exit 1;
fi
fi
outdir=$(readlink -f $outdir)
logdir=$(readlink -f $logdir)
echo 'include required(classpath("application"))' >$outfile
echo '' >>$outfile
echo 'backend {' >>$outfile
echo ' default = "LSF"' >>$outfile
echo ' providers {' >>$outfile
echo ' LSF {' >>$outfile
echo ' actor-factory = "cromwell.backend.impl.sfs.config.ConfigBackendLifecycleActorFactory"' >>$outfile
echo ' config {' >>$outfile
echo ' runtime-attributes = """' >>$outfile
echo ' Int cpu = 1' >>$outfile
echo ' Int memory_kb = 4096000' >>$outfile
echo ' Int memory_mb = 4096' >>$outfile
echo ' String? docker' >>$outfile
echo ' """' >>$outfile
echo '' >>$outfile
echo ' submit = """' >>$outfile
echo ' LSF_DOCKER_VOLUMES='\'$volumes\'' \' >>$outfile
echo ' LSF_DOCKER_PRESERVE_ENVIRONMENT=false \' >>$outfile
echo ' bsub \' >>$outfile
echo ' -J ${job_name} \' >>$outfile
echo ' -cwd ${cwd} \' >>$outfile
echo ' -o /dev/null \' >>$outfile
echo ' -e '$logdir'/cromwell-%J.err \' >>$outfile
echo ' -a '\''docker(registry.gsc.wustl.edu/apipe-builder/genome_perl_environment:compute1-10)'\'' \' >>$outfile
echo ' -q '$compute_queue' \' >>$outfile
echo ' -G '$compute_group' \' >>$outfile
if [[ ! -z "$lsf_job_group" ]];then
echo ' -g '$lsf_job_group' \' >>$outfile
fi
echo ' -M ${memory_mb}M \' >>$outfile
echo ' -n ${cpu} \' >>$outfile
echo ' -R "span[hosts=1] select[mem>${memory_mb}] rusage[mem=${memory_mb}]" \' >>$outfile
echo ' /bin/bash ${script}' >>$outfile
echo ' """' >>$outfile
echo '' >>$outfile
echo ' submit-docker = """' >>$outfile
echo ' LSF_DOCKER_VOLUMES='\''${cwd}:${docker_cwd} '$volumes''\'' \' >>$outfile
echo ' LSF_DOCKER_PRESERVE_ENVIRONMENT=false \' >>$outfile
echo ' bsub \' >>$outfile
echo ' -J ${job_name} \' >>$outfile
echo ' -cwd ${cwd} \' >>$outfile
echo ' -o /dev/null \' >>$outfile
echo ' -e '$logdir'/cromwell-%J.err \' >>$outfile
echo ' -q '$compute_queue' \' >>$outfile
echo ' -G '$compute_group' \' >>$outfile
if [[ ! -z "$lsf_job_group" ]];then
echo ' -g '$lsf_job_group' \' >>$outfile
fi
echo ' -a "docker0(${docker})" \' >>$outfile
echo ' -M ${memory_mb}M \' >>$outfile
echo ' -n ${cpu} \' >>$outfile
echo ' -R "span[hosts=1] select[mem>${memory_mb}M] rusage[mem=${memory_mb}M]" \' >>$outfile
echo ' /bin/bash ${script}' >>$outfile
echo ' """' >>$outfile
echo '' >>$outfile
echo ' kill = "bkill ${job_id}"' >>$outfile
echo ' docker-kill = "bkill ${job_id}"' >>$outfile
echo ' check-alive = "bjobs -noheader -o stat ${job_id} | /bin/grep '\''PEND\\|RUN'\''"' >>$outfile
echo ' job-id-regex = "Job <(\\d+)>.*"' >>$outfile
echo ' root = "'$outdir'"' >>$outfile
echo ' filesysytems {' >>$outfile
echo ' local {' >>$outfile
echo ' caching {' >>$outfile
echo ' duplication-strategy: [' >>$outfile
echo ' "hard-link", "soft-link", "copy"' >>$outfile
echo ' ]' >>$outfile
echo ' hashing-strategy: "xxh64"' >>$outfile
echo ' fingerprint-size: 10485760' >>$outfile
echo ' }' >>$outfile
echo ' }' >>$outfile
echo ' }' >>$outfile
echo ' }' >>$outfile
echo ' }' >>$outfile
echo ' }' >>$outfile
echo '}' >>$outfile
echo 'workflow-options {' >>$outfile
echo ' workflow-log-dir = "'$logdir'"' >>$outfile
echo '}' >>$outfile
echo 'database {' >>$outfile
echo ' profile = "slick.jdbc.HsqldbProfile$"' >>$outfile
echo ' db {' >>$outfile
echo ' driver = "org.hsqldb.jdbcDriver"' >>$outfile
echo ' url = """' >>$outfile
echo ' jdbc:hsqldb:file:'$outdir'/cromwell-db;' >>$outfile
echo ' shutdown=false;' >>$outfile
echo ' hsqldb.default_table_type=cached;hsqldb.tx=mvcc;' >>$outfile
echo ' hsqldb.result_max_memory_rows=10000;' >>$outfile
echo ' hsqldb.large_data=true;' >>$outfile
echo ' hsqldb.applog=1;' >>$outfile
echo ' hsqldb.lob_compressed=true;' >>$outfile
echo ' hsqldb.script_format=3' >>$outfile
echo ' """' >>$outfile
echo ' connectionTimeout = 120000' >>$outfile
echo ' numThreads = 1' >>$outfile
echo ' }' >>$outfile
echo '}' >>$outfile
echo 'call-caching {' >>$outfile
echo ' enabled = true' >>$outfile
echo ' invalidate-bad-cache-results = true' >>$outfile
echo '}' >>$outfile