| """ |
| 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 <root>/data) |
| QDRANT_LOCAL_PATH -> Qdrant on-disk store (build scratch) |
| QDRANT_SNAPSHOT_DIR -> committed Qdrant snapshots |
| """ |
|
|
| import os |
| from pathlib import Path |
|
|
| |
| PROJECT_ROOT = Path(__file__).resolve().parents[2] |
|
|
| DATA_DIR = Path(os.environ.get("AGADVISOR_DATA_DIR", PROJECT_ROOT / "data")) |
|
|
| |
| PDF_DIR = DATA_DIR / "pdfs" / "cdms" |
|
|
| |
| DB_PATH = DATA_DIR / "cdms_metadata.db" |
|
|
| |
| |
| APP_DIR = DATA_DIR / "app" |
| ACCOUNTS_DB_PATH = Path(os.environ.get("AGADVISOR_ACCOUNTS_DB") or (APP_DIR / "agadvisor_users.db")) |
|
|
| |
| |
| QDRANT_DIR = Path(os.environ.get("QDRANT_LOCAL_PATH") or (DATA_DIR / "qdrant_local")) |
|
|
| |
| SNAPSHOT_DIR = Path(os.environ.get("QDRANT_SNAPSHOT_DIR") or (DATA_DIR / "qdrant_snapshots")) |
|
|
| |
| |
| 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) |
|
|