ann_router.config module

Load the shipped YAML config (policy thresholds, backend + hardware catalogs).

The suite keeps its data in commented YAML next to the code (best-engine’s models.yaml / hardware.yaml); ann-router does the same with policy.yaml (the tunable thresholds), backends.yaml (the prose backend catalog) and hardware.yaml (the accelerator profiles). This module is the single reader for them: the Python constants in ann_router.policy stay the canonical defaults, and these functions let an operator override the thresholds from a YAML file (or the ANN_ROUTER_POLICY env var) without touching code — the “example config, profusely commented” house rule.

Consumes: pyyaml; the packaged *.yaml files (via importlib.resources). Produces: policy_thresholds(), backend_catalog(), hardware_profiles().

Author: Warith Harchaoui <warith.harchaoui@deraison.ai>

ann_router.config.backend_catalog()[source]

Return the prose backend catalog from backends.yaml.

Returns:

One entry per backend: name, summary, when, pip_extra.

Return type:

list of dict

Examples

>>> {b["name"] for b in backend_catalog()} >= {"exact", "hnsw", "faiss"}
True
ann_router.config.hardware_profiles()[source]

Return the accelerator profiles from hardware.yaml.

Returns:

One entry per hardware class: hardware, summary, unlocks.

Return type:

list of dict

Examples

>>> sorted(p["hardware"] for p in hardware_profiles())
['apple_silicon', 'cpu', 'gpu']
ann_router.config.policy_thresholds(path=None)[source]

Return the policy thresholds, optionally overridden from a YAML file.

Resolution order: the in-code ann_router.policy.THRESHOLDS defaults, overlaid with the packaged policy.yaml, overlaid with an external file (path argument or the ANN_ROUTER_POLICY env var) if present.

Parameters:

path (str, optional) – Path to an external policy.yaml to overlay. Falls back to the ANN_ROUTER_POLICY environment variable, then to no override.

Returns:

The merged {THRESHOLD_NAME: value} mapping, ready to pass to ann_router.policy.rank_backends().

Return type:

dict

Examples

>>> t = policy_thresholds()
>>> t["EXACT_MAX_N"]
1000