Skip to content

Bind dict node inputs by name in %load_node - #5858

Open
omaraldulimay wants to merge 1 commit into
kedro-org:mainfrom
omaraldulimay:fix/load-node-dict-inputs
Open

omaraldulimay wants to merge 1 commit into
kedro-org:mainfrom
omaraldulimay:fix/load-node-dict-inputs

Conversation

@omaraldulimay

Copy link
Copy Markdown

Description

Fixes #5846

%load_node bound the inputs of a node declared with a dict of inputs by position instead of by argument name. For node(train, {"data": "raw", "seed": "params:seed"}, ...) with def train(data, config=None, seed=0), params:seed was loaded into config. For keyword only arguments or **kwargs the generated call failed with TypeError: too many positional arguments.

Development notes

  • _get_node_bound_arguments now binds the declared inputs (node._inputs) instead of node.inputs. For dict inputs the latter is already a list in signature order and has lost the argument names.
  • _prepare_function_call walks the function signature: positional parameters are passed by position up to the first gap, everything after the gap, keyword only parameters and **kwargs entries are passed by keyword. Dict keys that are not in the signature are handled through **kwargs.
  • _NodeBoundArguments.input_params_dict expands **kwargs into one variable per key.
  • Generated output for the issue examples:
    • train: data = catalog.load("raw"), seed = catalog.load("params:seed"), call train(data, seed=seed)
    • report(data, *, title): call report(data, title=title)
  • Added 4 tests in tests/ipython/test_ipython.py (skipped parameter, keyword only, **kwargs, list input regression). The 3 dict tests fail without the fix and pass with it.
  • pytest tests/ipython: 88 passed, 1 skipped (pre-existing skip). ruff format --check and mypy --strict on the changed module are clean.

Developer Certificate of Origin

All commits are signed off.

Checklist

  • Read the contributing guidelines
  • Linked to a relevant GitHub issue
  • Signed off each commit with a DCO
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the RELEASE.md file
  • Added tests to cover my changes

Drafted with the help of Claude Code and reviewed by me.

🤖 Generated with Claude Code

The generated cells and call for a node declared with a dict of inputs
used the positional order of node.inputs, which loses the argument names.
Use the declared inputs so dict keys map to argument names, and build the
call positionally up to the first gap and by keyword after, including
keyword only arguments and **kwargs.

Fixes kedro-org#5846

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Omar Aldulimay <120497558+omaraldulimay@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

%load_node binds dict inputs by position, loading datasets into the wrong arguments

1 participant