Return workflow output to calling script

I would like to access the output of a node from the calling script after the workflow has run. e.g

# Create Node
mynode = pe.Node(MyInterface(), name='mynode')

# Create workflow
workflow = pe.Workflow('myworkflow')
workflow.add_nodes([mynode])

# Run workflow
workflow.run()

# Try to access output (result) of mynode
print workflow.get_node('mynode').get_output('myoutput')  # Returns None as the result has been reset

If I step through the worfkow.run() in debug mode, it appears that this value is temporarily stored in mynode.result but is cleared in the cleanup process. Is there anyway I can easily access it after the workflow.run has completed?

@tclose

eg = wf.run()
for node in eg.nodes():
	if node.name == 'mynode':
		print(node.result.outputs.SpecificOutput)
1 Like