Skip to content

Commit 9dc0480

Browse files
authored
Merge pull request #1966 from mgxd/enh/clean-dir
ENH: Add ``--clean-workdir`` argument
2 parents 66b39aa + a07a68d commit 9dc0480

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

fmriprep/cli/run.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ def get_parser():
244244
g_other = parser.add_argument_group('Other options')
245245
g_other.add_argument('-w', '--work-dir', action='store', type=Path, default=Path('work'),
246246
help='path where intermediate results should be stored')
247+
g_other.add_argument('--clean-workdir', action='store_true', default=False,
248+
help='Clears working directory of contents. Use of this flag is not'
249+
'recommended when running concurrent processes of fMRIPrep.')
247250
g_other.add_argument(
248251
'--resource-monitor', action='store_true', default=False,
249252
help='enable Nipype\'s resource monitoring to keep track of memory and CPU usage')
@@ -508,6 +511,12 @@ def build_workflow(opts, retval):
508511
output_dir = opts.output_dir.resolve()
509512
work_dir = opts.work_dir.resolve()
510513

514+
if opts.clean_workdir:
515+
from niworkflows.utils.misc import clean_directory
516+
build_log.log("Clearing previous fMRIPrep working directory: %s" % work_dir)
517+
if not clean_directory(work_dir):
518+
build_log.warning("Could not clear all contents of working directory: %s" % work_dir)
519+
511520
retval['return_code'] = 1
512521
retval['workflow'] = None
513522
retval['bids_dir'] = str(bids_dir)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ install_requires =
2424
nibabel ~= 3.0.0rc1
2525
nipype >=1.3.1
2626
nitime
27-
niworkflows ~= 1.1.3
27+
niworkflows ~= 1.1.5
2828
numpy
2929
pandas
3030
psutil >=5.4

0 commit comments

Comments
 (0)