phenotypic.sdk_.register#
Registry utilities for PhenoTypic analysis dashboard components.
Examples
Register a new analysis plugin:
from phenotypic.sdk\_.register import register_analysis
@register_analysis
class MyAnalysisPlugin(BaseAnalysisPlugin):
call_name = "my_analysis"
Query available analysis plugins:
from phenotypic.sdk\_.register import available_analysis_plugins
print(available_analysis_plugins())
Functions
Return names of all registered analysis plugins. |
|
Look up registered analysis plugin by name. |
|
Decorator to register an analysis plugin class. |
Classes
Registry for dashboard analysis plugins. |
|
Base class for component registries. |
- class phenotypic.sdk_.register.AnalysisPluginRegistry[source]
Bases:
BaseRegistry[BaseAnalysisPlugin]Registry for dashboard analysis plugins.
Plugins are registered by their
call_nameclass attribute, which is used as the HTML element ID prefix and sub-tab identifier.- classmethod get(name: str) type[T]
Look up registered class by name.
- Parameters:
name (str) – The registered name of the component.
- Returns:
The registered class.
- Raises:
ValueError – If name is not registered.
- Return type:
type[T]
- classmethod register(target_cls: type[T]) type[T]
Decorator that registers a class by its
call_nameclass attribute.If
call_nameis not defined on the class, defaults to the class name.- Parameters:
target_cls (type[T]) – The class to register.
- Returns:
The registered class (unchanged).
- Raises:
ValueError – If a component with the same name is already registered.
- Return type:
type[T]
- class phenotypic.sdk_.register.BaseRegistry[source]
Bases:
Generic[T]Base class for component registries.
Subclasses define _REGISTRY dict and implement register/get/available. Registered classes may define a
call_nameclass attribute; if not set, the class name is used as the default.Examples
Create a custom registry:
class MyComponentRegistry(BaseRegistry["MyComponent"]): _REGISTRY: ClassVar[dict[str, type["MyComponent"]]] = {} _registry_name: ClassVar[str] = "component" @MyComponentRegistry.register class ConcreteComponent: call_name = "concrete" # Look up by name cls = MyComponentRegistry.get("concrete")
- classmethod get(name: str) type[T][source]
Look up registered class by name.
- Parameters:
name (str) – The registered name of the component.
- Returns:
The registered class.
- Raises:
ValueError – If name is not registered.
- Return type:
type[T]
- classmethod register(target_cls: type[T]) type[T][source]
Decorator that registers a class by its
call_nameclass attribute.If
call_nameis not defined on the class, defaults to the class name.- Parameters:
target_cls (type[T]) – The class to register.
- Returns:
The registered class (unchanged).
- Raises:
ValueError – If a component with the same name is already registered.
- Return type:
type[T]
- phenotypic.sdk_.register.available_analysis_plugins() tuple[str, ...][source]
Return names of all registered analysis plugins.
- phenotypic.sdk_.register.get_analysis_plugin(name: str) type['BaseAnalysisPlugin'][source]
Look up registered analysis plugin by name.
- Parameters:
name (str) – The registered name of the plugin.
- Returns:
The registered analysis plugin class.
- Raises:
ValueError – If name is not registered.
- Return type:
type[‘BaseAnalysisPlugin’]
- phenotypic.sdk_.register.register_analysis(cls: type['BaseAnalysisPlugin']) type['BaseAnalysisPlugin'][source]
Decorator to register an analysis plugin class.
The class must have a
call_nameclass attribute used as the registration key and HTML ID prefix.- Parameters:
cls (type['BaseAnalysisPlugin']) – Analysis plugin class to register.
- Returns:
The registered class (unchanged).
- Return type:
type[‘BaseAnalysisPlugin’]
Examples
>>> @register_analysis ... class MyPlugin(BaseAnalysisPlugin): ... call_name = "my_analysis" ... display_name = "My Analysis" ... ... def css(self): ... ... def html(self): ... ... def js(self): ...