def test_multi_out(): called = {} @graph(out={"out_1": GraphOut(), "out_2": GraphOut()}) def composite_return_mult(): one, two = return_mult() return (one, two) @op def echo(in_one, in_two): called["one"] = in_one called["two"] = in_two @graph def my_graph(): one, two = composite_return_mult() echo(one, two) result = composite_return_mult.execute_in_process() assert result.output_value("out_1") == 1 assert result.output_value("out_2") == 2 result = my_graph.execute_in_process() assert result.success assert result.output_for_node("composite_return_mult", "out_1") == 1 assert result.output_for_node("composite_return_mult", "out_2") == 2 assert called == {"one": 1, "two": 2}
def test_graph_in_graph(): @graph(out=GraphOut()) def inner_composite_add_one(int_1): return add_one(int_1) @graph(out=GraphOut()) def composite_adder(int_1): return inner_composite_add_one(int_1) @graph def my_graph(): composite_adder(return_one()) result = my_graph.execute_in_process() assert result.success assert result.output_for_node("composite_adder") == 2 assert result.output_for_node( "composite_adder.inner_composite_add_one") == 2 assert result.output_for_node( "composite_adder.inner_composite_add_one.add_one") == 2
def test_single_out(): @graph(out=GraphOut()) def composite_return_one(): return return_one() @graph def my_graph(): composite_return_one() result = my_graph.execute_in_process() assert result.success assert result.output_for_node("composite_return_one") == 1
def test_output_for_node_composite(): @op(out={"foo": Out()}) def my_op(): return 5 @graph(out={"bar": GraphOut()}) def my_graph(): return my_op() @graph(out={"baz": GraphOut()}) def my_top_graph(): return my_graph() result = my_graph.execute_in_process() assert result.success assert result.output_for_node("my_op", "foo") == 5 assert result.output_value("bar") == 5 result = my_top_graph.execute_in_process() assert result.output_for_node("my_graph", "bar") == 5 assert result.output_for_node("my_graph.my_op", "foo") == 5 assert result.output_value("baz") == 5
@op def do_something(): pass @op def one(): return 1 @op(ins={"arg1": In(int)}, out=Out(int)) def do_something_else(arg1): return arg1 @graph(out=GraphOut()) def do_two_things(arg1): do_something() return do_something_else(arg1) @op def do_yet_more(arg1): assert arg1 == 1 @graph def do_it_all(): do_yet_more(do_two_things(one()))
from dagster import Out, graph, op from dagster.core.definitions.output import GraphOut @op def do_something(): pass @op(out={"one": Out(int), "two": Out(int)}) def return_multi(): return 1, 2 @graph(out={"one": GraphOut(), "two": GraphOut()}) def do_two_things(): do_something() one, two = return_multi() return (one, two) @op def do_yet_more(arg1, arg2): assert arg1 == 1 assert arg2 == 2 @graph def do_it_all(): one, two = do_two_things() do_yet_more(one, two)