Source code for openworld_radio_twin.config

from functools import lru_cache
from pathlib import Path

from pydantic_settings import BaseSettings, SettingsConfigDict

DEFAULT_AUTOMATIC_BUILDING_SOURCES = ("3dbag", "berlin", "boston")


[docs] class Settings(BaseSettings): model_config = SettingsConfigDict(env_prefix="OWRT_", env_file=".env", extra="ignore") host: str = "127.0.0.1" port: int = 8765 location_provider: str = "osm_nominatim" cache_ttl_seconds: int = 900 max_buildings: int = 5000 max_view_buildings: int = 7500 automatic_building_sources: tuple[str, ...] = DEFAULT_AUTOMATIC_BUILDING_SOURCES boston_source_catalog: Path | None = None max_surface_features_per_theme: int = 20_000 http_request_timeout_seconds: int = 60 overture_connect_timeout_seconds: int = 15 overture_request_timeout_seconds: int = 60 user_agent: str = ( "OpenWorldRadioTwin/0.1 (+https://github.com/zhiheng-yang/openworld-radio-twin)" ) overpass_url: str = "https://overpass-api.de/api/interpreter" nominatim_url: str = "https://nominatim.openstreetmap.org/search" dataset_root: Path = Path("data/generated") scene_cache_root: Path | None = None overture_index_root: Path | None = None engine_spec_directory: Path | None = None model_deployment_file: Path | None = Path("config/model-deployments.json") @property def package_root(self) -> Path: return Path(__file__).resolve().parent @property def project_root(self) -> Path: """Checkout root when the package runs from source, else the working directory.""" for parent in self.package_root.parents: if (parent / "pyproject.toml").is_file(): return parent return Path.cwd() @property def cache_root(self) -> Path: """Directory holding every cache the project writes.""" return self.project_root / ".cache" @property def web_root(self) -> Path: return self.package_root / "web"
[docs] @lru_cache def get_settings() -> Settings: return Settings()