LocalBackend Storage Backend#

Local host directory implementation of the FileBackend interface for OpenFactory.

This backend allows OpenFactory services to access a directory on the host filesystem via a bind mount in Docker containers. It is intended primarily for development and testing purposes.

Note

  • This backend is not compatible with Docker Swarm.

  • Mount specifications can be generated via LocalBackend.get_mount_spec().

  • Ensure the local path exists and has the proper permissions for the container.

See also

The schema of the Local Backend is openfactory.schemas.filelayer.local_backend.LocalBackendConfig.

class openfactory.filelayer.local_backend.LocalBackend(config)[source]#

Bases: FileBackend

FileBackend implementation for local host directories.

This backend allows OpenFactory services to access a directory on the host filesystem via a bind mount in Docker containers.

__init__(config)[source]#

Initialize the LocalBackend.

Parameters:

config (LocalBackendConfig) – Configuration object for the local backend.

compatible_with_swarm()[source]#

Returns False because LocalBackend cannot be used with SwarmDeploymentStrategy.

Return type:

bool

delete(path)[source]#

Delete the file at the given path.

Return type:

None

exists(path)[source]#

Check if a file exists at the given path.

Return type:

bool

static from_config(config)[source]#

Create a LocalBackend instance from a dictionary config.

Return type:

LocalBackend

Parameters:

config (dict) – Configuration dictionary.

Returns:

LocalBackend – Configured backend instance.

get_mount_spec()[source]#

Build a Docker-compatible mount specification for local bind mount.

Return type:

Dict[str, Any]

Returns:

Dict[str, Any] – Mount spec suitable for LocalDockerDeploymentStrategy.

listdir(path)[source]#

List files and directories at the given path.

Return type:

List[str]

open(path, mode='r')[source]#

Open a file at the given path.

Return type:

IO

Parameters:
  • path (str) – Path relative to backend root.

  • mode (str) – File mode (‘r’, ‘w’, ‘rb’, ‘wb’, etc.).

Returns:

IO – File-like object.