refactor(constants): single source of truth for data dir (#3368)

* refactor(constants): single source of truth for data dir + merge core/src constants

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs(contributing): use named src.constants for data paths, drop core/constants references

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mike
2026-06-08 09:58:52 +02:00
committed by GitHub
parent adc6ac9394
commit ac94885c84
56 changed files with 279 additions and 243 deletions
+4 -8
View File
@@ -14,6 +14,8 @@ Set EMBEDDING_URL in .env, e.g.:
import os
from src.constants import FASTEMBED_CACHE_DIR, EMBEDDING_ENDPOINT_FILE
# Windows: force HuggingFace/fastembed to COPY model files rather than symlink
# them. On a network-share/UNC cache dir Windows can't follow HF's symlinks
# ([WinError 1463] "symbolic link cannot be followed"), so ONNX fails to load the
@@ -117,10 +119,7 @@ class FastEmbedClient:
# Persistent cache under data/ so the model survives reboots and so
# the download lands exactly where the admin panel's _is_downloaded()
# check looks (both default to this same path).
cache_dir = os.getenv("FASTEMBED_CACHE_PATH") or os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
"data", "fastembed_cache",
)
cache_dir = FASTEMBED_CACHE_DIR
os.makedirs(cache_dir, exist_ok=True)
# Windows self-heal: the HuggingFace-hub cache stores model files as
# symlinks (snapshots/<rev>/model.onnx -> ../../blobs/<hash>). On a
@@ -188,10 +187,7 @@ class FastEmbedClient:
def _load_persisted_endpoint() -> dict:
"""Load the custom embedding endpoint saved from the admin panel."""
try:
endpoint_file = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
"data", "embedding_endpoint.json",
)
endpoint_file = EMBEDDING_ENDPOINT_FILE
if os.path.exists(endpoint_file):
import json
data = json.loads(open(endpoint_file, encoding="utf-8").read())