google
Classes:
-
BlobStorage–A storage backend that uses Google Cloud Storage.
-
ReaderType–A protocol for creating a blob reader.
-
WriterType–A protocol for creating a blob writer.
BlobPointer
Bases: TypedDict
A pointer to a blob in Google Cloud Storage.
Attributes:
-
blob(str) –The path to the blob within the bucket.
-
bucket(str) –The name of the bucket where the blob is stored.
-
user_project(NotRequired[str | None]) –The project ID to be billed for API requests made via the bucket.
user_project
instance-attribute
user_project: NotRequired[str | None]
The project ID to be billed for API requests made via the bucket.
BlobRouter
BlobStorage
BlobStorage(
*,
storage_client: Client,
storage_router: BlobRouter | None,
object_chunk_size: int = DEFAULT_CHUNK_SIZE,
max_writers: int | None = None,
max_readers: int | None = None,
writer_type: WriterType = BlobWriter,
reader_type: ReaderType = BlobReader
)
Bases: Storage['BlobPointer']
A storage backend that uses Google Cloud Storage.
Methods:
-
deserialize_config–Deserialize the configuration from a JSON string.
-
read_data–Load data from the given location.
-
read_data_stream–Load a data stream from the given location.
-
serialize_config–Serialize the configuration to a JSON string.
-
write_data–Save the given data.
-
write_data_stream–Save the given data steam.
deserialize_config
deserialize_config(config: str) -> C
Deserialize the configuration from a JSON string.
read_data_stream
async
read_data_stream(
pointer: BlobPointer,
) -> AsyncGenerator[bytes]
Load a data stream from the given location.
write_data
async
write_data(
data: bytes, digest: Digest, tags: TagMap
) -> BlobPointer
Save the given data.
write_data_stream
async
write_data_stream(
data_stream: AsyncIterable[bytes],
get_digest: GetStreamDigest,
tags: TagMap,
) -> BlobPointer
Save the given data steam.
ReaderType
WriterType
simple_blob_router
simple_blob_router(
bucket: str, prefix: str = ""
) -> BlobRouter
Create a simple blob router that returns a BlobPointer based on the bucket and prefix.
Parameters:
-
(bucketstr) –The name of the Google Cloud Storage bucket.
-
(prefixstr, default:'') –An optional prefix to prepend to the blob path.
Returns:
-
BlobRouter–A BlobRouter that generates BlobPointers for the specified bucket and prefix.