""" Project-root-anchored storage paths. Every storage location (PDFs, SQLite metadata DB, Qdrant local store, Qdrant snapshots) is derived from the repository root rather than the process working directory. Before this module the paths were hard-coded relative strings ("data/pdfs/cdms", "data/cdms_metadata.db", ...) resolved against CWD, so the app read a different (often empty) store depending on where it was launched from. Anchoring to PROJECT_ROOT makes the committed, preprocessed bundle load identically no matter the launch directory. Env overrides (all optional): AGADVISOR_DATA_DIR -> base data directory (default /data) QDRANT_LOCAL_PATH -> Qdrant on-disk store (build scratch) QDRANT_SNAPSHOT_DIR -> committed Qdrant snapshots """ import os from pathlib import Path # src/config/paths.py -> parents[0]=config, [1]=src, [2]=repo root PROJECT_ROOT = Path(__file__).resolve().parents[2] DATA_DIR = Path(os.environ.get("AGADVISOR_DATA_DIR", PROJECT_ROOT / "data")) # Raw CDMS label PDFs (the offline build ingests every *.pdf here). PDF_DIR = DATA_DIR / "pdfs" / "cdms" # SQLite chunk/metadata database. DB_PATH = DATA_DIR / "cdms_metadata.db" # Per-user accounts + chat-history DB (git-ignored; mirrored to a private HF # Dataset by src/accounts/hf_sync.py on deployed Spaces). APP_DIR = DATA_DIR / "app" ACCOUNTS_DB_PATH = Path(os.environ.get("AGADVISOR_ACCOUNTS_DB") or (APP_DIR / "agadvisor_users.db")) # Qdrant local on-disk store. Used only as build scratch now that served mode # reads from a Docker Qdrant restored from a snapshot. QDRANT_DIR = Path(os.environ.get("QDRANT_LOCAL_PATH") or (DATA_DIR / "qdrant_local")) # Committed, portable Qdrant snapshot(s) restored into the Docker Qdrant at deploy. SNAPSHOT_DIR = Path(os.environ.get("QDRANT_SNAPSHOT_DIR") or (DATA_DIR / "qdrant_snapshots")) # filename -> original cdms.net source URL, captured at download time so offline # citations still link the live label. URL_MANIFEST_PATH = PDF_DIR / "urls.json" def as_str(p: Path) -> str: """Convenience for call sites that still want a plain string path.""" return str(p)