https://dagster.io/ logo
Title
s

szalai1

05/27/2021, 9:37 AM
I though I need to implement
get_output_asset_key
,but when I implemented it I got this error:
Both the OutputDefinition and the IOManager of output "result" on solid "pull_tweets" associate it with an asset. Either remove the asset_key parameter on the OutputDefinition or use an IOManager that does not specify an AssetKey in its get_output_asset_key() function.
class S3IOManagerWithPathEntry(PickledObjectS3IOManager):
    def get_output_asset_key(self, context:OutputContext):
        return AssetKey(context.name)

    def handle_output(self, context, obj):
        super().handle_output(context, obj)
        yield EventMetadataEntry.path(f"s3://{self.bucket}/{self._get_path(context)}", label="path")
this is my simple iomanager
a

alex

05/27/2021, 2:55 PM
@prha / @owen
p

prha

05/27/2021, 4:19 PM
@szalai1 I think it’s an either/or situation. If you know in the solid definition what asset you want to materialize, it’s probably easiest to set the asset key on the output definition. If you have a generic solid, and want to materialize an asset whose key depends on the behavior of the io manager, you probably want to use
get_output_asset_key
in the IOManager.
For example, you could just materialize a
users
asset from a solid
create_users_table
. But you could also want to materialize a location-specific asset, like
redshift > users
or
snowflake > users
, where it kind of depends how you’ve configured your IOManager.
s

szalai1

05/28/2021, 9:25 AM
If you have a generic solid, and want to materialize an asset whose key depends on the behavior of the io manager, you probably want to use 
get_output_asset_key
 in the IOManager.
does this mean I shouldn't name my output with asset_key, but using thre ``get_output_asset_key`` method ?
p

prha

05/28/2021, 3:35 PM
I think if you can name your output with
asset_key
, you should do that instead of using the IOManager
get_output_asset_key