Fazil Topal
05/20/2025, 8:14 PMnode(myfunc, inputs=dict(x="ds1", y=dict(subv="test1", subc="test2"))
Basically i would expect kedro to pass the resolved dict into the node as a dict. Right now it's not possible as kedro complains and wants the values as string. Not really sure how to get around thatdatajoely
05/20/2025, 8:16 PMfunctools
, I’ve long wanted a Literal
operator for thisFazil Topal
05/20/2025, 8:18 PMFazil Topal
05/20/2025, 8:21 PMJuan Luis
05/20/2025, 8:40 PMdatajoely
05/21/2025, 8:33 AMfrom functools import partial, update_wrapper
from kedro.pipeline import node
# Original lambda
add = lambda x, y: x + y
# Partially apply x=10
add_10 = partial(add, 10)
update_wrapper(add_10, add) # Optional, preserves metadata
# Create Kedro node
add_node = node(
func=add_10,
inputs="input_y", # only 'y' is needed now
outputs="output_sum",
name="add_10_node"
)
datajoely
05/21/2025, 8:33 AMdatajoely
05/21/2025, 8:34 AMfrom kedro.pipeline import Literal
so you didn't have to do this hackFazil Topal
05/21/2025, 8:36 AM@node_kwargs(
inputs=dict(
text=ds.TEXT,
models=ModelGroup(
free="master:deepseek-v3-0324::worker:gemini-2.5-flash",
plus="master:gpt-4o::worker:gemini-2.5-pro",
pro="master:claude-sonnet::worker:gemini-2.5-pro",
).to_string(),
prompts=prompt_param,
max_shot=param("max_shot"),
),
outputs=ds.RESPONSE
)
Notice the ModelGroup has to_string
method. I basically serialize this class into json and in the custom Catalog class during the load i deserialize it again. After that for each value i invoke kedro load and return the combine class.
I have my custom node decorator so going towards lambda wasn't easy for me. Happy to get it working due to flexibility and customization in kedro 😄