ann_router.registry module
Backend registry — the single lookup table from name to adapter class.
Every backend adapter is a subclass of ann_router.base.ANNIndex; this
module is the one place that maps the seven backend names to those classes and
answers the two questions the router asks about each: what can it do
(capabilities, readable without the dependency) and can it run here (is the
optional dependency importable). Importing this module — and therefore
ann_router — must stay dependency-free, so the adapter modules it imports
all defer their heavy imports.
Consumes: the seven ann_router.backends.* adapter modules.
Produces: BACKENDS, get_backend(), available_backends(),
all_capabilities().
Author: Warith Harchaoui <warith.harchaoui@deraison.ai>
- ann_router.registry.all_capabilities()[source]
Return the capability descriptor of every registered backend.
- Returns:
{name: Capabilities}— readable even for uninstalled backends.- Return type:
Examples
>>> all_capabilities()["annoy"].supports_remove False
- ann_router.registry.available_backends()[source]
Return the names of backends whose dependency is importable here.
Examples
>>> "exact" in available_backends() # numpy is always present True
- ann_router.registry.get_backend(name)[source]
Return the adapter class registered under
name.- Parameters:
name (str) – A backend identifier (see
ann_router.spec.BackendName).- Returns:
The adapter class (not an instance).
- Return type:
- Raises:
KeyError – If
nameis not a known backend.
Examples
>>> get_backend("exact").__name__ 'ExactIndex'