Storage Backend Schema#
- class openfactory.schemas.filelayer.storage.StorageBackendSchema(**data)[source]#
Bases:
BaseModelPydantic wrapper for a storage backend configuration.
This class allows parsing and validation of a dictionary that represents a storage backend. It automatically selects the correct backend subclass based on the type field using the StorageBackend discriminated union.
- Example usage:
from openfactory.schemas.filelayer.storage import StorageBackendSchema # Example storage backend (NFS) storage_dict = { "type": "nfs", "server": "10.0.5.2", "remote_path": "/nfs/data", "mount_point": "/mnt", "mount_options": ["rw", "noatime"] } # Parse and validate storage_schema = StorageBackendSchema(storage=storage_dict) # Get runtime backend instance backend_instance = storage_schema.storage.create_backend_instance()
Note
storage contains the parsed backend schema (a subclass of
openfactory.schemas.filelayer.base_backend.BaseBackendConfig).Use create_backend_instance() on .storage to obtain the runtime backend (e.g., NFSBackend, LocalBackend) for actual file operations.
Supports any backend added to the StorageBackend discriminated union.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- storage: Annotated[NFSBackendConfig | LocalBackendConfig, FieldInfo(annotation=NoneType, required=True, description='Discriminator field to select the correct storage backend schema', discriminator='type')]#