[ui/core] Add Validators paradigm#3088
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3088 +/- ##
===========================================
+ Coverage 83.56% 83.72% +0.15%
===========================================
Files 81 83 +2
Lines 10322 10418 +96
===========================================
+ Hits 8626 8722 +96
Misses 1696 1696 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5c972ee to
3559a29
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces an attribute “validators” mechanism in meshroom.core and wires it through to the QML UI so invalid attributes and nodes can be visually flagged and warned about on submit.
Changes:
- Add reusable attribute validators (
NotEmptyValidator,RangeValidator) and expose validation state/messages on runtime attributes/nodes. - Update Graph Editor QML to display per-attribute and per-node warning indicators (orange styling + tooltip messages).
- Add tests and a test node description to exercise the new validation behavior.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
meshroom/core/desc/validators.py |
Adds validator interfaces/helpers and two concrete validators. |
meshroom/core/desc/attribute.py |
Extends attribute description classes to accept validators=. |
meshroom/core/attribute.py |
Executes validators and exposes validation-related properties to the UI layer. |
meshroom/core/node.py |
Adds node-level hasInvalidAttribute property + change signal emission. |
meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml |
Adds per-attribute warning icon/border and tooltip changes. |
meshroom/ui/qml/GraphEditor/Node.qml |
Adds node-level warning icon and orange selection/border when warnings exist. |
meshroom/ui/qml/Application.qml |
Adds a warning dialog when submitting graphs containing nodes with warnings. |
tests/nodes/test/nodeValidators.py |
Adds a test node description that uses validators. |
tests/test_attributes.py |
Adds tests for NotEmpty and Range validation behavior. |
meshroom/common/PySignal.py |
Allows ClassSignal(...) to accept args/kwargs (for typed-signal parity). |
meshroom/core/graph.py |
Adds a new attributeValueChanged signal (currently only declared). |
meshroom/ui/qml/Utils/format.js |
Guards plainToHtml for falsy inputs. |
meshroom/ui/qml/Utils/Colors.qml |
Adds a warning color constant. |
meshroom/ui/commands.py |
Refactors attribute set to go through a single attribute reference. |
Comments suppressed due to low confidence (1)
meshroom/core/desc/attribute.py:4
typesis imported but not used in this module. Please remove the unused import to keep the file clean (and to avoid failing lint checks if/when they are enabled).
import ast
import os
import re
from collections.abc import Iterable
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def _hasDisplayableShape(self): | ||
| """ |
There was a problem hiding this comment.
name is declared twice on BaseNode (first as constant=True, then again later with notify=nodeNameChanged). The earlier declaration is redundant and can be misleading; please remove the duplicate name = Property(str, getName, constant=True) to keep a single source of truth for the Qt property.
3559a29 to
b4dfda0
Compare
| try: | ||
| return self._desc.validValue(self.node) | ||
| except Exception as exc: | ||
| if not self.node.isCompatibilityNode: |
There was a problem hiding this comment.
I can't see a corresponding check on the new code ?
| expressionApplied = Signal() | ||
|
|
||
| errorMessageChanged = Signal() | ||
| errorMessages = Property(Variant, lambda self: self.getErrorMessages(), notify=errorMessageChanged) |
There was a problem hiding this comment.
I can't see that signal emitted ?
There was a problem hiding this comment.
It's needed because it's used internally by Qml. If not set, an error occure:
QQmlExpression: Expression file:///s/apps/users/lambertni/packages/meshroom/lambertni/repo/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml:28:5 depends on non-NOTIFYable properties:
| expressionApplied = Signal() | ||
|
|
||
| errorMessageChanged = Signal() | ||
| errorMessages = Property(Variant, lambda self: self.getErrorMessages(), notify=errorMessageChanged) |
There was a problem hiding this comment.
Shouldn't we have some caching here ? I guess getErrorMessages() is called many times, even if the attribute value did not change.
There was a problem hiding this comment.
I tried to use caching, but I failed trying to keep the same robustness. Problems with connect/disconnect, undo/redo
It seems that signal have to be cared manually in a lot of places to be reactive on any user actions.
For now it's the more robust version i manage to have in a reasonable dev time.
Alxiice
left a comment
There was a problem hiding this comment.
If I read well validValue is not used anymore so is it possible to add a @deprecated.depreciateParam on it (like for the "group" attribute) and maybe check where it is used ?
7a48c71 to
7a67e84
Compare
Description
Alicevision related PR
Add a standard way to validate the attribute value.
It add a way to apply validators to an attribute description and to represent in the UI when these attributes are not valid.
Validators
Validators usage (can be a lambda)
Features list