Inputing and manipulating lists of numbers in Hops

I’m quite new to the Rhino API but have lot of python experience. I’m trying to figure out how to input and output lists and trees with the GH Hops component. My research from this thread about accessing trees in Hops suggests it should be working if the access is set correctly. Looking at other Hops tagged posts on the forums shows people are passing in lists of any sort this with ease but since it doesn’t show all the steps there are still gaps in my knowledge.

I’m not sure why my highly simplified python script isn’t working as expected. I’m expecting it to take a list/tree of 12 integers and output it. I want to be able to do more sophisticated calculations and sorting in python with more numbers. Instead I’m getting the error 1. Solution exception:Input string was not in a correct format. I can see in the python terminal the script is receiving the input as expected: {'{0}': [6190, 6170, 6150, 6340, 6260, 6500, 6090, 6510, 6330, 6080, 6530, 6210]} but I’m not sure how to manipulate it. What do I need to change about my code to make it output a list of integers?

@hops.component(
    "/worker",
    name="Worker",
    nickname="Worker",
    description="Basic Template For Python Function",
    inputs=[
        hs.HopsBoolean("Toggle", "T", "Evaluate Function"),
        hs.HopsInteger("Column Length", "L", "List of Column Lengths",access=HopsParamAccess.TREE),
    ],
    outputs=[hs.HopsInteger("Data", "D", "Test output")]
)
def main(t, l):
    if t is True:
        print(l)
        return l
    elif t is False:
        return -1

I’m using: Hops 0.9, ghhops_server 1.4.0, and python 3.8 on mac oxs.

It’s been a couple days since my last post and I’ve kept working on the issue with some local GH experts. None of us were really able to explain the behaviour in depth, but with enough trial-and-error, we were able to get results. I’m posting an update here in the hopes it might be useful to other newcomers who encounter the same Solution exception:Input string was not in a correct format error.

@hops.component(
    "/worker",
    name="Worker",
    nickname="Worker",
    description="Basic Template For Python Function",
    inputs=[
        hs.HopsBoolean("Toggle", "T", "Evaluate Function"),
        hs.HopsInteger("Column Length", "L", "List of Column Lengths", access=HopsParamAccess.TREE),
    ],
    outputs=[hs.HopsString("Data", "D", "Test output")]
)
def main(t,l):
    if t is True:
        val = extract_values(l)
        return val
    elif t is False:
        return -1

def extract_values(numbers):
    return list(numbers.values())[0]

I’m happy that I will be able to work on the integers directly in python but am surpised that I needed to update strings from the component even tho back in GH they seem to be treated as both integers and strings. Anyways, this information should help others keep moving forward in their projects.