https://dagster.io/ logo
Title
s

Sara

09/09/2021, 9:44 AM
Hi there!

I am new to Dagster and I need help.

I need to create a solid that has more than one outlet. I found an example in the documentation but I don't know how to apply it to a pipe.

This is an example of what I want to do, but I get an error trying to put it in the pipeline.

Thanks! :)

from dagster import solid, pipeline, OutputDefinition, Output

@solid(
    output_defs=[
        OutputDefinition(name="first_number"),
        OutputDefinition(name="second_output"),
    ],
)
def multi_output_solid():
    yield Output(5, output_name="first_number")
    yield Output(6, output_name="second_number")

@solid
def add5(first_number):
    result1 = first_number + 10
    return result1

@solid
def add6(second_number):
    result2 = second_number + 10
    return result2

@solid
def total_add(result1, result2):
    total_result = result1 + result2
    return total_result

@pipeline
def my_pipeline():

    first_number = "???" <------
    second_number = "???" <------
    total_add(add5(first_number), add6(second_number))
a

alex

09/09/2021, 2:32 PM
for multiple outputs, we return a namedtuple in the composition function, so you can unpack at assignment:
first_number, second_number = multi_output_solid()
or via the output names:
outs = multi_output_solid()
outs.first_number
outs.second_number
or by index, but unlikely you want to do that
1
s

Sara

09/13/2021, 8:38 AM
Solve it! Thank you very much Alex! 🙂