phenotypic.tools_.register#
Registry utilities for PhenoTypic components.
Provides registration decorators and lookup functions for extensible components like plotters and dashboards.
Examples
Register a new plotter:
from phenotypic.tools\_.register import register_plotter
@register_plotter
class MyPlotter(BasePlotter):
name = "my_plot"
def my_plot(self, **kwargs):
...
Query available plotters:
from phenotypic.tools\_.register import available_plotters, get_plotter
print(available_plotters())
# ('all', 'diagnostics', 'morph_progression', ...)
plotter_cls = get_plotter("overlay")
Functions
Return names of all registered analysis plugins. |
|
Return names of all registered dashboards. |
|
Return names of all registered plotters. |
|
Look up registered analysis plugin by name. |
|
Look up registered dashboard by name. |
|
Look up registered plotter by name. |
|
Decorator to register an analysis plugin class. |
|
Decorator to register a dashboard class. |
|
Decorator to register a plotter class. |
Classes
Registry for dashboard analysis plugins. |
|
Base class for component registries. |
|
Registry for dashboard classes (duck-typed, no strict base). |
|
Registry for plotter classes. |
- class phenotypic.tools_.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.tools_.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]
- class phenotypic.tools_.register.DashboardRegistry[source]
Bases:
BaseRegistryRegistry for dashboard classes (duck-typed, no strict base).
Dashboards are registered by their
call_nameclass attribute, which must match the method name used for dispatch (e.g.,call_name = "detect_modes"corresponds toimage.panel.detect_modes()).Dashboards may have optional dependencies (e.g., Panel). Classes should only be registered when their dependencies are available.
- 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.tools_.register.PlotterRegistry[source]
Bases:
BaseRegistry[BasePlotter]Registry for plotter classes.
Plotters are registered by their
call_nameclass attribute, which must match the method name used for dispatch (e.g.,call_name = "overlay"corresponds toimage.plot.size_distribution()).- 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]
- phenotypic.tools_.register.available_analysis_plugins() tuple[str, ...][source]
Return names of all registered analysis plugins.
- phenotypic.tools_.register.available_dashboards() tuple[str, ...][source]
Return names of all registered dashboards.
- phenotypic.tools_.register.available_plotters() tuple[str, ...][source]
Return names of all registered plotters.
- phenotypic.tools_.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.tools_.register.get_dashboard(name: str) type[source]
Look up registered dashboard by name.
- Parameters:
name (str) – The registered name of the dashboard.
- Returns:
The registered dashboard class.
- Raises:
ValueError – If name is not registered.
- Return type:
- phenotypic.tools_.register.get_plotter(name: str) type[BasePlotter][source]
Look up registered plotter by name.
- Parameters:
name (str) – The registered name of the plotter.
- Returns:
The registered plotter class.
- Raises:
ValueError – If name is not registered.
- Return type:
type[BasePlotter]
- phenotypic.tools_.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): ...
- phenotypic.tools_.register.register_dashboard(cls: type) type[source]
Decorator to register a dashboard class.
The class must have a
call_nameclass attribute that matches the method name for dispatch.- Parameters:
cls (type) – Dashboard class to register.
- Returns:
The registered class (unchanged).
- Return type:
Examples
>>> @register_dashboard ... class MyDashboard(BaseDashboard): ... call_name = "my_dashboard" ... ... def my_dashboard(self, **kwargs): ... ...
- phenotypic.tools_.register.register_plotter(cls: type[BasePlotter]) type[BasePlotter][source]
Decorator to register a plotter class.
The class must have a
call_nameclass attribute that matches the method name for dispatch.- Parameters:
cls (type[BasePlotter]) – Plotter class to register.
- Returns:
The registered class (unchanged).
- Return type:
type[BasePlotter]
Examples
>>> @register_plotter ... class MyPlotter(BasePlotter): ... call_name = "my_plot" ... ... def my_plot(self, **kwargs): ... ...