Skip to content

Output attributes : Keep saved template value instead of node description#3132

Open
servantftransperfect wants to merge 1 commit into
developfrom
dev/attributeTemplate
Open

Output attributes : Keep saved template value instead of node description#3132
servantftransperfect wants to merge 1 commit into
developfrom
dev/attributeTemplate

Conversation

@servantftransperfect

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request preserves output expression templates when loading nodes from saved project files, ensuring that node type description changes only affect new nodes. It also corrects the parameter order in validateIncomingConnection and removes a list-connection restriction in AttributePin.qml. Feedback suggests moving the _expressionTemplate assignment logic to Attribute._setValue to support nested attributes inside a GroupAttribute, and removing the corresponding asymmetrical list-connection restriction in outputDropArea within AttributePin.qml for consistent drag-and-drop behavior.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread meshroom/core/attribute.py Outdated
Comment on lines +41 to +45
attr._setValue(value)
# For output expression attributes loaded from a file, store the expression template
# so that description changes on the node type only affect new nodes.
if isOutput and description.isExpression and isinstance(value, str):
attr._expressionTemplate = value

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The current implementation of storing the _expressionTemplate in attributeFactory does not work for nested attributes inside a GroupAttribute.

When a GroupAttribute is loaded from a file, attributeFactory is called for the group itself with the serialized dictionary. The child attributes are initialized with value=None in GroupAttribute._initValue (so their _expressionTemplate remains None), and then their values are updated later via _setValue inside GroupAttribute._setValue. Since _setValue does not update _expressionTemplate, any nested output expression attributes will lose their templates.

Suggestion

Move this logic into Attribute._setValue so that it automatically captures the expression template whenever an output expression attribute is set with a template string (which can be identified by checking if the string contains '{'). This fixes the issue for both flat and nested attributes, and simplifies attributeFactory.

For example, in Attribute._setValue (around line 209):

if self.isOutput and self._desc.isExpression and isinstance(value, str) and "{" in value:
    self._expressionTemplate = value
Suggested change
attr._setValue(value)
# For output expression attributes loaded from a file, store the expression template
# so that description changes on the node type only affect new nodes.
if isOutput and description.isExpression and isinstance(value, str):
attr._expressionTemplate = value
attr._setValue(value)

|| !validIncomingConnection // Connection is not allowed
|| drag.source.nodeItem === inputDragTarget.nodeItem // Connection between attributes of the same node
|| drag.source.isList && childrenRepeater.count // Source/target are lists but target already has children
|| drag.source.connectorType === "input" // Refuse to connect an "input pin" on another one (input attr can be connected to input attr, but not the graphical pin)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Removing the restriction drag.source.isList && childrenRepeater.count from inputDropArea is a good improvement, as it allows connecting list attributes even if the target list already has children (which are properly cleared during connection anyway).

However, there is an asymmetrical check in outputDropArea (around line 375 in the codebase, currently outside this diff) that was not updated:
|| (drag.source.isList && childrenRepeater.count) // Source/target are lists but target already has children

In outputDropArea (on the output pin), drag.source is the input pin (target of the connection) and childrenRepeater belongs to root (the output pin / source of the connection). This means the check incorrectly blocks connecting a list input to a list output if the source output list already has children (which is the normal state for computed outputs!).

To ensure consistent behavior regardless of the drag-and-drop direction, this restriction should also be removed from outputDropArea in a follow-up or as part of this PR.

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.32%. Comparing base (d73790a) to head (61294dc).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
meshroom/core/attribute.py 81.25% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3132      +/-   ##
===========================================
- Coverage    85.33%   85.32%   -0.01%     
===========================================
  Files           73       73              
  Lines        11414    11430      +16     
===========================================
+ Hits          9740     9753      +13     
- Misses        1674     1677       +3     

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

child_attr = attr._value.get(key)
if child_attr is not None:
_captureExpressionTemplates(child_attr, child_value)
except (KeyError, AttributeError):
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.

1 participant