Skip to content

Add the node's function name to NodeSnapshot#5663

Merged
jitu5 merged 6 commits into
mainfrom
feat/add-func-name-snapshot
Jul 15, 2026
Merged

Add the node's function name to NodeSnapshot#5663
jitu5 merged 6 commits into
mainfrom
feat/add-func-name-snapshot

Conversation

@jitu5

@jitu5 jitu5 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #5653.

get_project_snapshot exposes each node's name, namespace, tags, inputs and outputs, but not the name of the underlying function. Kedro-Viz needs the function name when reading the graph from the snapshot instead of a live KedroSession (kedro-org/kedro-viz#2265):

  • to reconstruct its existing node IDs, which are a hash of the node's string form (which includes the function name), avoiding a breaking change for anything keyed on those IDs

Development notes

  • Added func_name: str to NodeSnapshot, populated in _node_to_snapshot from Node._func_name, the readable function name Kedro already derives internally (the same one kedro registry describe prints). The value is available at snapshot-build time, so no extra project loading is needed.
  • Updated the inspection docs (NodeSnapshot field list and example) and the GET /snapshot example response in the serving docs.
  • Tests: extended the NodeSnapshot instantiation and _node_to_snapshot tests, and the snapshot endpoint test now asserts func_name appears in the JSON payload.

Note on the constructor: func_name is added as a required field, second in NodeSnapshot, so it sits next to name in serialized output. This changes the signature for any code that constructs NodeSnapshot positionally, likely rare, since snapshots are produced by Kedro and all internal call sites use keyword arguments. Happy to make it keyword-only (field(kw_only=True)) or give it a default if preferred.

Developer Certificate of Origin

We need all contributions to comply with the Developer Certificate of Origin (DCO). All commits must be signed off by including a Signed-off-by line in the commit message. See our wiki for guidance.

If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.

Checklist

  • Read the contributing guidelines
  • Signed off each commit with a Developer Certificate of Origin (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
  • Checked if this change will affect Kedro-Viz, and if so, communicated that with the Viz team

Signed-off-by: Jitendra Gundaniya <jitendra_gundaniya@mckinsey.com>
@jitu5
jitu5 marked this pull request as ready for review July 13, 2026 13:38
Comment thread kedro/inspection/models.py Outdated
"""

name: str
func_name: str

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func_name inserted as a required positional field silently corrupts field values for any pre-existing positional NodeSnapshot(...) call (values shift by one field with no error). Should be field(kw_only=True) or given a default as you proposed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll make func_name required but keyword-only so existing positional fields cannot silently shift.

Comment thread kedro/inspection/snapshot.py Outdated
jitu5 and others added 2 commits July 14, 2026 15:58
Comment thread tests/inspection/test_node_pipeline_snapshot.py
Comment thread kedro/inspection/snapshot.py Outdated
…a test for TypeError

Signed-off-by: Jitendra Gundaniya <jitendra_gundaniya@mckinsey.com>

@ElenaKhaustova ElenaKhaustova left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@ravi-kumar-pilla ravi-kumar-pilla left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

@jitu5
jitu5 merged commit 55bde97 into main Jul 15, 2026
32 of 33 checks passed
@jitu5
jitu5 deleted the feat/add-func-name-snapshot branch July 15, 2026 15:29
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.

Add the node's function name to NodeSnapshot in get_project_snapshot

3 participants