https://prefect.io logo
#prefect-community
Title
# prefect-community
t

tkanas

05/12/2020, 4:28 PM
Hello! I am having a particular problem with Prefect flows. When I create an extremely simple flow, with a single task (can be anything, just the identity function is fine), but pass in a parameter that is a NamedTuple with more than one entry, it doesn't parse the keys of the NamedTuple correctly. Instead of expanding them like a dictionary, it treats them all as a single entity. I'm happy to provide example code if needed.
z

Zachary Hughes

05/12/2020, 4:35 PM
Hi @tkanas, a reproducible example would be fantastic!
t

tkanas

05/12/2020, 4:37 PM
Copy code
@task
def fake_task(spec):
    return spec

with Flow('bla') as flow:
    param_1_specs = Parameter('param_1_specs')
    res = fake_task(param_1_specs)

class Complex(NamedTuple):
    r: int
    i: int

param_values={'param_1_specs': Complex(r=1, i=1)}

flow_result = flow.run(**param_values)
z

Zachary Hughes

05/12/2020, 4:38 PM
Thank you! Taking a look now.
After some digging, it looks like this issue is on our radar. A couple of notes: • as an immediate way to move forward, you should be able to use a dot dict instead of a NamedTuple • we have an issue open for this at the link below. If you have any opinions about the correct solution or your use case, we'd love to hear them here. https://github.com/PrefectHQ/prefect/issues/2118
t

tkanas

05/12/2020, 4:59 PM
Thank you!
z

Zachary Hughes

05/12/2020, 4:59 PM
Sure thing! Let us know if you have any more questions/issues. 🙂