Local component registry for TuiML.
Provides the local algorithm/feature/preprocessor registry used by
@classifier, @regressor, @transformer decorators across the library, plus the shared ComponentType enum and Registrable mixin.Local component registration:
python
from tuiml.registry import registry
python
@registry.register("classifier")
class MyClassifier:
pass
python
model = registry.create("MyClassifier", param=value)
Classes
Base mixin for all registrable components.
Any class that wants to be registered in the hub should inherit from this.
Methods
Local registry for TuiML components.
Provides discovery, registration, and instantiation of local components. Supports plugins from external packages.
python
>>> from tuiml.registry import registry
>>> # Register a custom algorithm
>>> @registry.register("classifier")
... class MyClassifier:
... pass
>>> # List all classifiers
>>> registry.list(ComponentType.CLASSIFIER)
>>> # Get a component by name
>>> cls = registry.get("MyClassifier")
Methods
register
(self, component_type: Union[ComponentType, str], name: Optional[str]=None, tags: Optional[List[str]]=None, version: str='1.0.0', author: Optional[str]=None) -> Callable[..., Type]
register
(self, component_type: Union[ComponentType, str], name: Optional[str]=None, tags: Optional[List[str]]=None, version: str='1.0.0', author: Optional[str]=None) -> Callable[..., Type]
Decorator to register a component in the hub.
Parameters
component_type
ComponentType or str
Type of component being registered.
name
str
= None
Custom name for the component. Defaults to the class name.
tags
list of str
= None
Tags for component discovery.
version
str
= "1.0.0"
Component version string.
author
str
= None
Name of the component author.
Returns
decorator
callable
A class decorator that registers the component.
list
(self, component_type: Optional[ComponentType]=None, tags: Optional[List[str]]=None) -> List[Dict[str, Any]]
list
(self, component_type: Optional[ComponentType]=None, tags: Optional[List[str]]=None) -> List[Dict[str, Any]]
List components, optionally filtered by type or tags.
Parameters
component_type
ComponentType
= None
Filter components by type.
tags
list of str
= None
Filter components by tags. Components must have ALL specified tags.
Returns
results
List[dict]
A list of component metadata dictionaries.
search
(self, query: str, limit: Optional[int]=None) -> List[Dict[str, Any]]
search
(self, query: str, limit: Optional[int]=None) -> List[Dict[str, Any]]
Search components by keyword, ranked by relevance.
Parameters
query
str
Search query string.
limit
int
= None
Maximum number of results to return.
None returns all matches.
Returns
results
List[dict]
Matching component metadata dictionaries, best match first.
add_hook
(self, event: str, callback: Callable) -> None
add_hook
(self, event: str, callback: Callable) -> None
Add a hook to be called on registry events.
Parameters
event
str
The event name ('on_register' or 'on_unregister').
callback
callable
The function to call. It will receive (class, info) as arguments.
Raises
ValueError
If the event name is unknown.