https://dagster.io/ logo
Title
r

Rubén Lopez Lozoya

06/22/2021, 11:19 AM
Hey guys I have a solid:
def my_solid(input0, [input1, input2])
The problem is that input1 and input2 come from other solid executions whose execution may be skipped due to dependencies on prior solids. Is there any way to still allow my_solid to execute despite input1 and input2 computation being skipped?
😛artydagster: 1
j

jordan

06/22/2021, 4:01 PM
Here’s an example that might help:
from dagster import Output, OutputDefinition, pipeline, solid
from dagster.core.execution.api import execute_pipeline


@solid(
    output_defs=[
        OutputDefinition(name="branch1", is_required=False),
        OutputDefinition(name="branch2", is_required=False),
    ]
)
def brancher():
    yield Output(1, "branch1")
    # branch2 isn't yielded so solid2 will never run


@solid
def solid1(num):
    return num


@solid
def solid2(num):
    return num


@solid()
def adder(inputs):
    return sum(inputs)


@pipeline
def pipeline1():
    should_run1, should_run2 = brancher()
    adder([solid1(should_run1), solid2(should_run2)])


def test_skipped_inputs():
    result = execute_pipeline(pipeline1)
    assert result.success
    # branch1 is yielded so solid1 runs and returns 1
    assert result.result_for_solid("solid1").success
    assert result.result_for_solid("solid1").output_value() == 1
    # branch2 isn't yielded so solid2 will never run
    assert not result.result_for_solid("solid2").success
    # adder still successfully runs even though solid2 is skipped
    assert result.result_for_solid("adder").success
    assert result.result_for_solid("adder").output_value() == 1
tl;dr if you specify:
def adder(solid1, solid2):
    ...
and one gets skipped, the
adder
will be skipped because all of its dependencies won’t be satisfied. If you instead specify:
def adder(inputs): # a list of dependencies
    ...
adder
will still run as long as it’s not an empty list - as long as at least one dependency is satisfied. Here’s some additional discussion along the same lines: https://dagster.slack.com/archives/C01U954MEER/p1622817115415700?thread_ts=1622726789.366900&cid=C01U954MEER
r

Rubén Lopez Lozoya

06/24/2021, 6:01 PM
thanks a lot!