Exemple #1
0
def test_s3_storage():
    _storage = S3FileSystem()
    storage = S3Storage(_storage, "s3://snark-test/test_s3_storage")

    storage["hello"] = bytes("world2", "utf-8")
    assert storage["hello"] == bytes("world2", "utf-8")
    assert len(storage) == 1
    assert list(storage) == ["hello"]
    del storage["hello"]
    assert len(storage) == 0
Exemple #2
0
def test_s3_storage():
    _storage = S3FileSystem()
    storage = S3Storage(_storage, "s3://snark-test/test_s3_storage1")

    storage["hello"] = BYTE_DATA
    storage["numpy"] = NUMPY_ARR
    assert storage["hello"] == BYTE_DATA
    assert storage["numpy"] == bytearray(memoryview(NUMPY_ARR))
    assert len(storage) == 2
    assert list(storage) == ["hello", "numpy"]
    del storage["hello"]
    assert len(storage) == 1
Exemple #3
0
 def get_mapper(self, root: str, check=False, create=False):
     root = "s3://" + root
     client_kwargs = self._kwargs.get("client_kwargs")
     endpoint_url = client_kwargs and client_kwargs.get(
         "endpoint_url") or None
     return S3Storage(
         self,
         root,
         aws_access_key_id=self._kwargs.get("key"),
         aws_secret_access_key=self._kwargs.get("secret"),
         aws_session_token=self._kwargs.get("token"),
         endpoint_url=endpoint_url,
     )
Exemple #4
0
def test_s3_storage_pickability():
    _storage = S3FileSystem()
    storage = S3Storage(_storage, "s3://snark-test/test_s3_storage")

    cloudpickle.dumps(storage)