PluginStore
One plugin's persistent storage for one datasource.
from plexora.api import PluginStorePluginStore(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
datasourcestrrequiredThe datasource this store persists against.
pluginstrrequiredThe plugin's own name: lowercase letters, digits and underscores, starting with a letter.
legacy_state_tablestrdefault NoneA 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: strThis plugin's table-name prefix.
str"plugin_<plugin>_".
Methods
table_name
table_name(name: str) -> strThe namespaced SQL table name for one of this plugin's own names.
namestrrequiredA name meaningful to the plugin, e.g. "results".
Lowercase letters, digits and underscores, starting with a
letter.
strThe real table name, prefixed for this plugin.
get_state
get_state() -> bytes | NoneThis plugin's saved state.
bytes | NoneNone 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) -> NoneSave this plugin's opaque state for this datasource.
blobbytesrequiredThe state to save, replacing whatever was saved before.
TypeErrorIf blob is not bytes.
put_table
put_table(name: str, frame: pl.DataFrame) -> NoneStore a result table -- measurements, annotations, classifications.
namestrrequiredA name meaningful to the plugin, e.g. "results".
Lowercase letters, digits and underscores, starting with a
letter.
framepolars.DataFramerequiredThe table to store, replacing whatever was stored under this name before.
TypeErrorIf frame is not a polars DataFrame.
get_table
get_table(name: str) -> pl.DataFrame | NoneA result table this plugin previously stored.
namestrrequiredThe name it was stored under.
polars.DataFrame | NoneNone 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.PathThe 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() -> NoneRemove 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.