mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-05 12:21:59 +02:00
[core] Graph: add importGraphContent API
Extract the logic of importing the content of a graph within a graph instance from the graph loading logic. Add `Graph.importGraphContent` and `Graph.importGraphContentFromFile` methods. Use the deserialization API to load the content in another temporary graph instance, to handle the renaming of nodes using the Graph API, rather than manipulating entries in a raw dictionnary.
This commit is contained in:
parent
7eab289d30
commit
4aec741a89
4 changed files with 258 additions and 26 deletions
|
@ -431,3 +431,28 @@ class TestAttributeCallbackBehaviorWithUpstreamDynamicOutputs:
|
|||
assert nodeB.affectedInput.value == 0
|
||||
|
||||
|
||||
class TestAttributeCallbackBehaviorOnGraphImport:
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
registerNodeType(NodeWithAttributeChangedCallback)
|
||||
|
||||
@classmethod
|
||||
def teardown_class(cls):
|
||||
unregisterNodeType(NodeWithAttributeChangedCallback)
|
||||
|
||||
def test_importingGraphDoesNotTriggerAttributeChangedCallbacks(self):
|
||||
graph = Graph("")
|
||||
|
||||
nodeA = graph.addNewNode(NodeWithAttributeChangedCallback.__name__)
|
||||
nodeB = graph.addNewNode(NodeWithAttributeChangedCallback.__name__)
|
||||
|
||||
graph.addEdge(nodeA.affectedInput, nodeB.input)
|
||||
|
||||
nodeA.input.value = 5
|
||||
nodeB.affectedInput.value = 2
|
||||
|
||||
otherGraph = Graph("")
|
||||
otherGraph.importGraphContent(graph)
|
||||
|
||||
assert otherGraph.node(nodeB.name).affectedInput.value == 2
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue