Configuration
This section contains auto-generated documentation for configuration modules.
Config Module
Pydantic models for service configuration.
- class routir.config.config.ServiceConfig(*, name, engine, config, processor='BatchQueryProcessor', cache=-1, batch_size=32, cache_ttl=600, max_wait_time=0.05, cache_key_fields=<factory>, cache_redis_url=None, cache_redis_kwargs=<factory>, scoring_disabled=False)[source]
Bases:
BaseModelConfiguration for a single search or ranking service.
One
ServiceConfigentry in the"services"list corresponds to one loaded engine, one search processor, and optionally one scoring processor registered inProcessorRegistry.Example JSON:
{ "name": "my-retriever", "engine": "Qwen3", "config": { "index_path": "/data/qwen3-index", "embedding_model_name": "Qwen/Qwen3-Embedding-8B" }, "cache": 4096, "cache_ttl": 600, "batch_size": 16, "max_wait_time": 0.05 }
- name
Service identifier used in API requests (the
"service"field) and as the key inProcessorRegistry.- Type:
- engine
Class name of the
Enginesubclass to instantiate. Must be importable at startup — either a built-in engine or one loaded viafile_imports.- Type:
- config
Engine-specific parameters passed as
config=to the engine constructor. Content varies by engine; see the engine’s__init__for accepted keys. The special key"index_path"with thehfds:<repo>prefix triggers automatic download from Hugging Face Datasets.- Type:
- processor
Class name of the
BatchProcessorsubclass for the search role. Default"BatchQueryProcessor"works for most engines. Override only if you need custom batching or request logic.- Type:
- cache
In-memory LRU cache size for search results (number of entries).
-1(default) disables the cache entirely. Ignored whencache_redis_urlis set.- Type:
- cache_ttl
Cache entry time-to-live in seconds (default 600). Applies to both LRU and Redis caches.
- Type:
- batch_size
Maximum requests accumulated into one batch before the engine processes them (default 32).
- Type:
- max_wait_time
Maximum seconds to wait for a batch to fill before processing a partial batch (default 0.05 s). Lower values reduce latency; higher values improve GPU utilisation.
- Type:
- cache_key_fields
Request fields included in the cache key. Default
["query", "limit"]. Add extra fields (e.g."subset") whenever they affect the results.
- cache_redis_url
Redis connection URL for distributed caching (e.g.
"redis://localhost:6379"). When set, Redis replaces the in-memory LRU cache.- Type:
str, optional
- cache_redis_kwargs
Additional keyword arguments forwarded to the Redis client (e.g.
{"password": "…", "db": 1}).- Type:
dict, optional
- scoring_disabled
When
True, the scoring/reranking processor for this service is not registered even if the engine implementsscore_batch. Useful when you want search-only access to an engine that also supports reranking.- Type:
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class routir.config.config.CollectionConfig(*, name, doc_path=None, processor='ContentProcessor', offset_source='offsetfile', id_field='id', content_field='text', id_to_lang_mapping=None, cache_path=None, force_load_all_documents=False)[source]
Bases:
BaseModelConfiguration for a document collection.
Collections expose the
/contentendpoint and are used by reranking pipeline stages to fetch document text by ID.Note
The class name has a historical typo (three
ls). It is kept as-is to avoid breaking existing imports.Example JSON:
{ "name": "my-corpus", "doc_path": "/data/corpus.jsonl", "id_field": "docid", "content_field": "text" }
- name
Collection identifier used in API requests (the
"collection"field) and as the key inProcessorRegistry.- Type:
- doc_path
Path to the JSONL (or gzip-compressed) document file. Each line must be a JSON object. May be a local path or an
hfds:<repo>URL for Hugging Face Datasets.- Type:
str, optional
- processor
Class name of the content-processor to use. Default
"ContentProcessor"provides offset-based random access. Use"IRDSProcessor"to load from anir_datasetsdataset ID.- Type:
- offset_source
Strategy for random document access:
"offsetfile"(default) — builds a byte-offset map (.offsetmapsidecar file) for fast O(1) lookup in a JSONL file."msmarco_seg"— reads from sharded gzipped files in the MSMARCO v2.1 segmented document format, using embedded byte offsets from the document ID.
- Type:
- content_field
JSON key(s) whose values are concatenated (space-joined) to form the document text returned by
/content. Accepts a single string or a list for multi-field concatenation (e.g.["title", "body"]). Always stored as a list internally after validation.
- id_to_lang_mapping
Path to a pickle file mapping document IDs to language codes. Used by processors that serve multilingual corpora.
- Type:
str, optional
- cache_path
Directory for the
.offsetmapcache file. Defaults to the same directory asdoc_path.- Type:
str, optional
- force_load_all_documents
When
True, all documents are loaded into memory at startup for maximum throughput. Only suitable for small corpora; defaultFalseuses on-demand offset-based access.- Type:
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class routir.config.config.Config(*, services=<factory>, collections=<factory>, server_imports=<factory>, file_imports=<factory>, dynamic_pipeline=True)[source]
Bases:
BaseModelTop-level configuration for the RoutIR service.
Passed as a JSON file (or JSON string) to
routir <config.json>. Parsed byload_config(), which initialises all collections and services and registers them withProcessorRegistry.Example JSON skeleton:
{ "file_imports": ["./my_engine.py"], "collections": [ { "name": "my-corpus", "doc_path": "/data/corpus.jsonl" } ], "services": [ { "name": "my-retriever", "engine": "MyEngine", "config": {"index_path": "/data/index"} } ], "server_imports": ["http://other-host:5000"] }
- services
Search/ranking services to load and register. Each entry loads one engine and creates its processors.
- Type:
- collections
Document collections to register as content services. Required for reranking pipeline stages.
- Type:
- server_imports
URLs of remote RoutIR servers whose services are proxied locally via
Relay. Discovered automatically from each server’s/availendpoint at startup.
- file_imports
Paths to Python files loaded before any service is initialised. Use this to register custom
Enginesubclasses.
- dynamic_pipeline
When
True(default), the/pipelineendpoint accepts arbitrary pipeline DSL strings at request time. Set toFalseto restrict the server to pre-defined services only.- Type:
- services: List[ServiceConfig]
- collections: List[CollectionConfig]
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].