From 0594f593f2ff6b71d82611ccd1b3b6375acfd4d7 Mon Sep 17 00:00:00 2001 From: Yann Lanthony Date: Thu, 6 Feb 2025 18:03:00 +0100 Subject: [PATCH] [core][graphIO] PartialSerializer: fix List/GroupAttribute link serialization Ensure attribute input connection is serialized, even for List/GroupAttributes. Note: while connecting GroupAttributes is not yet supported, this will benefit this type of attribute once it is. --- meshroom/core/graphIO.py | 10 +++++++--- tests/test_graphIO.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/meshroom/core/graphIO.py b/meshroom/core/graphIO.py index 5bcd6321..c2cdd508 100644 --- a/meshroom/core/graphIO.py +++ b/meshroom/core/graphIO.py @@ -200,9 +200,13 @@ class PartialGraphSerializer(GraphSerializer): Serialize `attribute` (recursively for list/groups) and deal with attributes being connected to nodes that are not part of the partial list of nodes to serialize. """ - # If the attribute is connected to a node that is not in the list of nodes to serialize, - # the link expression should not be serialized. - if attribute.isLink and attribute.getLinkParam().node not in self.nodes: + linkParam = attribute.getLinkParam() + + if linkParam is not None: + # Use standard link serialization if upstream node is part of the serialization. + if linkParam.node in self.nodes: + return attribute.getExportValue() + # Skip link serialization otherwise. # If part of a list, this entry can be discarded. if isinstance(attribute.root, ListAttribute): return None diff --git a/tests/test_graphIO.py b/tests/test_graphIO.py index 95d72021..b7420691 100644 --- a/tests/test_graphIO.py +++ b/tests/test_graphIO.py @@ -243,6 +243,20 @@ class TestGraphPartialSerialization: assert compareGraphsContent(graph, graphA) assert compareGraphsContent(graphA, graphB) + def test_listAttributeToListAttributeConnectionIsSerialized(self): + graph = Graph("") + + with registeredNodeTypes([NodeWithListAttributes]): + nodeA = graph.addNewNode(NodeWithListAttributes.__name__) + nodeB = graph.addNewNode(NodeWithListAttributes.__name__) + + graph.addEdge(nodeA.listInput, nodeB.listInput) + + otherGraph = Graph("") + otherGraph._deserialize(graph.serializePartial([nodeA, nodeB])) + + assert otherGraph.node(nodeB.name).listInput.linkParam == otherGraph.node(nodeA.name).listInput + def test_singleNodeWithInputConnectionFromNonSerializedNodeRemovesEdge(self): graph = Graph("")