[core] plugins: Move validateNodeDesc from __init__.py to plugins.py

The validation of the node descriptions will be handled directly within
the `NodePlugin` objects and there is thus no need for this method to
exist outside of plugins.py.
This commit is contained in:
Candice Bentéjac 2025-05-07 15:25:40 +01:00
parent 1531e11b83
commit fa3cb8c4d6
2 changed files with 35 additions and 35 deletions

View file

@ -19,7 +19,7 @@ try:
except Exception: except Exception:
pass pass
from meshroom.core.plugins import ProcessEnv from meshroom.core.plugins import validateNodeDesc, ProcessEnv
from meshroom.core.submitter import BaseSubmitter from meshroom.core.submitter import BaseSubmitter
from meshroom.env import EnvVar, meshroomFolder from meshroom.env import EnvVar, meshroomFolder
from . import desc from . import desc
@ -128,40 +128,6 @@ def loadClasses(folder, packageName, classType):
return classes return classes
def validateNodeDesc(nodeDesc: desc.Node) -> list:
"""
Check that the node has a valid description before being loaded. For the description
to be valid, the default value of every parameter needs to correspond to the type
of the parameter.
An empty returned list means that every parameter is valid, and so is the node's description.
If it is not valid, the returned list contains the names of the invalid parameters. In case
of nested parameters (parameters in groups or lists, for example), the name of the parameter
follows the name of the parent attributes. For example, if the attribute "x", contained in group
"group", is invalid, then it will be added to the list as "group:x".
Args:
nodeDesc: description of the node
Returns:
errors: the list of invalid parameters if there are any, empty list otherwise
"""
errors = []
for param in nodeDesc.inputs:
err = param.checkValueTypes()
if err:
errors.append(err)
for param in nodeDesc.outputs:
if param.value is None:
continue
err = param.checkValueTypes()
if err:
errors.append(err)
return errors
class Version: class Version:
""" """
Version provides convenient properties and methods to manipulate and compare versions. Version provides convenient properties and methods to manipulate and compare versions.

View file

@ -8,6 +8,40 @@ from pathlib import Path
from meshroom.common import BaseObject from meshroom.common import BaseObject
from meshroom.core import desc from meshroom.core import desc
def validateNodeDesc(nodeDesc: desc.Node) -> list:
"""
Check that the node has a valid description before being loaded. For the description
to be valid, the default value of every parameter needs to correspond to the type
of the parameter.
An empty returned list means that every parameter is valid, and so is the node's description.
If it is not valid, the returned list contains the names of the invalid parameters. In case
of nested parameters (parameters in groups or lists, for example), the name of the parameter
follows the name of the parent attributes. For example, if the attribute "x", contained in group
"group", is invalid, then it will be added to the list as "group:x".
Args:
nodeDesc: description of the node.
Returns:
errors: the list of invalid parameters if there are any, empty list otherwise
"""
errors = []
for param in nodeDesc.inputs:
err = param.checkValueTypes()
if err:
errors.append(err)
for param in nodeDesc.outputs:
if param.value is None:
continue
err = param.checkValueTypes()
if err:
errors.append(err)
return errors
class ProcessEnv(BaseObject): class ProcessEnv(BaseObject):
""" """
Describes the environment required by a node's process. Describes the environment required by a node's process.