Initial commit - Trekker V2 source
This commit is contained in:
commit
d71faf19e3
65 files changed
+3615
No files matched your search
@@ -0,0 +1,74 @@
|
||||
"""Trekker configuration: env vars + optional YAML file (TREKKER_CONFIG)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
import yaml
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class WatchConfig(BaseModel):
|
||||
internal_path: Optional[str] = None
|
||||
remote_path: Optional[str] = None
|
||||
poll_interval: int = 30 # seconds, polling observer for remote mounts
|
||||
|
||||
|
||||
class LLMConfig(BaseModel):
|
||||
base_url: Optional[str] = None # e.g. http://localhost:11434/v1 for Ollama
|
||||
model: str = "gpt-4o-mini"
|
||||
api_key: Optional[str] = None
|
||||
|
||||
|
||||
class TilesConfig(BaseModel):
|
||||
# Raster basemap URL template. Default OSM is fine for interactive viewing;
|
||||
# bulk offline downloads need a source whose policy permits it (see PLAN.md),
|
||||
# hence the per-pack tile cap below.
|
||||
base_url: str = "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
# Terrarium-encoded terrain tiles (AWS Open Data, bulk download permitted).
|
||||
terrain_url: str = "https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"
|
||||
max_pack_tiles: int = 4000
|
||||
user_agent: str = "Trekker/0.1 (+https://github.com/claw-peyo/trekker)"
|
||||
|
||||
|
||||
class SyncConfig(BaseModel):
|
||||
peer_url: Optional[str] = None # e.g. http://neutron.tailnet:8000
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_prefix="TREKKER_", env_file=".env", extra="ignore")
|
||||
|
||||
data_dir: str = "data"
|
||||
host_role: str = "home" # home | neutron
|
||||
watch: WatchConfig = Field(default_factory=WatchConfig)
|
||||
llm: LLMConfig = Field(default_factory=LLMConfig)
|
||||
tiles: TilesConfig = Field(default_factory=TilesConfig)
|
||||
sync: SyncConfig = Field(default_factory=SyncConfig)
|
||||
|
||||
@property
|
||||
def db_path(self) -> str:
|
||||
return str(Path(self.data_dir) / "trekker.db")
|
||||
|
||||
@property
|
||||
def offline_maps_dir(self) -> str:
|
||||
return str(Path(self.data_dir) / "offline_maps")
|
||||
|
||||
@property
|
||||
def pdf_dir(self) -> str:
|
||||
return str(Path(self.data_dir) / "pdfs")
|
||||
|
||||
|
||||
def load_settings() -> Settings:
|
||||
"""Env settings, overlaid with YAML from TREKKER_CONFIG if present."""
|
||||
overrides: dict = {}
|
||||
config_path = os.environ.get("TREKKER_CONFIG", "trekker.yml")
|
||||
path = Path(config_path)
|
||||
if path.is_file():
|
||||
overrides = yaml.safe_load(path.read_text()) or {}
|
||||
return Settings(**overrides)
|
||||
|
||||
|
||||
settings = load_settings()
|
||||
Reference in new issue
Block a user