Hi everyone.
I have a quick question. Imagine that I use a workchain that submits two subworkchains. I want to retrieve the outputs of the two subworkchains via the big workchain. Hence, I have to use:
self.out_many(
self.exposed_outputs(self.ctx.subworkchain_node_1, subworkchain1)
)
self.out_many(
self.exposed_outputs(self.ctx.subworkchain_node_2 ,subworkchain2)
)
Now, Imagine that unfortunately, subworkchain1 and subworkchain2 have an output with the same name, ‘output_parameters’. I guess that this is a conflict because when writing something like bigworkchain_node.outputs.output_parameters, we have no way to distinguish which one we want, the one corresponding to subworkchain1 or subworkchain2.
Now my question is, how can I solve this issue in a smart way? Is there a way to rename certain outputs of the subworkchains? I am looking forward to read your ideas 
Thanks in advance
Jaime
Hi Jaime,
the expose_outputs and exposed_outputs methods have the namespace argument, which addresses the “issue” that you mentioned. In your example, you could do the following:
class BigWorkChain(WorkChain):
@classmethod
def define(cls, spec):
super().define(spec)
# outline etc.
spec.expose_outputs(subworkchain1, namespace='sub_1')
spec.expose_outputs(subworkchain2, namespace='sub_2')
def results(self):
self.out_many(
self.exposed_outputs(self.ctx.subworkchain_node_1, subworkchain1, namespace='sub_1')
)
self.out_many(
self.exposed_outputs(self.ctx.subworkchain_node_2 ,subworkchain2, namespace='sub_2')
)
Assuming that both WorkChains have an output namespace called output_parameters, you can access them via:
result.outputs.sub_1.output_parameters
result.outputs.sub_2.output_parameters
The following section in the documentation explains this in more detail: Usage — AiiDA 2.5.1.post0 documentation
Hope this helps!
Hi
The solution you provide is perfect for what I am looking for
Tanks a lot!
Jaime