say I have two solids in Dagster connected on a pipeline. The first solid may do some process and generate a valid input so that the rest of the pipeline executes, or generate an invalid input that should not be further processed. To achieve this result, I raise an error when the data meets the invalid condition so the pipeline stops and the rest of the solids are skipped.
Raising an error to solve my use case seems hacky, is there a way that I can skip the execution of the rest of the pipeline without resorting to exceptions?
from dagster import solid, pipeline
@solid
def solid_1(context, x: int):
y = x + 1
if y%2 == 0:
raise "No even number is further processed"
return y
@solid
def solid_2(context, y:int):
return y**2
@pipeline
def toy_pipeline():
solid_2(solid_1())
In this quite contrived example, the solid 2 should only be executed when the output from the first solid is odd.
In my actual use case, the first solid polls a DB and sometimes finds no data to process. In this case it makes sense not to mark the execution as failed but rather as a success. It could be possible to check in each downstream solid whether the data meets the conditions, yet this quickly adds boilerplate. It would be ideal to have a way to skip the execution of all downstream solids when the solid that receives the data finds no data to process.