Skip to content

base

Abstract base class for state clients.

StateClient

Bases: ABC

Abstract base class for reading and writing state from different source systems.

Source code in src/cloe_delta_table_manager/state/clients/base.py
class StateClient(ABC):
    """Abstract base class for reading and writing state from different source systems."""

    @abstractmethod
    def read_state(self, path: str, state_type: type[StateT]) -> StateT:
        """Read state from the source system.

        Args:
            path: Location identifier for the state (interpretation depends on the client).
            state_type: The concrete State subclass to deserialize into.

        Returns:
            A State instance loaded from the source system.

        Raises:
            FileNotFoundError: If the state does not exist at the given path.

        """

    @abstractmethod
    def write_state(self, path: str, state: State) -> None:
        """Write state to the source system.

        The version in the state metadata is incremented before writing.

        Args:
            path: Location identifier for the state (interpretation depends on the client).
            state: The State instance to persist.

        """

    @abstractmethod
    def state_exists(self, path: str) -> bool:
        """Check whether a state exists at the given path.

        Args:
            path: Location identifier for the state.

        Returns:
            True if the state exists, False otherwise.

        """

read_state(path, state_type) abstractmethod

Read state from the source system.

Parameters:

Name Type Description Default
path str

Location identifier for the state (interpretation depends on the client).

required
state_type type[StateT]

The concrete State subclass to deserialize into.

required

Returns:

Type Description
StateT

A State instance loaded from the source system.

Raises:

Type Description
FileNotFoundError

If the state does not exist at the given path.

Source code in src/cloe_delta_table_manager/state/clients/base.py
@abstractmethod
def read_state(self, path: str, state_type: type[StateT]) -> StateT:
    """Read state from the source system.

    Args:
        path: Location identifier for the state (interpretation depends on the client).
        state_type: The concrete State subclass to deserialize into.

    Returns:
        A State instance loaded from the source system.

    Raises:
        FileNotFoundError: If the state does not exist at the given path.

    """

state_exists(path) abstractmethod

Check whether a state exists at the given path.

Parameters:

Name Type Description Default
path str

Location identifier for the state.

required

Returns:

Type Description
bool

True if the state exists, False otherwise.

Source code in src/cloe_delta_table_manager/state/clients/base.py
@abstractmethod
def state_exists(self, path: str) -> bool:
    """Check whether a state exists at the given path.

    Args:
        path: Location identifier for the state.

    Returns:
        True if the state exists, False otherwise.

    """

write_state(path, state) abstractmethod

Write state to the source system.

The version in the state metadata is incremented before writing.

Parameters:

Name Type Description Default
path str

Location identifier for the state (interpretation depends on the client).

required
state State

The State instance to persist.

required
Source code in src/cloe_delta_table_manager/state/clients/base.py
@abstractmethod
def write_state(self, path: str, state: State) -> None:
    """Write state to the source system.

    The version in the state metadata is incremented before writing.

    Args:
        path: Location identifier for the state (interpretation depends on the client).
        state: The State instance to persist.

    """