Skip to content

ENH: More verbose description when a faulty results file is loaded #2920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions nipype/pipeline/engine/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,32 +514,35 @@ def _get_inputs(self):
logger.debug('input: %s', key)
results_file = info[0]
logger.debug('results file: %s', results_file)
results = loadpkl(results_file)
outputs = loadpkl(results_file).outputs
if outputs is None:
raise RuntimeError("""\
Error populating the input "%s" of node "%s": the results file of the source node \
(%s) does not contain any outputs.""" % (key, self.name, results_file))
output_value = Undefined
if isinstance(info[1], tuple):
output_name = info[1][0]
value = getattr(results.outputs, output_name)
value = getattr(outputs, output_name)
if isdefined(value):
output_value = evaluate_connect_function(
info[1][1], info[1][2], value)
else:
output_name = info[1]
try:
output_value = results.outputs.trait_get()[output_name]
output_value = outputs.trait_get()[output_name]
except AttributeError:
output_value = results.outputs.dictcopy()[output_name]
output_value = outputs.dictcopy()[output_name]
logger.debug('output: %s', output_name)
try:
self.set_input(key, deepcopy(output_value))
except traits.TraitError as e:
msg = [
'Error setting node input:',
'Node: %s' % self.name,
'input: %s' % key,
msg = (
e.args[0], '', 'Error setting node input:',
'Node: %s' % self.name, 'input: %s' % key,
'results_file: %s' % results_file,
'value: %s' % str(output_value)
]
e.args = (e.args[0] + "\n" + '\n'.join(msg), )
'value: %s' % str(output_value),
)
e.args = ('\n'.join(msg), )
raise

# Successfully set inputs
Expand Down