Skip to content

Conversation

nicolas-lambert-tc
Copy link
Contributor

@nicolas-lambert-tc nicolas-lambert-tc commented May 22, 2025

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.

Screenshot_2025-05-23_17-35-17

image

Validators

class AttributeValidator(object):

    def __call__(self, node: "Node", attribute: "Attribute") -> tuple[bool, list[str]]: raise NotImplementedError()


class NotEmptyValidator(AttributeValidator):

    def __call__(self, node: "Node", attribute: "Attribute") -> tuple[bool, list[str]]:

        if attribute.value is None or attribute.value == "":
            return error("Empty value are not allowed")
        
        return success()

Validators usage (can be a lambda)

desc.StringParam(
            name="input",
            label="Test input",
            description="",
            value="",
            validators=[
                NotEmptyValidator(),
                lambda node, attribute: success() if attribute == "test" else error("Attribute value should be 'test'")
                ]
        ),

Features list

  • Add the notion of reusable validators
  • Validator embed the error messages
  • Validator can be a lambda
  • An icon with error message appear when an attribute value is invalid (at least one validator return error messages)
  • A node containing an invalid attribute is tagged with an orange icon and the selection rectangle is orange
  • Attribute value is checked every time the attribute value is set (in the Command)
  • A Warning Dialog is displayed before trying to submit a graph where a node is in warning state

Copy link

codecov bot commented May 22, 2025

Codecov Report

Attention: Patch coverage is 94.39252% with 6 lines in your changes missing coverage. Please review.

Project coverage is 78.89%. Comparing base (49ab4b5) to head (48acfec).
Report is 71 commits behind head on develop.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
meshroom/core/desc/validators.py 87.50% 3 Missing ⚠️
meshroom/core/desc/attribute.py 83.33% 2 Missing ⚠️
meshroom/core/attribute.py 96.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2725      +/-   ##
===========================================
+ Coverage    78.57%   78.89%   +0.32%     
===========================================
  Files           48       50       +2     
  Lines         6577     6663      +86     
===========================================
+ Hits          5168     5257      +89     
+ Misses        1409     1406       -3     

☔ View full report in Codecov by Sentry.
📢 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.

@nicolas-lambert-tc nicolas-lambert-tc force-pushed the feature/node-valididy-check branch from aca1a11 to a6e26b9 Compare May 23, 2025 15:22
@nicolas-lambert-tc nicolas-lambert-tc added feature new feature (proposed as PR or issue planned by dev) UI labels May 23, 2025
@nicolas-lambert-tc nicolas-lambert-tc self-assigned this May 23, 2025
@nicolas-lambert-tc nicolas-lambert-tc force-pushed the feature/node-valididy-check branch 2 times, most recently from 458de57 to 404056d Compare June 4, 2025 14:34
@nicolas-lambert-tc nicolas-lambert-tc marked this pull request as ready for review June 5, 2025 06:52
@nicolas-lambert-tc nicolas-lambert-tc force-pushed the feature/node-valididy-check branch 2 times, most recently from 528c611 to 2a34f27 Compare June 5, 2025 07:18
@fabiencastan fabiencastan added this to the Meshroom 2025.1.0 milestone Jun 14, 2025
@nicolas-lambert-tc nicolas-lambert-tc force-pushed the feature/node-valididy-check branch from 7154a48 to 88227fb Compare June 16, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature new feature (proposed as PR or issue planned by dev) UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants