Skip to content

file

Classes:

  • FileStorage

    A storage backend for testing that saves data to local files.

Attributes:

  • file_storage

    Default instance of FileStorage whose directory is deleted when the process exits.

file_storage module-attribute

file_storage = FileStorage(
    LABOX_USER_PROC_CACHE_DIR / __name__, mkdir=True
)

Default instance of FileStorage whose directory is deleted when the process exits.

FileStorage

FileStorage(
    path: Path | str,
    *,
    mkdir: bool = False,
    chunk_size: int = 5 * 1024**2
)

Bases: Storage[str]

A storage backend for testing that saves data to local files.

Methods:

deserialize_config

deserialize_config(config: str) -> C

Deserialize the configuration from a JSON string.

read_data async

read_data(location: str) -> bytes

Load data from the given location.

read_data_stream async

read_data_stream(location: str) -> AsyncGenerator[bytes]

Load a stream of data from the given location.

serialize_config

serialize_config(config: C) -> str

Serialize the configuration to a JSON string.

write_data async

write_data(
    data: bytes, digest: Digest, _tags: TagMap
) -> str

Save the given data.

write_data_stream async

write_data_stream(
    data_stream: AsyncIterable[bytes],
    get_digest: GetStreamDigest,
    _tags: TagMap,
) -> str

Save the given data stream.