Azure Block Blob

class keg_storage.backends.azure.AzureStorage(account: str, key: str, bucket: str, name: str = 'azure')[source]
delete(path: str)[source]

Delete the remote file specified by path.

list(path: str) → List[keg_storage.backends.base.ListEntry][source]

Returns a list of ListEntry`s representing files available under the directory or prefix given in `path.

open(path: str, mode: Union[keg_storage.backends.base.FileMode, str], buffer_size: int = 10485760) → keg_storage.backends.azure.AzureFile[source]

Returns a instance of RemoteFile for the given path that can be used for reading and/or writing depending on the mode given.

class keg_storage.backends.azure.AzureReader(container_name: str, path: str, mode: keg_storage.backends.base.FileMode, service: azure.storage.blob.blockblobservice.BlockBlobService, chunk_size=10485760)[source]

The Azure reader uses byte ranged API calls to fill a local buffer to avoid lots of API overhead for small read sizes.

read(size: int) → bytes[source]

Read and return up to size bytes from the remote file. If the end of the file is reached this should return an empty bytes string.

class keg_storage.backends.azure.AzureWriter(container_name: str, path: str, mode: keg_storage.backends.base.FileMode, service: azure.storage.blob.blockblobservice.BlockBlobService, chunk_size: int = 4194304)[source]

We are using Azure Block Blobs for all operations. The process for writing them is substantially similar to that of S3 with a couple of differences.

  1. We generate the IDs for the blocks
  2. There is no separate call to instantiate the upload. The first call to put_block will create the blob.
close()[source]

Cleanup and deallocate any held resources. This method may be called multiple times on a single instance. If the file was already closed, this method should do nothing.

write(data: bytes) → None[source]

Write the data buffer to the remote file.

class keg_storage.backends.azure.AzureFile(container_name: str, path: str, mode: keg_storage.backends.base.FileMode, service: azure.storage.blob.blockblobservice.BlockBlobService, chunk_size: int = 10485760)[source]

Base class for Azure file interface. Since read and write operations are very different and integrating the two would introduce a lot of complexity there are distinct subclasses for files opened for reading and writing.