plf
03/16/2023, 12:09 AM@asset
def some_asset():
output = "some_great_output"
return Output(
value=output,
output_name=some_name,
)
raises this error:
dagster._core.errors.DagsterInvariantViolationError: Bad state: Output was explicitly named 'some_name', which does not match the output definition specified for position 0: 'result'.
how do i fix this?yuhan
03/16/2023, 3:17 AM@asset
def some_asset():
output = "some_great_output"
return Output(
value=output,
)
you don’t need to specify the name@asset
def some_asset():
output = "some_great_output"
return output
@asset
would yield only one output, which is considered as “the data asset” tied to this computation. if you’d like to yield multiple outputs in one asset, you can use @multi_assets
https://docs.dagster.io/concepts/assets/multi-assets where you can give names to different outputsplf
03/16/2023, 10:11 AMOutput
object even for a (non-multi) asset, e.g. to attach metadata to it (correct me if that’s wrong). but if you wrap your output into an Output
object, the asset gets the default name “result” - not exactly a very useful name for an asset. hence my need to give it an explicit name. that should be possible somehow, right?asset
decorator does not expect an output_defs
parameter or an outs
parameter or anything like that, how do you specify an OutputDefinition
for it?yuhan
03/16/2023, 6:21 PMcontext.add_output_metadata
too. here’s an example: https://github.com/dagster-io/dagster/blob/master/examples/quickstart_etl/quickstart_etl/assets/hackernews.py#L40-L49
as for “result” isn’t useful name, when you’re using the single asset with single output (1:1 mapping), the name “result” becomes an implementation detail because the output metadata will show up in that asset page, which is why @asset
doesn’t have the outs
argument bc it doesn’t need to. that being said, if you do need to return Output
, you can return Output(name="result",…)