Skip to content

state

State submodule providing functionality related to persisting process or component state.

StateBackend

StateBackend(
    job_id: Optional[str] = None,
    metadata: Optional[dict] = None,
    **kwargs: Any,
)

Bases: ABC, ExportMixin

StateBackend defines an interface for managing process state.

Instantiates StateBackend.

Parameters:

Name Type Description Default
job_id Optional[str]

The unique id for the job.

None
metadata Optional[dict]

Metadata key value pairs.

None
kwargs Any

Additional keyword arguments.

{}

created_at property

created_at: str

Returns date and time of job creation.

job_id property

job_id: str

Returns the job id for the state.

metadata property

metadata: dict

Returns metadata attached to the job.

__aenter__ async

__aenter__() -> StateBackend

Enters the context manager.

__aexit__ async

__aexit__(
    exc_type: Optional[Type[BaseException]],
    exc_value: Optional[BaseException],
    traceback: Optional[TracebackType],
) -> None

Exits the context manager.

destroy async

destroy() -> None

Destroys the StateBackend.

get_component async

get_component(component_id: str) -> dict

Returns a component from the state.

get_connector async

get_connector(connector_id: str) -> dict

Returns a connector from the state.

get_process async

get_process(process_id: str) -> dict

Returns a process from the state.

get_process_for_component async

get_process_for_component(component_id: str) -> dict

Gets the process that a component belongs to.

get_process_status async

get_process_status(process_id: str) -> Status

Gets the status of a process from the state.

get_process_status_for_component async

get_process_status_for_component(
    component_id: str,
) -> Status

Gets the status of the process that a component belongs to.

init async

init() -> None

Initialises the StateBackend.

update_process_status async

update_process_status(
    process_id: str, status: Status
) -> None

Updates the status of a process in the state.

upsert_component async

upsert_component(component: Component) -> None

Upserts a component into the state.

upsert_connector async

upsert_connector(connector: Connector) -> None

Upserts a connector into the state.

upsert_process async

upsert_process(
    process: Process, with_components: bool = False
) -> None

Upserts a process into the state.

DictStateBackend

DictStateBackend(*args: Any, **kwargs: Any)

Bases: StateBackend

DictStateBackend provides state persistence for single process runs.

Instantiates DictStateBackend.

SqliteStateBackend

SqliteStateBackend(
    db_path: str = "plugboard.db", *args: Any, **kwargs: Any
)

Bases: StateBackend

SqliteStateBackend handles single host persistent state.

Initializes SqliteStateBackend with db_path.

destroy async

destroy() -> None

Destroys the SqliteStateBackend.

get_component async

get_component(component_id: str) -> dict

Returns a component from the state.

get_connector async

get_connector(connector_id: str) -> dict

Returns a connector from the state.

get_process async

get_process(process_id: str) -> dict

Returns a process from the state.

get_process_for_component async

get_process_for_component(component_id: str) -> dict

Gets the process that a component belongs to.

get_process_status async

get_process_status(process_id: str) -> Status

Gets the status of a process from the state.

get_process_status_for_component async

get_process_status_for_component(
    component_id: str,
) -> Status

Gets the status of the process that a component belongs to.

init async

init() -> None

Initializes the SqliteStateBackend.

update_process_status async

update_process_status(
    process_id: str, status: Status
) -> None

Updates the status of a process in the state.

upsert_component async

upsert_component(component: Component) -> None

Upserts a component into the state.

upsert_connector async

upsert_connector(connector: Connector) -> None

Upserts a connector into the state.

upsert_process async

upsert_process(
    process: Process, with_components: bool = False
) -> None

Upserts a process into the state.