[core] Provide node access in expressions#3013
Conversation
On output strings, this allows to directly access the node (as we do
with the lamda).
Same on the command line expression of desc.CommandLineNode.
So instead of:
commandLine = "ffmpeg -i {inputValue} {outputValue}"
We can also do:
commandLine = "ffmpeg -i {node.input.value} {node.output.value}"
There was a problem hiding this comment.
Pull request overview
This PR adds direct node access in string expressions by including the node object itself in the _expVars dictionary. This enhancement allows users to write expressions like {node.input.value} in addition to the existing shorthand {inputValue} or lambda-based approaches.
Changes:
- Added
"node": selfto the_expVarsdictionary in the_buildExpVarsmethod
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self._expVars = { | ||
| "uid": self._uid, | ||
| "nodeCacheFolder": self._internalFolder, | ||
| "node": self, |
There was a problem hiding this comment.
The existing test for expression variables in tests/test_nodes.py::test_expVariables should be extended to verify that the new 'node' key is present in _expVars and that it correctly references the node object. This would ensure that the feature works as intended and prevent regressions.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
|
@fabiencastan I've opened a new pull request, #3014, to work on those changes. Once the pull request is ready, I'll request review from you. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3013 +/- ##
===========================================
+ Coverage 81.99% 82.38% +0.38%
===========================================
Files 69 70 +1
Lines 9315 9359 +44
===========================================
+ Hits 7638 7710 +72
+ Misses 1677 1649 -28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
We have isolated nodes in unit tests.
Move generic attributes formatting in a dedicated unit test.
On output strings, this allows to directly access the node (as we do with the lamda).
Same on the command line expression of desc.CommandLineNode.
So instead of:
commandLine = "ffmpeg -i {inputValue} {outputValue}"
We can also do:
commandLine = "ffmpeg -i {node.input.value} {node.output.value}"