bec_widgets.utils.plugin_utils#

Classes#

Functions#

_collect_classes_from_package(→ BECClassContainer)

Collect classes from a package subtree (for example widgets or applications).

_filter_auto_updates(obj)

_filter_plugins(obj)

get_custom_classes(→ BECClassContainer)

Get all relevant classes for RPC/CLI in the specified repository.

get_plugin_auto_updates(→ dict[str, ...)

Get all available auto update classes from the plugin directory. AutoUpdates must inherit from AutoUpdate and be

get_plugin_widgets(→ dict[str, ...)

Get all available widgets from the plugin directory. Widgets are classes that inherit from BECConnector.

Module Contents#

class BECClassContainer(initial: Iterable[BECClassInfo] = [])#
__add__(other: BECClassContainer)#
__iter__()#
__repr__()#
add_class(class_info: BECClassInfo)#

Add a class to the collection.

Parameters:

class_info (BECClassInfo) – The class information

as_dict(ignores: list[str] = []) dict[str, type[bec_widgets.utils.bec_widget.BECWidget]]#

get a dict of {name: Type} for all the entries in the collection.

Parameters:

ignores (list[str]) – a list of class names to exclude from the dictionary.

property classes#

Get all classes.

property collection#

Get the collection of classes.

property connector_classes#

Get all connector classes.

property names#

Return a list of class names

property plugins#

Get all plugins. These are all classes that are on the top level and are widgets.

property rpc_top_level_classes#

Get all top-level classes that are RPC-enabled. These are all classes that users can choose from.

property top_level_classes#

Get all top-level classes.

property widgets#

Get all widgets. These are all classes inheriting from BECWidget.

class BECClassInfo#
file: str#
is_connector: bool = False#
is_plugin: bool = False#
is_widget: bool = False#
module: str#
name: str#
obj: type[bec_widgets.utils.bec_widget.BECWidget]#
_collect_classes_from_package(repo_name: str, package: str) BECClassContainer#

Collect classes from a package subtree (for example widgets or applications).

_filter_auto_updates(obj)#
_filter_plugins(obj)#
get_custom_classes(repo_name: str, packages: tuple[str, Ellipsis] | None = None) BECClassContainer#

Get all relevant classes for RPC/CLI in the specified repository.

By default, discovery is limited to <repo>.widgets for backward compatibility. Additional package subtrees (for example applications) can be included explicitly.

Parameters:
  • repo_name (str) – The name of the repository.

  • packages (tuple[str, ...] | None) – Optional tuple of package names to scan. Defaults to (“widgets”,) for backward compatibility.

Returns:

Container with collected class information.

Return type:

BECClassContainer

get_plugin_auto_updates() dict[str, type[bec_widgets.widgets.containers.auto_update.auto_updates.AutoUpdates]]#

Get all available auto update classes from the plugin directory. AutoUpdates must inherit from AutoUpdate and be placed in the plugin repository’s bec_widgets/auto_updates directory. The entry point for the auto updates is specified in the respective pyproject.toml file using the following key:

[project.entry-points.”bec.widgets.auto_updates”] plugin_widgets_update = “<beamline_name>.bec_widgets.auto_updates”

e.g.

[project.entry-points.”bec.widgets.auto_updates”] plugin_widgets_update = “pxiii_bec.bec_widgets.auto_updates”

Returns:

A dictionary of widget names and their respective classes.

Return type:

dict[str, AutoUpdates]

get_plugin_widgets() dict[str, bec_widgets.utils.BECConnector]#

Get all available widgets from the plugin directory. Widgets are classes that inherit from BECConnector. The plugins are provided through python plugins and specified in the respective pyproject.toml file using the following key:

[project.entry-points.”bec.widgets.user_widgets”] plugin_widgets = “path.to.plugin.module”

e.g.

[project.entry-points.”bec.widgets.user_widgets”] plugin_widgets = “pxiii_bec.bec_widgets.widgets”

assuming that the widgets module for the package pxiii_bec is located at pxiii_bec/bec_widgets/widgets and contains the widgets to be loaded within the pxiii_bec/bec_widgets/widgets/__init__.py file.

Returns:

A dictionary of widget names and their respective classes.

Return type:

dict[str, BECConnector]