Registry¶
Functions for registering and discovering components.
Registration¶
register_component(component_func: Optional[Callable] = None, component_type: str = 'both') -> Callable
¶
Register a component function in the registry.
Adds the component to the global registry and appropriate component type sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_func
|
Optional[Callable]
|
Function that creates a component. When used as a decorator without arguments, this will be the decorated function. |
None
|
component_type
|
str
|
Type of component. Must be one of "signal", "feature", or "both". Determines which registries the component is added to. |
'both'
|
Returns:
| Name | Type | Description |
|---|---|---|
Callable |
Callable
|
The original function, unchanged but now registered. |
Source code in xaitimesynth/registry.py
register_component_generator(name: Optional[str] = None, component_type: str = 'both', **default_overrides) -> Callable
¶
Register a generator function and create a component function.
This decorator simplifies component creation by automatically: 1. Creating a component definition function based on the generator 2. Registering both in the appropriate registries 3. Exposing the component function in the generator's module namespace
The component name is determined as follows: - If the 'name' parameter is provided, that exact name is used - Otherwise, the function's name is used, with the 'generate_' prefix removed if present
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
Optional custom name for the component. If not provided, derives name from the generator function name. |
None
|
component_type
|
str
|
Type of component. Must be one of "signal", "feature", or "both". Determines which registries the component is added to. |
'both'
|
**default_overrides
|
Override default parameter values for the component function. These will replace the default values in the generator function. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Callable |
Callable
|
Decorator function that processes the generator function. |
Examples:
Basic usage - creates component named "sine_wave"¶
@register_component_generator() def generate_sine_wave(n_timesteps, rng, length=None, frequency=0.1): # Implementation...
Explicit naming - creates component named "my_sine"¶
@register_component_generator(name="my_sine") def generate_wave(n_timesteps, rng, length=None, frequency=0.1): # Implementation...
Override default values - component default amplitude will be 2.0¶
@register_component_generator(amplitude=2.0) def generate_sine_wave(n_timesteps, rng, length=None, amplitude=1.0): # Implementation...
Source code in xaitimesynth/registry.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
Discovery¶
list_components() -> Dict[str, Callable]
¶
List all registered components.
Provides a copy of the complete component registry.
Returns:
| Type | Description |
|---|---|
Dict[str, Callable]
|
Dict[str, Callable]: Dictionary mapping component names to their creation functions. |
Source code in xaitimesynth/registry.py
list_signal_components() -> Dict[str, Callable]
¶
List components commonly used as signals.
Returns a dictionary of all components registered with the "signal" type.
Returns:
| Type | Description |
|---|---|
Dict[str, Callable]
|
Dict[str, Callable]: Dictionary mapping signal component names to their creation functions. |
Source code in xaitimesynth/registry.py
list_feature_components() -> Dict[str, Callable]
¶
List components commonly used as features.
Returns a dictionary of all components registered with the "feature" type.
Returns:
| Type | Description |
|---|---|
Dict[str, Callable]
|
Dict[str, Callable]: Dictionary mapping feature component names to their creation functions. |
Source code in xaitimesynth/registry.py
get_component_parameters(component_name: str) -> Dict[str, Any]
¶
Get parameters for a component.
Retrieves the parameter names and default values for a registered component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_name
|
str
|
Name of the component in the registry. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Dictionary mapping parameter names to their default values. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the component_name is not found in the registry. |