""" Compatibility wrapper for search-behavior config access. The unified loader lives in :mod:`config.loader`. This module now exposes the search subtree only, so existing search/indexer code can consume a single source-of-truth search config without reparsing YAML separately. """ from __future__ import annotations from dataclasses import asdict from pathlib import Path from typing import Any, Dict, List, Optional from config.loader import AppConfigLoader, ConfigurationError from config.schema import ( FunctionScoreConfig, IndexConfig, QueryConfig, RerankConfig, SPUConfig, SearchConfig, ) class ConfigLoader: """Load the unified app config and return the search subtree.""" def __init__(self, config_file: Optional[Path] = None) -> None: self._loader = AppConfigLoader(config_file=Path(config_file) if config_file is not None else None) def load_config(self, validate: bool = True) -> SearchConfig: return self._loader.load(validate=validate).search def validate_config(self, config: SearchConfig) -> List[str]: errors: List[str] = [] if not config.es_index_name: errors.append("es_index_name is required") if not config.field_boosts: errors.append("field_boosts is empty") if config.query_config.default_language not in config.query_config.supported_languages: errors.append("default_language must be included in supported_languages") if config.spu_config.enabled and not config.spu_config.spu_field: errors.append("spu_field is required when SPU is enabled") return errors def to_dict(self, config: SearchConfig) -> Dict[str, Any]: return asdict(config)