Files
awoooi/apps/api/src/services/snapshot_paths.py
Your Name c28212027c
Some checks failed
CD Pipeline / tests (push) Successful in 1m23s
Code Review / ai-code-review (push) Successful in 13s
CD Pipeline / build-and-deploy (push) Failing after 3m52s
CD Pipeline / post-deploy-checks (push) Has been skipped
fix(api): resolve snapshot paths in production image
2026-06-04 22:26:44 +08:00

33 lines
1018 B
Python

"""
Snapshot path helpers.
Resolve committed documentation snapshot paths across local repo checkouts and
production API images. In containers, service modules live under
``/app/src/services`` instead of ``apps/api/src/services``.
"""
from __future__ import annotations
from pathlib import Path
def resolve_repo_root(anchor: Path) -> Path:
"""Resolve the repository root that contains committed docs snapshots."""
resolved = anchor.resolve()
start = resolved if resolved.is_dir() else resolved.parent
for candidate in (start, *start.parents):
if (candidate / "docs").is_dir():
return candidate
container_root = Path("/app")
if (container_root / "docs").is_dir():
return container_root
parents = list(start.parents)
return parents[2] if len(parents) > 2 else start
def default_evaluations_dir(anchor: Path) -> Path:
"""Resolve the default committed evaluations snapshot directory."""
return resolve_repo_root(anchor) / "docs" / "evaluations"