Hi folks, I have an asset annotated with return va...
# ask-community
j
Hi folks, I have an asset annotated with return value
-> None
because it is not supposed to return anything. I still want to return some metadata of its materialization. This unfortunately doesn't work:
Copy code
return Output(
        None,
        metadata={
            'my_metadata': my_value,
        }
    )
What would be the correct way to do this?
l
I believe the decorated return value should be
Output[None]
, not
None
itself.
j
Thanks for the reply. Will that still ensure that any potential downstream assets understand that it never returns any values? As opposed to receiving an actual value of
None
?
l
The special return type essentially turns off invoking the I/O Manager. You may use non_argument_dependencies if you want downstream assets to have dependency on this asset but not expecting any input value. https://docs.dagster.io/concepts/assets/software-defined-assets#non-argument-dependencies
j
Oh yeah, the I/O manager invocation is also what I was worried about. Thanks a lot, this is very helpful!
l
I'm learning myself too, trying to make sense of the different Dagster concepts and where to use what. It pays to actually read through the Concept section 😅
j
True that 🙂 Anyway, thanks and good luck!
g
personally I prefer to use context.add_output_metadata()
one fewer import, and no typehint shenanigans
l
I think the issue is less about adding metadata but to avoid asset expectations that may never materialize
j
It's kind of about both those things, thanks guys, both your advices are helpful 🙂