mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-20 12:36:29 +02:00
Add "minimal" mode for template files
Add a specific option to save a graph as a template ("Save As Template") in "minimal" mode. This mode only saves, for each node in the graph, the input and output attributes whose values differ from the default ones. Any attribute that is not serialized in the saved template file is assumed to have its default value. If a conflict is detected on a node when opening the template file, it is logged but solved automatically. The goal of this minimal mode is to prevent template files from needing an update every single time a modification (may it be minor or major) is done on a node description. Templates can thus follow node changes and still be usable.
This commit is contained in:
parent
1f800aefd5
commit
c44b2a8c00
4 changed files with 90 additions and 11 deletions
|
@ -1393,7 +1393,7 @@ class CompatibilityNode(BaseNode):
|
|||
issueDetails = Property(str, issueDetails.fget, constant=True)
|
||||
|
||||
|
||||
def nodeFactory(nodeDict, name=None):
|
||||
def nodeFactory(nodeDict, name=None, template=False):
|
||||
"""
|
||||
Create a node instance by deserializing the given node data.
|
||||
If the serialized data matches the corresponding node type description, a Node instance is created.
|
||||
|
@ -1437,9 +1437,10 @@ def nodeFactory(nodeDict, name=None):
|
|||
compatibilityIssue = CompatibilityIssue.VersionConflict
|
||||
# in other cases, check attributes compatibility between serialized node and its description
|
||||
else:
|
||||
# check that the node has the exact same set of inputs/outputs as its description
|
||||
if sorted([attr.name for attr in nodeDesc.inputs]) != sorted(inputs.keys()) or \
|
||||
sorted([attr.name for attr in nodeDesc.outputs]) != sorted(outputs.keys()):
|
||||
# check that the node has the exact same set of inputs/outputs as its description, except if the node
|
||||
# is described in a template file, in which only non-default parameters are saved
|
||||
if not template and (sorted([attr.name for attr in nodeDesc.inputs]) != sorted(inputs.keys()) or \
|
||||
sorted([attr.name for attr in nodeDesc.outputs]) != sorted(outputs.keys())):
|
||||
compatibilityIssue = CompatibilityIssue.DescriptionConflict
|
||||
# verify that all inputs match their descriptions
|
||||
for attrName, value in inputs.items():
|
||||
|
@ -1463,5 +1464,7 @@ def nodeFactory(nodeDict, name=None):
|
|||
if not internalFolder and nodeDesc:
|
||||
logging.warning("No serialized output data: performing automatic upgrade on '{}'".format(name))
|
||||
node = node.upgrade()
|
||||
elif template: # if the node comes from a template file and there is a conflict, it should be upgraded anyway
|
||||
node = node.upgrade()
|
||||
|
||||
return node
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue