def _graph_merge(self, other_graph: Dict): newbuilder = GraphBuilder(self.builder.processes) merged = newbuilder.merge(GraphBuilder(other_graph)) newCollection = ImageCollectionClient(self.node_id, merged, self.session) newCollection.bands = self.bands return newCollection
def _graph_merge(self, other_graph: Dict): newbuilder = GraphBuilder(self.builder.processes) merged = newbuilder.merge(GraphBuilder(other_graph)) # TODO: properly update metadata as well? newCollection = ImageCollectionClient(self.node_id, merged, self.session, metadata=self.metadata) return newCollection
def test_merge(self): graph1 = { "sum1": { "arguments": { "data1": { "from_node": "node1" }, "data2": { "from_node": "node3" } }, "process_id": "sum", "result": True } } graph2 = { "sum1": { "arguments": { "data": { "from_node": "node4" }, "data2": [{ "from_node": "node4" }] }, "process_id": "sum", }, "sum2": { "arguments": { "data": { "from_node": "sum1" }, "data2": [{ "from_node": "sum1" }] }, "process_id": "sum", } } builder1 = GraphBuilder(graph1) builder2 = GraphBuilder(graph2) merged = builder1.merge(builder2).processes import json print(json.dumps(merged, indent=2)) self.assertIn("sum1", merged) self.assertIn("sum2", merged) self.assertIn("sum3", merged) self.assertEqual("sum2", merged["sum3"]["arguments"]["data"]["from_node"]) self.assertEqual("sum2", merged["sum3"]["arguments"]["data2"][0]["from_node"])