Skip to content

Commit 8367ff3

Browse files
committed
defer check of file existence to workflow build stage
1 parent 13f7a1f commit 8367ff3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

sdcflows/fieldmaps.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,8 @@ class FieldmapFile:
229229
@path.validator
230230
def check_path(self, attribute, value):
231231
"""Validate a fieldmap path."""
232-
if not value.is_file():
233-
raise FileNotFoundError(
234-
f'File path <{value}> does not exist, is a broken link, or it is not a file'
235-
)
232+
if not value.is_file() and not value.is_symlink():
233+
raise FileNotFoundError(f'File path <{value}> does not exist, or it is not a file')
236234

237235
if not value.name.endswith(('.nii', '.nii.gz')):
238236
raise ValueError(f'File path <{value}> does not look like a NIfTI file.')
@@ -472,6 +470,13 @@ def get_workflow(self, set_inputs=True, **kwargs):
472470
if self.method in (EstimatorType.MAPPED, EstimatorType.PHASEDIFF):
473471
from .workflows.fit.fieldmap import init_fmap_wf
474472

473+
for f in self.sources:
474+
if not f.path.is_file():
475+
raise FileNotFoundError(
476+
f'File path <{f.path}> does not exist, '
477+
'is a broken link, or it is not a file'
478+
)
479+
475480
kwargs['mode'] = str(self.method).rpartition('.')[-1].lower()
476481
self._wf = init_fmap_wf(**kwargs)
477482
if set_inputs:

0 commit comments

Comments
 (0)