1
1
# # NOTE ##
2
2
# This workflow is derived from the Datalad Handbook
3
3
4
+ # In addition to the positional arguments described in https://pennlinc.github.io/docs/TheWay/RunningDataLadPipelines/#preparing-the-analysis-dataset ,
5
+ # this bootstrap script also takes a /full/path/to/callback.log i.e.,
6
+ # `bash bootstrap-c-pac.sh /full/path/to/BIDS /full/path/to/cpac-container /full/path/to/callback.log`
7
+ # for optimizing memory (see https://fcp-indi.github.io/docs/nightly/user/tutorials/observed_usage for C-PAC optimization tutorial, and see
8
+ # sections marked "C-PAC-specific memory optimization" in this script for details).
9
+
4
10
# # Ensure the environment is ready to bootstrap the analysis workspace
5
11
# Check that we have conda installed
6
12
# conda activate
@@ -23,7 +29,7 @@ set -e -u
23
29
24
30
25
31
# # Set up the directory that will contain the necessary directories
26
- PROJECTROOT=${PWD} /c-pac-1.8.3
32
+ PROJECTROOT=${PWD} /c-pac-1.8.4
27
33
if [[ -d ${PROJECTROOT} ]]
28
34
then
29
35
echo ${PROJECTROOT} already exists
37
43
fi
38
44
39
45
40
- # # Check the BIDS input
46
+ # C-PAC-specific memory optimization
47
+ CALLBACK_LOG=$3
48
+ # ----------------------------------
49
+
50
+
41
51
BIDSINPUT=$1
42
52
if [[ -z ${BIDSINPUT} ]]
43
53
then
109
119
cd ${PROJECTROOT} /analysis
110
120
datalad install -d . --source ${PROJECTROOT} /pennlinc-containers
111
121
122
+
123
+ # C-PAC-specific memory optimization ---------
124
+ if [[ ! -z " ${CALLBACK_LOG} " ]]; then
125
+ ln $CALLBACK_LOG code/runtime_callback.log
126
+ fi
127
+ # --------------------------------------------
128
+
129
+
112
130
# # the actual compute job specification
113
131
cat > code/participant_job.sh << "EOT "
114
132
#!/bin/bash
@@ -173,16 +191,31 @@ datalad get -n "inputs/data/${subid}"
173
191
# ------------------------------------------------------------------------------
174
192
# Do the run!
175
193
176
- datalad run \
177
- -i code/c-pac_zip.sh \
178
- -i code/RBC_pipeline.yml \
179
- -i inputs/data/${subid} \
180
- -i inputs/data/*json \
181
- -i pennlinc-containers/.datalad/environments/cpac-1-8-3/image \
182
- --explicit \
183
- -o ${subid}_c-pac-1.8.3.zip \
184
- -m "C-PAC:1.8.3 ${subid}" \
185
- "bash ./code/c-pac_zip.sh ${subid}"
194
+ # C-PAC-specific memory optimization --------------------------------
195
+ if [[ -f code/runtime_callback.log ]]
196
+ then
197
+ datalad run \
198
+ -i code/c-pac_zip.sh \
199
+ -i code/runtime_callback.log \
200
+ -i inputs/data/${subid} \
201
+ -i inputs/data/*json \
202
+ -i pennlinc-containers/.datalad/environments/cpac-1-8-4/image \
203
+ --explicit \
204
+ -o ${subid}_c-pac-1.8.4.zip \
205
+ -m "C-PAC:1.8.4-dev ${subid}" \
206
+ "bash ./code/c-pac_zip.sh ${subid}"
207
+ # -------------------------------------------------------------------
208
+ else
209
+ datalad run \
210
+ -i code/c-pac_zip.sh \
211
+ -i inputs/data/${subid} \
212
+ -i inputs/data/*json \
213
+ -i pennlinc-containers/.datalad/environments/cpac-1-8-4/image \
214
+ --explicit \
215
+ -o ${subid}_c-pac-1.8.4.zip \
216
+ -m "C-PAC:1.8.4-dev ${subid}" \
217
+ "bash ./code/c-pac_zip.sh ${subid}"
218
+ fi
186
219
187
220
# file content first -- does not need a lock, no interaction with Git
188
221
datalad push --to output-storage
@@ -210,20 +243,40 @@ set -e -u -x
210
243
211
244
subid="$1"
212
245
mkdir -p ${subid}_outputs
213
- singularity run --cleanenv \
214
- -B ${PWD} \
215
- -B ${PWD}/${subid}_outputs:/outputs \
216
- pennlinc-containers/.datalad/environments/cpac-1-8-3/image \
217
- inputs/data \
218
- /outputs \
219
- participant \
220
- --preconfig rbc-options \
221
- --skip_bids_validator \
222
- --n_cpus 4 \
223
- --mem_gb 32 \
224
- --participant_label "$subid"
225
-
226
- 7z a ${subid}_c-pac-1.8.3.zip ${subid}_outputs
246
+ # C-PAC-specific memory optimization -----------------------------
247
+ if [[ -f code/runtime_callback.log ]]
248
+ then
249
+ singularity run --cleanenv \
250
+ -B ${PWD} \
251
+ -B ${PWD}/${subid}_outputs:/outputs \
252
+ pennlinc-containers/.datalad/environments/cpac-1-8-4/image \
253
+ inputs/data \
254
+ /outputs \
255
+ participant \
256
+ --preconfig rbc-options \
257
+ --skip_bids_validator \
258
+ --n_cpus 4 \
259
+ --mem_gb 32 \
260
+ --participant_label "$subid" \
261
+ --runtime_usage=code/runtime_callback.log \
262
+ --runtime_buffer=30
263
+ # ----------------------------------------------------------------
264
+ else
265
+ singularity run --cleanenv \
266
+ -B ${PWD} \
267
+ -B ${PWD}/${subid}_outputs:/outputs \
268
+ pennlinc-containers/.datalad/environments/cpac-1-8-4/image \
269
+ inputs/data \
270
+ /outputs \
271
+ participant \
272
+ --preconfig rbc-options \
273
+ --skip_bids_validator \
274
+ --n_cpus 4 \
275
+ --mem_gb 32 \
276
+ --participant_label "$subid"
277
+ fi
278
+
279
+ 7z a ${subid}_c-pac-1.8.4.zip ${subid}_outputs
227
280
rm -rf ${subid}_outputs
228
281
229
282
EOT
0 commit comments