Skip to content

Commit 981d36c

Browse files
committed
maint: add comments regarding building workflow and save/load config [skip ci]
addresses #2018 (comment) also address #2018 (comment)
1 parent a795760 commit 981d36c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

fmriprep/cli/run.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ def main():
2121
from ..utils.sentry import sentry_setup
2222
sentry_setup()
2323

24+
# CRITICAL Save the config to a file. This is necessary because the execution graph
25+
# is built as a separate process to keep the memory footprint low. The most
26+
# straightforward way to communicate with the child process is via the filesystem.
2427
config_file = config.execution.work_dir / '.fmriprep.toml'
2528
config.to_filename(config_file)
2629

27-
# Call build_workflow(config_file, retval) in a subprocess
30+
# CRITICAL Call build_workflow(config_file, retval) in a subprocess.
31+
# Because Python on Linux does not ever free virtual memory (VM), running the
32+
# workflow construction jailed within a process preempts excessive VM buildup.
2833
with Manager() as mgr:
2934
from .workflow import build_workflow
3035
retval = mgr.dict()
@@ -35,6 +40,9 @@ def main():
3540
retcode = p.exitcode or retval.get('return_code', 0)
3641
fmriprep_wf = retval.get('workflow', None)
3742

43+
# CRITICAL Load the config from the file. This is necessary because the ``build_workflow``
44+
# function executed constrained in a process may change the config (and thus the global
45+
# state of fMRIPrep).
3846
config.load(config_file)
3947

4048
if config.execution.reports_only:

fmriprep/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
pass # context has been already set
8787
finally:
8888
# Defer all custom import for after initializing the forkserver and
89-
# redirecting warnings
89+
# ignoring the most annoying warnings
9090
import os
9191
import sys
9292
import logging

0 commit comments

Comments
 (0)