Hops CPython multiple outputs

Hey! :slight_smile:

For some reason I cannot properly return multiple outputs. Adding multiple elements in outputs list in the decorator works, but then when I try to return multiple values in the function: there are some issues with it. Do you have an example how to return multiple outputs with Hops component using CPython?

Hi,

First you need to declare two output values within outputs = [] inside the @hops.component[] decorator of your function, and then it - the function - needs to return these value types in the same order!

Yeah, I did that, it worked for me for 2 outputs, but didn’t work for 3 or more. The decorator outputs list works OK - it creates multiple outputs in the component, but these outputs are returning nothing in GH.

This works for me

@hops.component(
    "/decompose",
    name="Decompose",
    nickname="Decomp",
    description="get x,y,z from point",
    inputs=[hs.HopsPoint("Point", "Pt", "Point to decompose")],
    outputs=[
        hs.HopsNumber("x"),
        hs.HopsNumber("y"),
        hs.HopsNumber("z")
    ]
)
def decompose(point):
    return (point.X, point.Y, point.Z)

1 Like

Thank you Steve, I will try this one when I will find some time, and let you know! :slight_smile:

Ok, after many experiments it turns out, that I just needed to Clear Cache to make it work :slight_smile: Thank you for example!