fahad
03/29/2022, 5:40 PM@op(out={"branch_1": Out(is_required=False), "branch_2": Out(is_required=False)})
def branching_op():
num = random.randint(0, 1)
if num == 0:
yield Output(1, "branch_1")
else:
yield Output(2, "branch_2")
@op
def branch_1_op(_input):
return "hello"
@op
def branch_2_op(_input):
return "world"
@op
def another_op(_input):
pass
@job
def branching():
branch_1, branch_2 = branching_op()
returned_string_1 = branch_1_op(branch_1)
returned_string_2 = branch_2_op(branch_2)
another_op( ??? ) # should take in either returned_string_1 or returned_string_2
owen
03/29/2022, 5:46 PManother_op([returned_string_1, returned_string_2])
. At runtime, optional outputs that do not get fired will not be part of the list (so, the way it's defined right now, this list would always have a single element at runtime). Inside another_op, you can safely just take the first element of the input list and carry on from there.fahad
03/29/2022, 5:46 PM