Skip to content

Commit c66ae8e

Browse files
oestebanyarikoptic
andcommitted
enh: include @yarikoptic's suggestions
Co-authored-by: Yaroslav Halchenko <[email protected]>
1 parent fc90f82 commit c66ae8e

File tree

2 files changed

+80
-5
lines changed

2 files changed

+80
-5
lines changed

docs/apps/datalad.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ we will need to ensure the following settings are observed:
2727
* the uid who is *executing MRIQC* within the container must
2828
have sufficient permissions to write in the tree.
2929

30+
!!! tip "Check *ReproNim* if the suggestions here did not work"
31+
32+
The actions suggested here are relatively fundamental, and your
33+
settings may showcase specific circumstances that render them
34+
insufficient.
35+
For a more detailed discussion about orchestrating containers, version
36+
control, and reproducible pipelines, please check
37+
[the *ReproNim* guidelines](https://www.repronim.org/).
38+
39+
In the particular case of *MRIQC*, please consider updating (if necessary)
40+
and fetching the required data before execution and then
41+
add the `--no-datalad-get` argument to workaround issues with
42+
*DataLad*.
43+
3044
### Setting a regular user's execution uid
3145

3246
If the execution uid does not match the uid of the user who installed

docs/apps/docker.md

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ The Docker Engine provides mounting filesystems into the container with the `-v`
101101
where the trailing `:ro` specifies that the mount is read-only.
102102
The mount permissions modifiers can be omitted, which means the mount
103103
will have read-write permissions.
104+
105+
!!! warning "*Docker for Windows* requires enabling Shared Drives"
106+
107+
On *Windows* installations, the `-v` argument will not work
108+
by default because it is necessary to enable shared drives.
109+
Please check on this [Stackoverflow post](https://stackoverflow.com/a/51822083) how to enable them.
110+
104111
In general, you'll want to at least provide two mount-points:
105112
one set in read-only mode for the input data and one read/write
106113
to store the outputs:
@@ -133,7 +140,48 @@ $ docker run -ti --rm \
133140
-w /work # override default directory
134141
```
135142

136-
*BIDS Apps* relying on [TemplateFlow](https://www.templateflow.org)
143+
!!! tip "Best practices"
144+
145+
The [*ReproNim* initiative](https://www.repronim.org/)
146+
distributes materials and documentation of best practices
147+
for containerized execution of neuroimaging workflows.
148+
Most of these are organized within the
149+
[*YODA* (Yoda's Organigram on Data Analysis)](https://github.com/myyoda) principles.
150+
151+
For example, mounting `$PWD` into `$PWD` and setting that path
152+
as current working directory can effectively resolve many issues.
153+
This strategy may be combined with the above suggestion about
154+
the application's work directory as follows:
155+
156+
``` {.shell hl_lines="4 5 9"}
157+
$ docker run -ti --rm \
158+
-v path/to/data:/data:ro \
159+
-v path/to/output:/out \
160+
-v $PWD:$PWD \
161+
-w $PWD \ # DO NOT confuse with the application's work directory
162+
nipreps/fmriprep:<latest-version> \
163+
/data /out/out \
164+
participant
165+
-w $PWD/work
166+
```
167+
168+
Mounting `$PWD` may be used with YODA so that all necessary *parts*
169+
in execution are reachable from under `$PWD`.
170+
This effectively
171+
(i) makes it easy to *transfer* configurations from
172+
*outside* the container to the *inside* execution runtime;
173+
(ii) the *outside*/*inside* filesystem trees are homologous, which
174+
makes post-processing and orchestration easier;
175+
(iii) execution in shared systems is easier as everything is
176+
sort of *self-contained*.
177+
178+
In addition to mounting `$PWD`, other advanced practices
179+
include mounting specific configuration files (for example, a
180+
[*Nipype* configuration file](https://miykael.github.io/nipype_tutorial/notebooks/basic_execution_configuration.html))
181+
into the appropriate paths within the container.
182+
183+
184+
*BIDS Apps* relying on [*TemplateFlow*](https://www.templateflow.org)
137185
for atlases and templates management may require
138186
the *TemplateFlow Archive* be mounted from the host.
139187
Mounting the *Archive* from the host is an effective way
@@ -152,13 +200,26 @@ $ docker run -ti --rm \
152200
-w /work
153201
```
154202

155-
!!! warning "*Docker for Windows* requires enabling Shared Drives"
203+
!!! danger "Sharing the *TemplateFlow* cache can cause race conditions in parallel execution"
156204

157-
On *Windows* installations, the `-v` argument will not work
158-
by default because it is necessary to enable shared drives.
159-
Please check on this [Stackoverflow post](https://stackoverflow.com/a/51822083) how to enable them.
205+
When sharing the *TemplateFlow* *HOME* folder across several parallel
206+
executions against a single filesystem, these instance will likely
207+
attempt to fetch unavailable templates without sufficient time between
208+
actions for the data to be fully downloaded (in other words,
209+
data downloads will be *racing* each other).
210+
211+
To resolve this issue, you will need to make sure all necessary
212+
templates are already downloaded within the cache folder.
213+
If the *TemplateFlow Client* is properly installed in your system,
214+
this is possible with the following command line
215+
(example shows how to fully download `MNI152NLin2009cAsym`:
216+
217+
``` Shell
218+
$ templateflow get MNI152NLin2009cAsym
219+
```
160220

161221
### Running containers as a user
222+
162223
By default, Docker will run the container with the
163224
user id (uid) **0**, which is reserved for the default **root**
164225
account in *Linux*.

0 commit comments

Comments
 (0)