def test_operation_links_multiple(self, sum_op, square_op, negative_op): # # (y) --> (n1) # my_func sum (n) --> (num) square # (x) --> (n2) # def my_func(x: int, y: int) -> (int, int): return y, x my_op = operation(my_func, output_names=("y", "x"))() workflow = Workflow() # workflow.add_operations(sum_op, square_op, negative_op, my_op) workflow.add_operations(my_op, sum_op, square_op, negative_op) link1 = (my_op, sum_op, "y", "n1") link2 = (my_op, sum_op, "x", "n2") link3 = (sum_op, square_op, "sum", "n") link4 = (square_op, negative_op, "square", "num") workflow.add_link(my_op, sum_op, "y", "n1") workflow.add_link(my_op, sum_op, "x", "n2") workflow.add_link(sum_op, square_op, "sum", "n") workflow.add_link(square_op, negative_op, "square", "num") # assert workflow.operation_links(my_op) == [link1, link2] # assert workflow.operation_links(sum_op) == [link3] # assert workflow.operation_links(square_op) == [link4] # assert workflow.operation_links(negative_op) == [] workflow._pretty_print() dask_graph, end_ids = workflow.as_dask_graph() # test execution results = workflow.execute_synchronous(x=3, y=5)
def test_two_ops_to_one_op(self, negative_op, square_op, sum_op): workflow = Workflow() workflow.add_operations(negative_op, square_op, sum_op) workflow.add_link(negative_op, sum_op, "negative", "n1") workflow.add_link(square_op, sum_op, "square", "n2") print(workflow.get_inbound_links(sum_op)) #from dask import visualize #visualize(workflow.as_dask_graph()[0], filename="/home/ihumphrey/graph") graph = workflow.as_dask_graph()[0] print(graph) for k, op in graph.items(): print(k, op[0].node.name) from dask.threaded import get negative_op.filled_values.update(num=3) square_op.filled_values.update(n=4) print(get(graph, '0')) # WHY is this an issue? Complains that sum missing required 'n2'