Join the Kedro community

M
M
D
M
M

Node definition requires name parameter

hey all,

I noticed something that when i define the following node:

node(
    func=sample_func,
    # name="sample_func"    -> does not work when this is commented
    inputs="epubdf",
    outputs="result"
)

and then run this test:
kedro_session.run(node_names=['sample_func'])
I get an error saying name doesnt exists but when i specify name parameter in node itself it works. I thought if i don't provide it, name would be equal to func name itself, no?

1
M
F
J
9 comments

Node name is optional, so if you haven't specified it, it will be None

I see, would it make sense to make it default to func.__<i><code>name</code></i>__ ? Or was there a reason why it wasn't?

The name was just added for visualisation in Kedro Viz and has no functional purpose.

hmm but session run uses it somehow. if i wanna run a single node in my pipeline, it breaks

would it make sense to make it default to func.__<i><code>name</code></i>__ ?

it's been discussed, it's a backwards-incompatible change but I actually think we should do it, have a look at https://github.com/kedro-org/kedro/issues/3575

Thanks, that's what i hit now with not able to run a single node unless name param is specified. I also run the kedro registry describe __ default __ which returns func names so i thought it was working but tests fail. Reading the thread, i also see it has other issues with default as well so i guess for now i'll put the names manually 😄

The simple reason for this is, you can use the same function for different node and that default wouldn't work.

Kedro need unique nodes to sort out the execution orders, so behind the scene it generate some default name to make this work.

You will get error if you try to define the same node name for more than 1 node too.

Makes sense. Thanks for the explanation

Add a reply
Sign up and join the conversation on Slack
Join