BC A
03/13/2024, 8:50 PMdef multiple_dynamic_values():
for i in range(2):
yield DynamicOutput(i, output_name="values", mapping_key=f"num_{i}")
yield DynamicOutput(-i, output_name="negatives", mapping_key=f"neg_{i}")
Scout
03/13/2024, 8:50 PMDynamicOutput
objects based on some condition. Here's a modified version of your example that includes a conditional statement: python from dagster import DynamicOutput, op @op(out={"values": DynamicOut(), "negatives": DynamicOut()}) def multiple_dynamic_values(): for i in range(2): if some_condition(i): yield DynamicOutput(i, output_name="values", mapping_key=f"num_{i}") if another_condition(i): yield DynamicOutput(-i, output_name="negatives", mapping_key=f"neg_{i}")
In this code, some_condition(i)
and another_condition(i)
represent placeholder functions that return a boolean value. If some_condition(i)
returns True
, then a DynamicOutput
with the value i
is yielded for the output named "values". Similarly, if another_condition(i)
returns True
, then a DynamicOutput
with the value -i
is yielded for the output named "negatives". You would need to define the actual conditions that some_condition(i)
and another_condition(i)
check for based on your specific use case.