diff options
author | Candice Bentéjac <candice.bentejac@gmail.com> | 2022-10-21 17:54:17 +0300 |
---|---|---|
committer | Candice Bentéjac <candice.bentejac@gmail.com> | 2022-10-21 17:54:17 +0300 |
commit | 10844747f0eefef7c10c81689e5d87abfc0eb31a (patch) | |
tree | c9d4729ae30515d7a7092d63f50f4120d34e0741 | |
parent | c9ade6c0c3d3a602ebfca17c3e21a1c0190bba4b (diff) |
[core] Do not write outputs, internal folder and parallelization in templates
For every node, the only information that is kept when saving a
template are the non-default input attributes' values as well as the
node's position.
The unit test checking the templates' nodes is updated to stop taking
outputs into account.
-rw-r--r-- | meshroom/core/graph.py | 21 | ||||
-rw-r--r-- | tests/test_templatesVersion.py | 5 |
2 files changed, 10 insertions, 16 deletions
diff --git a/meshroom/core/graph.py b/meshroom/core/graph.py index 601e6b90..4ad528fd 100644 --- a/meshroom/core/graph.py +++ b/meshroom/core/graph.py @@ -1206,7 +1206,7 @@ class Graph(BaseObject): if template: data = { Graph.IO.Keys.Header: self.header, - Graph.IO.Keys.Graph: self.getNonDefaultAttributes() + Graph.IO.Keys.Graph: self.getNonDefaultInputAttributes() } else: data = { @@ -1220,20 +1220,22 @@ class Graph(BaseObject): if path != self._filepath and setupProjectFile: self._setFilepath(path) - def getNonDefaultAttributes(self): + def getNonDefaultInputAttributes(self): """ - Instead of getting all the inputs/outputs attribute keys, only get the keys of + Instead of getting all the inputs attribute keys, only get the keys of the attributes whose value is not the default one. + The output attributes, UIDs, parallelization parameters and internal folder are + not relevant for templates, so they are explicitly removed from the returned dictionary. Returns: - dict: self.toDict() with all the inputs/outputs attributes with default values removed + dict: self.toDict() with the output attributes, UIDs, parallelization parameters, internal folder + and input attributes with default values removed """ graph = self.toDict() for nodeName in graph.keys(): node = self.node(nodeName) inputKeys = list(graph[nodeName]["inputs"].keys()) - outputKeys = list(graph[nodeName]["outputs"].keys()) for attrName in inputKeys: attribute = node.attribute(attrName) @@ -1241,13 +1243,10 @@ class Graph(BaseObject): if attribute.isDefault and not attribute.isLink: del graph[nodeName]["inputs"][attrName] - for attrName in outputKeys: - attribute = node.attribute(attrName) - # check that attribute is not a link for choice attributes - if attribute.isDefault and not attribute.isLink: - del graph[nodeName]["outputs"][attrName] - + del graph[nodeName]["outputs"] del graph[nodeName]["uids"] + del graph[nodeName]["internalFolder"] + del graph[nodeName]["parallelization"] return graph diff --git a/tests/test_templatesVersion.py b/tests/test_templatesVersion.py index 784d6728..3d391ecf 100644 --- a/tests/test_templatesVersion.py +++ b/tests/test_templatesVersion.py @@ -38,7 +38,6 @@ def test_templateVersions(): currentNodeVersion = meshroom.core.nodeVersion(nodeDesc) inputs = nodeData.get("inputs", {}) - outputs = nodeData.get("outputs", {}) version = nodesVersions.get(nodeType, None) compatibilityIssue = None @@ -50,9 +49,5 @@ def test_templateVersions(): if not CompatibilityNode.attributeDescFromName(nodeDesc.inputs, attrName, value): compatibilityIssue = CompatibilityIssue.DescriptionConflict break - for attrName, value in outputs.items(): - if not CompatibilityNode.attributeDescFromName(nodeDesc.outputs, attrName, value): - compatibilityIssue = CompatibilityIssue.DescriptionConflict - break assert compatibilityIssue is None |