Mark Fickett
03/04/2022, 1:38 AMbranch_1
but then assign branch_2, branch_1 = branching_op()
in my @job
, then I get backwards execution.
# <https://docs.dagster.io/concepts/ops-jobs-graphs/jobs-graphs#conditional-branching>
import random
from dagster import Out, Output, job, op
@op(out={"branch_1": Out(is_required=False), "branch_2": Out(is_required=False)})
def branching_op():
num = 0
if num == 0:
yield Output(1, "branch_1")
else:
yield Output(2, "branch_2")
@op
def branch_1_op(_input):
pass
@op
def branch_2_op(_input):
pass
@job
def branching():
branch_2, branch_1 = branching_op() # Does this always return branch_1, branch_2? Why?
branch_1_op(branch_1)
branch_2_op(branch_2)
alex
03/04/2022, 7:32 PMDoes this always return branch_1, branch_2? Why?The object representing the multiple outputs is a
namedtuple
. You can destructure as you are based on the order of elements in the tuple. The order is determined by the order of the dictionary passed to out
.
The name of the variables you assign to has no effect. You can capture the tuple directly and then key using the names of the outputs though.
outs = branching_op()
branch_1 = outs.branch_1
Mark Fickett
03/04/2022, 8:22 PMalex
03/04/2022, 8:23 PM