Skip to content

Commit b46704f

Browse files
committed
improved hashfiles checks
1 parent 43537aa commit b46704f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

nipype/pipeline/engine/nodes.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,18 @@ def hash_exists(self, updatehash=False):
275275
logger.debug('Node hash value: %s', hashvalue)
276276

277277
if op.exists(outdir):
278+
# Find unfinished hashfiles and error if any
279+
unfinished = glob(op.join(outdir, '_0x*_unfinished.json'))
280+
if unfinished:
281+
raise RuntimeError(
282+
'[Caching Node Error] Found unfinished hashfiles (%d) that indicate '
283+
'that the ``base_dir`` for this node went stale. Please re-run the '
284+
'workflow.' % len(unfinished))
285+
278286
# Find previous hashfiles
279287
hashfiles = glob(op.join(outdir, '_0x*.json'))
280-
if len(hashfiles) > 1: # Remove hashfiles if more than one found
288+
# Remove hashfiles if more than one found or the one found is outdated
289+
if hashfiles and (len(hashfiles) > 1 or hashfiles[0] != hashfile):
281290
logger.info('Removing hashfiles (%s) and forcing node to rerun',
282291
', '.join(['"%s"' % op.basename(h) for h in hashfiles]))
283292
for hf in hashfiles:

0 commit comments

Comments
 (0)