# Taking the outputs of two subworkchains when these are the same

**URL:** <https://aiida.discourse.group/t/taking-the-outputs-of-two-subworkchains-when-these-are-the-same/266>\
**Category:** General Usage\
**Created:** [February 13, 2024, 8:32pm UTC](https://aiida.discourse.group/t/taking-the-outputs-of-two-subworkchains-when-these-are-the-same/266 "2024-02-13T20:32:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgarridoa](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/jgarridoa/32/56_2.png) [@jgarridoa](https://aiida.discourse.group/u/jgarridoa)\
**Post date:** [February 13, 2024, 8:32pm UTC](https://aiida.discourse.group/t/taking-the-outputs-of-two-subworkchains-when-these-are-the-same/266/1 "2024-02-13T20:32:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![t-reents](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/t-reents/32/82_2.png) [@t-reents](https://aiida.discourse.group/u/t-reents)\
**Post date:** [February 13, 2024, 9:05pm UTC](https://aiida.discourse.group/t/taking-the-outputs-of-two-subworkchains-when-these-are-the-same/266/2 "2024-02-13T21:05:29Z")

</div>

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:

```auto
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 `WorkChain`s have an output namespace called `output_parameters`, you can access them via:

```auto
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](https://aiida.readthedocs.io/projects/aiida-core/en/latest/topics/workflows/usage.html#exposing-inputs-and-outputs)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![jgarridoa](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/jgarridoa/32/56_2.png) [@jgarridoa](https://aiida.discourse.group/u/jgarridoa)\
**Post date:** [February 14, 2024, 11:00am UTC](https://aiida.discourse.group/t/taking-the-outputs-of-two-subworkchains-when-these-are-the-same/266/3 "2024-02-14T11:00:42Z")

</div>

Hi

The solution you provide is perfect for what I am looking for

Tanks a lot!

Jaime

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/aiida/original/1X/c417197d3750949351575d03ed03f5e2ad32e649.png) [@system](https://aiida.discourse.group/u/system)\
**Post date:** [February 20, 2024, 7:00am UTC](https://aiida.discourse.group/t/taking-the-outputs-of-two-subworkchains-when-these-are-the-same/266/4 "2024-02-20T07:00:44Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
