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.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.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.THRESHOLDSdefaults, overlaid with the packagedpolicy.yaml, overlaid with an external file (pathargument or theANN_ROUTER_POLICYenv var) if present.- Parameters:
path (str, optional) – Path to an external
policy.yamlto overlay. Falls back to theANN_ROUTER_POLICYenvironment variable, then to no override.- Returns:
The merged
{THRESHOLD_NAME: value}mapping, ready to pass toann_router.policy.rank_backends().- Return type:
Examples
>>> t = policy_thresholds() >>> t["EXACT_MAX_N"] 1000