py4ai.data.layer.fs.serializer module

Module for implementation of serializer objects for FileSystem persistence layers.

class py4ai.data.layer.fs.serializer.FileSerializer(path: Path, encoding: str = 'utf-8')

Bases: Generic[KE, E], DataSerializer[KE, str, E, IndexedIO[KE]], ABC

DataSerializer to read raw data and convert it into IndexedIO.

Return instance of DataSerializer.

Parameters
  • path – local folder to be used to construct filenames

  • encoding – type of IO serialization (text, binary) to be used when writing files

mode: FileSerializerMode = ''
classmethod with_path(path: Path) FileSerializer[KE, E]

Return an instance of the class, pointing to a given path.

Parameters

path – new path to be used for the serializer.

Returns

FileSerializer instance with path set to the input path.

class py4ai.data.layer.fs.serializer.FileSerializerMode(value)

Bases: str, Enum

Enum representing the type of reading/writing mode for files.

BINARY = 'b'
TEXT = ''
class py4ai.data.layer.fs.serializer.IndexedIO(*, name: KE = None, buffer: IOBase)

Bases: BaseModel, Generic[KE]

Domain object to represent data read from FileSystem.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

class Config

Bases: object

Specs for the pydantic model.

arbitrary_types_allowed = True
buffer: IOBase
name: KE