Jonas De Beukelaer
02/01/2022, 11:03 AMdef put_object(self, Bucket, Key, Body, *args, **kwargs):
self.mock_extras.put_object(*args, **kwargs)
> self.buckets[Bucket][Key] = Body.read()
E AttributeError: 'bytes' object has no attribute 'read'
I’m simulating mocking just uploading a zipped file so just some bytes, but it seems the fake resource expect to be able to .read()
the Body? Why is this? Or am I using the resource wrong?jordan
02/01/2022, 3:19 PMbytes or seekable file-like objecthttps://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.put_object But the
s3_fake_resource
incorrectly implements it to only take a seekable file-like object.
We can get a fix out for this - sorry about that!Jonas De Beukelaer
02/01/2022, 3:31 PMcreate_s3_fake_resource
in dagster_aws/s3/s3_fake_resource.py
does not have the @resourcce
decorator, meaning I can’t use it directly as a dagster resource - should it?jordan
02/01/2022, 4:16 PMJonas De Beukelaer
02/02/2022, 10:27 AMimport boto3
from moto import mock_s3
from dagster import resource, Array
@mock_s3
@resource(config_schema={"buckets": Array(str)})
def s3_resource_mock(init_context):
conn = boto3.resource("s3", region_name="eu-west-2")
for b in init_context.resource_config["buckets"]:
conn.create_bucket(Bucket=b)
return conn
with buckets
being a list of buckets I expect to find in s3