Hello. Is it possible to yield multiple Outputs fr...
# ask-community
p
Hello. Is it possible to yield multiple Outputs from up using conditional branching approach? This is the code I thought would work:
Copy code
@op(out={"first_output": Out(is_required=False), "second_output": Out(is_required=False)})
def my_op(context) -> Tuple[Output[str], Output[str]]:
    yield Output("first_output", "first_output"), Output("second_output", "second_output")
However, I'm getting such an error:
Copy code
dagster._core.errors.DagsterInvariantViolationError: Compute function for op "my_op" yielded a value of type <class 'tuple'> rather than an instance of Output, AssetMaterialization, or ExpectationResult. Values yielded by ops must be wrapped in one of these types. If your op has a single output and yields no other events, you may want to use `return` instead of `yield` in the body of your op compute function. If you are already using `return`, and you expected to return a value of type <class 'tuple'>, you may be inadvertently returning a generator rather than the value you expected.
I tried modifying that code in multiple ways, nothing helped. When returning one Output, it works. Any idea how to return multiple Outputs? Thanks in advance! 🙂
c
You need two separate yield statements or you need to return the tuple unfortunately
p
That's a shame. It seems like a quite basic functionality. Thanks for your response @chris!