Is there a way to end a graph early if a step prod...
# ask-community
d
Is there a way to end a graph early if a step produces no data (and do a dynamic map otherwise)?
y
https://docs.dagster.io/concepts/ops-jobs-graphs/graphs#with-conditional-branching you can conditionally skip downstream when the upstream output is set as optional and you don’t yield it
d
I don't think this does what I want. If I do that, the runs succeed, but the asset does not actual show as materialized for that partition (and so things like select missing partitions redo a lot of computation for nothing). Toy example:
Copy code
from dagster import HourlyPartitionsDefinition, op, asset, graph_asset, DynamicOut, DynamicOutput, Definitions, OpExecutionContext

@op(out=DynamicOut(int, is_required=False))
def splay(context: OpExecutionContext):
    if not '22' in context.partition_key:
        yield DynamicOutput(1, mapping_key='1')
@op
def op2(o1):
    return o1+1

@graph_asset(
    partitions_def=HourlyPartitionsDefinition(start_date='2023-03-14-20:00')
)
def g1():
    s = splay()
    a = s.map(op2)
    return a

defs = Definitions(
    assets=[g1]
)
Picture in dagit overall and for the 2200 run below