qhana_plugin_runner.db.models.virtual_plugins module

class qhana_plugin_runner.db.models.virtual_plugins.DataBlob(plugin_id: str, key: str, value: bytes)

Bases: object

classmethod delete_value(plugin_id: str, key: str, commit: bool = False)

Delete state for a given key.

Parameters:
  • plugin_id (str) – the plugin to set the state for (with or without version)

  • key (str) – the key to store state under

  • commit (bool, optional) – if true the session will be comitted immediately. Defaults to False.

classmethod get_item(plugin_id: str, key: str) DataBlob | None

Get a full item record for a given key.

Parameters:
  • plugin_id (str) – the plugin requesting the value (is matched exactly to plugin_id)

  • key (str) – the key of the state to search for

Returns:

the plugin state record

Return type:

Optional[DataBlob]

classmethod get_value(plugin_id: str, key: str, default: Any = Ellipsis) bytes

Get a value for a given key.

Parameters:
  • plugin_id (str) – the plugin requesting the value (is matched exactly to plugin_id)

  • key (str) – the key of the state to search for

  • default (Any, optional) – a default value to return if the key was not present.

Raises:

KeyError – if the key was not found and no default value was provided

Returns:

the stored state value, or the default value

Return type:

bytes

key: Mapped[str]
plugin_id: Mapped[str]
classmethod set_value(plugin_id: str, key: str, value: bytes, commit: bool = False) bytes | None

Set state for a given key.

Parameters:
  • plugin_id (str) – the plugin to set the state for (with or without version)

  • key (str) – the key to store state under

  • value (bytes) – the state to persist

  • commit (bool, optional) – if true the session will be comitted immediately. Defaults to False.

Returns:

the old value if any or None

Return type:

bytes

value: Mapped[bytes]
class qhana_plugin_runner.db.models.virtual_plugins.PluginState(plugin_id, key, value)

Bases: object

A table to store persistent plugin state.

The table offers a lightweight key value store for plugins for smallish values. Values are automatically serialized and deserialized. This table is for storing state that is not related to a specific task. Do not use this table to store task state!

plugin_id

the plugin identifier (with or without version) of the plugin that registered this state.

Type:

str

key

the key under which the state was registered.

Type:

str

value

(JSON_LIKE): the stored state.

Type:

sqlalchemy.orm.base.Mapped[Dict[str, Dict[str, Any] | list | str | float | int | bool | None] | List[Dict[str, Any] | list | str | float | int | bool | None] | str | float | int | bool | None]

classmethod delete_value(plugin_id: str, key: str, commit: bool = False)

Delete state for a given key.

Parameters:
  • plugin_id (str) – the plugin to set the state for (with or without version)

  • key (str) – the key to store state under

  • commit (bool, optional) – if true the session will be comitted immediately. Defaults to False.

classmethod get_all_items(plugin_id: str) Sequence[PluginState]

Get all plugin state records for a given plugin.

Parameters:

plugin_id (str) – the plugin requesting the value (is matched exactly to plugin_id)

Returns:

the plugin state record

Return type:

Optional[PluginState]

classmethod get_all_items_like(plugin_id: str) Sequence[PluginState]

Get all plugin state records for a given plugin.

Like get_all_items, but does not match the entire plugin id. This uses the database like feature so plugin_ids must not contain any % signs!

Parameters:

plugin_id (str) – the plugin requesting the value. A plugin id without version will match any version

Returns:

the plugin state record

Return type:

Optional[PluginState]

classmethod get_item(plugin_id: str, key: str) PluginState | None

Get a full item record for a given key.

Parameters:
  • plugin_id (str) – the plugin requesting the value (is matched exactly to plugin_id)

  • key (str) – the key of the state to search for

Returns:

the plugin state record

Return type:

Optional[PluginState]

classmethod get_value(plugin_id: str, key: str, default: Any = Ellipsis) Dict[str, Dict[str, Any] | list | str | float | int | bool | None] | List[Dict[str, Any] | list | str | float | int | bool | None] | str | float | int | bool | None

Get a value for a given key.

Parameters:
  • plugin_id (str) – the plugin requesting the value (is matched exactly to plugin_id)

  • key (str) – the key of the state to search for

  • default (Any, optional) – a default value to return if the key was not present.

Raises:

KeyError – if the key was not found and no default value was provided

Returns:

the stored state value

Return type:

JSON_LIKE

key: Mapped[str]
plugin_id: Mapped[str]
classmethod set_value(plugin_id: str, key: str, value: Dict[str, Dict[str, Any] | list | str | float | int | bool | None] | List[Dict[str, Any] | list | str | float | int | bool | None] | str | float | int | bool | None, commit: bool = False) Dict[str, Dict[str, Any] | list | str | float | int | bool | None] | List[Dict[str, Any] | list | str | float | int | bool | None] | str | float | int | bool | None

Set state for a given key.

Parameters:
  • plugin_id (str) – the plugin to set the state for (with or without version)

  • key (str) – the key to store state under

  • value (JSON_LIKE) – the state to persist

  • commit (bool, optional) – if true the session will be comitted immediately. Defaults to False.

Returns:

the old value if any or None

Return type:

JSON_LIKE

value: Mapped[Dict[str, Dict[str, Any] | list | str | float | int | bool | None] | List[Dict[str, Any] | list | str | float | int | bool | None] | str | float | int | bool | None]
class qhana_plugin_runner.db.models.virtual_plugins.VirtualPlugin(parent_id, name, version, description, tags, href)

Bases: object

A table to keep track of virtual plugins.

id

database ID of the virtual plugine.

Type:

int, optional

parent_id

the plugin identifier (with or without version) of the plugin that registered this virtual plugin.

Type:

str

name

the name of the virtual plugin.

Type:

str

version

the version of the virtual plugin.

Type:

str

description

a description of the plugin.

Type:

str

tags

a list of tags of the plugin (tags must be separated by newlines).

Type:

str

href

The URL of the REST entry point resource.

Type:

str

classmethod delete_by_href(href: str, parent_id: str | None = None, commit: bool = False)
classmethod delete_by_name_and_version(name: str, version: str, commit: bool = False)
description: Mapped[str]
classmethod exists(query_filter: Sequence[Any] = ()) bool
classmethod get_all(for_parents: Iterable[str] | None = None, filters: Sequence[ColumnOperators] = ()) List[VirtualPlugin]
classmethod get_all_by_name(name: str) List[VirtualPlugin]
classmethod get_by_href(href: str, parent_id: str | None = None) VirtualPlugin | None
href: Mapped[str]
id: Mapped[int]
property identifier
name: Mapped[str]
parent_id: Mapped[str]
property tag_list
tags: Mapped[str]
version: Mapped[str]