Skip to content

Commit 0594f59

Browse files
committed
[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.
1 parent 724e7fb commit 0594f59

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

meshroom/core/graphIO.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,13 @@ def _serializeAttribute(self, attribute: Attribute) -> Any:
200200
Serialize `attribute` (recursively for list/groups) and deal with attributes being connected
201201
to nodes that are not part of the partial list of nodes to serialize.
202202
"""
203-
# If the attribute is connected to a node that is not in the list of nodes to serialize,
204-
# the link expression should not be serialized.
205-
if attribute.isLink and attribute.getLinkParam().node not in self.nodes:
203+
linkParam = attribute.getLinkParam()
204+
205+
if linkParam is not None:
206+
# Use standard link serialization if upstream node is part of the serialization.
207+
if linkParam.node in self.nodes:
208+
return attribute.getExportValue()
209+
# Skip link serialization otherwise.
206210
# If part of a list, this entry can be discarded.
207211
if isinstance(attribute.root, ListAttribute):
208212
return None

tests/test_graphIO.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,20 @@ def test_serializeAllNodesIsSimilarToStandardSerialization(self):
243243
assert compareGraphsContent(graph, graphA)
244244
assert compareGraphsContent(graphA, graphB)
245245

246+
def test_listAttributeToListAttributeConnectionIsSerialized(self):
247+
graph = Graph("")
248+
249+
with registeredNodeTypes([NodeWithListAttributes]):
250+
nodeA = graph.addNewNode(NodeWithListAttributes.__name__)
251+
nodeB = graph.addNewNode(NodeWithListAttributes.__name__)
252+
253+
graph.addEdge(nodeA.listInput, nodeB.listInput)
254+
255+
otherGraph = Graph("")
256+
otherGraph._deserialize(graph.serializePartial([nodeA, nodeB]))
257+
258+
assert otherGraph.node(nodeB.name).listInput.linkParam == otherGraph.node(nodeA.name).listInput
259+
246260
def test_singleNodeWithInputConnectionFromNonSerializedNodeRemovesEdge(self):
247261
graph = Graph("")
248262

0 commit comments

Comments
 (0)