fix: clear stale socket references on neighbors in remove_component#11971
Open
chuenchen309 wants to merge 6 commits into
Open
fix: clear stale socket references on neighbors in remove_component#11971chuenchen309 wants to merge 6 commits into
chuenchen309 wants to merge 6 commits into
Conversation
`Pipeline.remove_component` reset only the removed component's own sockets, but left the removed component's name in its neighbors' sockets: a downstream component kept it in its input socket's `senders`, and an upstream component kept it in its output socket's `receivers`. `graph.remove_node` drops the edges but does not touch the socket objects held by the surviving components. These dangling references corrupt pipeline introspection and validation: `Pipeline.inputs()` computes `is_mandatory = socket.is_mandatory and not socket.senders`, so a stale sender hides a now-unconnected mandatory input; and `validate_input` raises a spurious "already connected to component ..." error (naming the deleted component) when that input is fed directly. Strip the removed component's name from its neighbors' sockets, walking the incident edges before `remove_node` while they still carry the socket objects. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@chuenchen309 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…t__ in new tests Matches the existing # type: ignore[attr-defined] convention already used elsewhere in this file for the same dunder-attribute access pattern. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Pipeline.remove_componentresets only the removed component's own sockets,but leaves the removed component's name behind on its neighbors' sockets:
sendersreceiversgraph.remove_nodedrops the edges from the graph, but thesenders/receiverslists live on the socket objects held by the surviving component instances, and
those are never touched.
These dangling references corrupt pipeline introspection and validation:
Pipeline.inputs()computesis_mandatory = socket.is_mandatory and not socket.senders. A stale sender makesnot socket.sendersfalse, so anow-unconnected mandatory input is hidden from
inputs().validate_inputthen raises a spurious"... is already connected to component '<removed>'"error — naming a component that no longer exists — when the usertries to feed that input directly.
Reproduction
Fix
Strip the removed component's name from its neighbors' sockets, walking the
incident edges (which still carry the
from_socket/to_socketobjects) beforeremove_node.Tests
Added two tests in
test/core/pipeline/test_pipeline_base.py(pure Python, noheavy deps) covering the downstream-neighbor
sendersand upstream-neighborreceiverscases. Both fail before the change and pass after. Thedownstream test also asserts
inputs()re-exposes the mandatory input andvalidate_inputno longer raises.ruff check/ruff format --checkpass on the changed files. Added a releasenote under
releasenotes/notes/.Disclosure: I used AI assistance (Claude) to help locate this stale-state bug
and draft the tests. I reviewed the change, ran the suite, and take
responsibility for its correctness.