Plexora

PluginStore

One plugin's persistent storage for one datasource.

Generated from Plexora 0.0.55View source
from plexora.api import PluginStore
PluginStore(datasource: str, plugin: str, legacy_state_table: str | None = None)

Every table this store creates is namespaced plugin_<plugin>_<name>, so two plugins can both persist a table called, say, "results" without colliding, and uninstalling one plugin (drop_all) removes exactly its own data.

Constructor parameters

datasourcestrrequired

The datasource this store persists against.

pluginstrrequired

The plugin's own name: lowercase letters, digits and underscores, starting with a letter.

legacy_state_tablestrdefault None

A table name this plugin's state used to live in before namespacing existed. Read once as a fallback so upgrading the host does not lose saved work, then dropped. None (the default) if the plugin has no such table.

Properties

prefix

prefix: str

This plugin's table-name prefix.

str

"plugin_<plugin>_".

Methods

table_name

table_name(name: str) -> str

The namespaced SQL table name for one of this plugin's own names.

namestrrequired

A name meaningful to the plugin, e.g. "results". Lowercase letters, digits and underscores, starting with a letter.

str

The real table name, prefixed for this plugin.

get_state

get_state() -> bytes | None

This plugin's saved state.

bytes | None

None if this plugin has never saved any state for this datasource. State saved before namespacing existed is adopted into the namespaced table the first time it is read.

put_state

put_state(blob: bytes) -> None

Save this plugin's opaque state for this datasource.

blobbytesrequired

The state to save, replacing whatever was saved before.

TypeError

If blob is not bytes.

put_table

put_table(name: str, frame: pl.DataFrame) -> None

Store a result table -- measurements, annotations, classifications.

namestrrequired

A name meaningful to the plugin, e.g. "results". Lowercase letters, digits and underscores, starting with a letter.

framepolars.DataFramerequired

The table to store, replacing whatever was stored under this name before.

TypeError

If frame is not a polars DataFrame.

get_table

get_table(name: str) -> pl.DataFrame | None

A result table this plugin previously stored.

namestrrequired

The name it was stored under.

polars.DataFrame | None

None if nothing has been stored under this name for this datasource.

directory

directory()

A directory this plugin owns for this datasource, created on demand.

For inputs a plugin collects itself -- an uploaded CSV, a cached model file -- anything that is a file rather than a table. Scoped per plugin so an uninstall knows what to remove, and so two plugins cannot overwrite each other's uploads.

pathlib.Path

The directory, created if it did not already exist.

list_tables

list_tables() -> list[str]

This plugin's own table names for this datasource.

list[str]

Names as passed to put_table/get_table, without the namespace prefix.

drop_all

drop_all() -> None

Remove every table this plugin owns for this datasource.

Includes the plugin's pre-namespacing table when legacy_state_table named one: that table is this plugin's too, so leaving it behind on uninstall would defeat the point.

Guides

On this page