Registries¶
Named plugin registries used by the CLI and RetargetingProblem resolution.
Extension registries support direct instances, zero-argument factories, and decorated classes for protocol-backed components. Decorated classes are instantiated immediately and validated against their protocol.
Registry
¶
Registry(
name: str,
key_type: type[K],
*,
decorator_transform: Callable[[object], T] | None = None,
)
Bases: Generic[K, T]
Small decorator-friendly registry.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Human-readable registry label used in error messages. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Registry label included in lookup errors. |
required |
decorator_transform
|
Callable[[object], T] | None
|
Optional wrapper applied when registering via the decorator form. |
None
|
Methods:
| Name | Description |
|---|---|
register |
Register a value directly or as a decorator. |
get |
Return a registered value. |
get_serialized |
Resolve a serialized key at a configuration or CLI boundary. |
key_from_serialized |
Return the registered enum member for a serialized value. |
maybe_get |
Return a registered value or |
names |
Registered names in sorted order. |
values |
Registered values ordered by sorted key. |
items |
Registered |
require_all |
Validate that every key exists. |
missing |
Return missing keys in first-seen order. |
Attributes¶
Functions¶
register
¶
register(
key: K, value: T | None = None, *, replace: bool = False
) -> Callable[[T], T] | T
Register a value directly or as a decorator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
K
|
Typed enum member used as the registry key. |
required |
value
|
T | None
|
Object to register; omit to use as |
None
|
replace
|
bool
|
Allow overwriting an existing key. |
False
|
Returns:
| Type | Description |
|---|---|
Callable[[T], T] | T
|
Callable[[T], T] | T: The decorator when |
get
¶
get(key: K) -> T
Return a registered value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
K
|
Typed enum member to look up. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
T |
T
|
Registered value for |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
get_serialized
¶
get_serialized(value: str) -> T
Resolve a serialized key at a configuration or CLI boundary.
key_from_serialized
¶
key_from_serialized(value: str) -> K
Return the registered enum member for a serialized value.
maybe_get
¶
maybe_get(key: K) -> T | None
Return a registered value or None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
K
|
Typed enum member to look up. |
required |
Returns:
| Type | Description |
|---|---|
T | None
|
T | None: Registered value, or |
require_all
¶
require_all(keys: Iterable[K]) -> None
Validate that every key exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Iterable[K]
|
Typed keys that must be registered. |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
If any key in |
missing
¶
missing(keys: Iterable[K]) -> tuple[str, ...]
Return missing keys in first-seen order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Iterable[K]
|
Typed keys to check for registration. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
tuple[str, ...]: Normalized keys from |
Built-in registry instances¶
Each name below is a shared Registry instance. Use .get(name), .register(...), and .names() in application code. Built-in keys have StrEnum aliases such as Robot.SYNTHETIC_HUMANOID, MotionFormat.MINIMAL, Objective.LAPLACIAN, and Constraint.JOINT_LIMITS; custom extension keys remain plain strings.
robots
module-attribute
¶
robots: Registry[RobotKind, AnyRobotSpec] = Registry(
"robot", RobotKind, decorator_transform=_robot_spec_from_decorator
)
robot_providers
module-attribute
¶
robot_providers: Registry[RobotProviderKind, RobotProvider] = Registry(
"robot provider",
RobotProviderKind,
decorator_transform=_robot_provider_from_decorator,
)
motion_formats
module-attribute
¶
motion_formats: Registry[MotionFormatKind, MotionFormatSpec] = Registry(
"motion format", MotionFormatKind, decorator_transform=_motion_format_from_decorator
)
Registry of built-in :class:~retarget.motion.spec.MotionFormatSpec entries.
motion_loaders
module-attribute
¶
motion_loaders: Registry[MotionLoaderKind, MotionLoader] = Registry(
"motion loader", MotionLoaderKind, decorator_transform=_motion_loader_from_decorator
)
Registry of file-suffix :class:~retarget.core.protocols.MotionLoader implementations.
kinematics_backends
module-attribute
¶
kinematics_backends: Registry[KinematicsKind, KinematicsBackendFactory] = Registry(
"kinematics backend", KinematicsKind
)
Registry of kinematics backend factories keyed by backend name.
objective_terms
module-attribute
¶
objective_terms: Registry[ObjectiveKind, ObjectiveTerm[Any]] = Registry(
"objective term", ObjectiveKind, decorator_transform=_objective_term_from_decorator
)
Registry of built-in and user-registered objective terms keyed by name.
constraint_terms
module-attribute
¶
constraint_terms: Registry[ConstraintKind, ConstraintTerm[Any]] = Registry(
"constraint term",
ConstraintKind,
decorator_transform=_constraint_term_from_decorator,
)
Registry of built-in and user-registered constraint terms keyed by name.
solver_factories
module-attribute
¶
solver_factories: Registry[SolverKind, SolverFactory] = Registry(
"solver factory", SolverKind
)
Registry of solver factories keyed by :class:~retarget.core.enums.SolverBackend name.
metrics
module-attribute
¶
metrics: Registry[MetricKind, Metric] = Registry(
"metric", MetricKind, decorator_transform=_metric_from_decorator
)
Registry of built-in and user-registered result metrics keyed by :class:~retarget.core.enums.MetricName.
exporters
module-attribute
¶
exporters: Registry[ExporterKind, Exporter] = Registry(
"exporter", ExporterKind, decorator_transform=_exporter_from_decorator
)
visualizers
module-attribute
¶
visualizers: Registry[VisualizerKind, Visualizer] = Registry(
"visualizer", VisualizerKind, decorator_transform=_visualizer_from_decorator
)