Skip to content

Commit 8579a3c

Browse files
committed
deal reliably with errors while checking hash
1 parent 2c35800 commit 8579a3c

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

nipype/pipeline/plugins/base.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
absolute_import)
88
from builtins import range, object, open
99

10+
import sys
1011
from copy import deepcopy
1112
from glob import glob
1213
import os
1314
import shutil
14-
import sys
1515
from time import sleep, time
16-
from traceback import format_exc
16+
from traceback import format_exception
1717

1818
import numpy as np
1919
import scipy.sparse as ssp
@@ -159,7 +159,7 @@ def run(self, graph, config, updatehash=False):
159159
graph,
160160
result={
161161
'result': None,
162-
'traceback': format_exc()
162+
'traceback': '\n'.join(format_exception(*sys.exc_info()))
163163
}))
164164
else:
165165
if result:
@@ -327,7 +327,7 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
327327
self.proc_pending[jobid] = False
328328
else:
329329
self.pending_tasks.insert(0, (tid, jobid))
330-
logger.info('Finished submitting: %s ID: %d' %
330+
logger.info('Finished submitting: %s ID: %d',
331331
(self.procs[jobid]._id, jobid))
332332
else:
333333
break
@@ -337,11 +337,17 @@ def _local_hash_check(self, jobid, graph):
337337
self.procs[jobid].config['execution']['local_hash_check']):
338338
return False
339339

340-
cached, updated = self.procs[jobid].is_cached()
340+
try:
341+
cached, updated = self.procs[jobid].is_cached()
342+
except Exception:
343+
logger.warning('Error while checking node hash, forcing re-run\n\n%s',
344+
'\n'.join(format_exception(*sys.exc_info())))
345+
return False
346+
341347
logger.debug('Checking hash "%s" locally: cached=%s, updated=%s.',
342348
self.procs[jobid].fullname, cached, updated)
343349
overwrite = self.procs[jobid].overwrite
344-
always_run = self.procs[jobid]._interface.always_run
350+
always_run = self.procs[jobid].interface.always_run
345351

346352
if cached and updated and (overwrite is False or
347353
overwrite is None and not always_run):
@@ -351,8 +357,9 @@ def _local_hash_check(self, jobid, graph):
351357
self._task_finished_cb(jobid, cached=True)
352358
self._remove_node_dirs()
353359
except Exception:
354-
logger.debug('Error skipping cached node %s (%s).',
355-
self.procs[jobid]._id, jobid)
360+
logger.debug('Error skipping cached node %s (%s).\n\n%s',
361+
self.procs[jobid]._id, jobid,
362+
'\n'.join(format_exception(*sys.exc_info())))
356363
self._clean_queue(jobid, graph)
357364
self.proc_pending[jobid] = False
358365
return True
@@ -481,7 +488,7 @@ def _get_result(self, taskid):
481488
taskid, timeout, node_dir))
482489
raise IOError(error_message)
483490
except IOError as e:
484-
result_data['traceback'] = format_exc()
491+
result_data['traceback'] = '\n'.join(format_exception(*sys.exc_info()))
485492
else:
486493
results_file = glob(os.path.join(node_dir, 'result_*.pklz'))[0]
487494
result_data = loadpkl(results_file)

0 commit comments

Comments
 (0)