https://dagster.io/ logo
#ask-community
Title
# ask-community
n

Nuno

08/10/2023, 10:23 AM
Hey everyone. Is there any documentation available regarding metadata in multi-asset outputs?
Copy code
@multi_asset(outs={"b": AssetOut(), "c": AssetOut()})
def example_op(a: pd.DataFrame) -> Output[Tuple[pd.DataFrame, pd.DataFrame]]:
    b, c = split_into_two_dfs(a)
    return Output(
        (b, c),
        metadata={
            "num_rows_b": b.shape[0],
            "num_rows_c": c.shape[0],
        },
    )
The code above yields the following error:
Copy code
dagster._core.errors.DagsterInvariantViolationError: Expected Tuple annotation for multiple outputs, but received non-tuple annotation.
Not sure what I am missing and would very much appreciate any feedback. Thanks in advance!
dagster bot responded by community 1
🤖 1
z

Zach

08/10/2023, 3:18 PM
I think the error is indicating that it's expecting the return type of the multi-asset to be a tuple of outputs. I would try something like:
Copy code
@multi_asset(outs={"b": AssetOut(), "c": AssetOut()})
def example_op(a: pd.DataFrame) -> Tuple[Output[pd.DataFrame], Output[pd.DataFrame]]:
    b, c = split_into_two_dfs(a)
    return Output(b,metadata={"num_rows_b": b.shape[0]}), Output(c, metadata={"num_rows_c": c.shape[0],})
👍 1
n

Nuno

08/14/2023, 3:11 PM
Thank you @Zach! That is indeed what I was looking for.
3 Views