Skip to content

Fix setting socket values#132

Merged
ElliottKasoar merged 6 commits intoscinode:mainfrom
ElliottKasoar:fix-setter
Dec 2, 2025
Merged

Fix setting socket values#132
ElliottKasoar merged 6 commits intoscinode:mainfrom
ElliottKasoar:fix-setter

Conversation

@ElliottKasoar
Copy link
Collaborator

Resolves #131

As discussed in the above issue, when tasks are run, their links are evaluated, which take precedence over input values directly set, leading to confusing behaviour where you can set and view values that are disregarded.

At the point where these values are set in _set_socket_value, it doesn't seem to be entirely straightforward to determine whether the update is being triggered by an update to the linked value, or if a value that should be linked is being directly set (and so ignored).

My solution has therefore been to check, for inputs, whether the input being changed corresponds to one in the socket links.

As discussed with @superstar54, the test_operation and test_operation_comparison were not testing quite what we expected, since task.execute does not resolve links, which meant that removing result._task.set_inputs({"x": 4, "y": 2}) raises a key error.

I've updated these to run using a local engine, giving the expected behaviour, and added new tests that check that we can set unlinked values, but not linked values.

Copy link
Collaborator

@superstar54 superstar54 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! I add two minor suggestions.

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.54%. Comparing base (d256df2) to head (b9fdda7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #132      +/-   ##
==========================================
+ Coverage   90.46%   90.54%   +0.07%     
==========================================
  Files          73       73              
  Lines        7088     7125      +37     
==========================================
+ Hits         6412     6451      +39     
+ Misses        676      674       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ElliottKasoar and others added 2 commits December 2, 2025 16:07
Co-authored-by: Xing Wang <xingwang1991@gmail.com>
@ElliottKasoar
Copy link
Collaborator Author

ElliottKasoar commented Dec 2, 2025

I think we still need the inputs check, otherwise we get errors e.g.

>       result = engine.run(ng=test_op.build())

tests/test_socket.py:509: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/node_graph/engine/local.py:76: in run
    return self._finalize_graph_success(ng, graph_pid, graph_outputs)
src/node_graph/engine/base.py:102: in _finalize_graph_success
    ng.outputs._set_socket_value(cleaned)
src/node_graph/socket.py:1271: in _set_socket_value
    target._set_socket_value(val)
...
...

E               ValueError: Input graph_outputs.outputs.result_1 has already been set via a link. Please update the linked value in [TaskLink(from="op_ge.result", to="graph_outputs.result_1")]

Co-authored-by: Xing Wang <xingwang1991@gmail.com>
@superstar54 superstar54 self-requested a review December 2, 2025 15:55
Copy link
Collaborator

@superstar54 superstar54 left a comment

Choose a reason for hiding this comment

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

Nice!

@ElliottKasoar ElliottKasoar merged commit 2bd4752 into scinode:main Dec 2, 2025
8 checks passed
@ElliottKasoar ElliottKasoar deleted the fix-setter branch December 2, 2025 17:22
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.

Raise error if setting ignored input

2 participants