WickTech commited on
Commit
f13535a
·
verified ·
1 Parent(s): 97481d0

Fix sample-dir path resolution for deployed layout

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -15,8 +15,19 @@ from lumen_rag.eval.harness import load_cases
15
  from lumen_rag.ingestion.loaders import _LOADERS, load_file
16
  from lumen_rag.retrieval import Retriever
17
 
18
- _SAMPLE_DIR = Path(__file__).resolve().parent.parent.parent / "data" / "docs"
19
- _EVAL_PATH = Path(__file__).resolve().parent.parent.parent / "data" / "eval.jsonl"
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  engine = RagEngine()
22
 
 
15
  from lumen_rag.ingestion.loaders import _LOADERS, load_file
16
  from lumen_rag.retrieval import Retriever
17
 
18
+ def _find_repo_root() -> Path:
19
+ # Locally this file lives at deploy/hf-space/gradio_app.py (repo root 3 up);
20
+ # on the deployed Space it's copied to app.py at the repo root (0 up).
21
+ here = Path(__file__).resolve().parent
22
+ for candidate in (here, here.parent.parent.parent):
23
+ if (candidate / "data" / "docs").is_dir():
24
+ return candidate
25
+ return here
26
+
27
+
28
+ _REPO_ROOT = _find_repo_root()
29
+ _SAMPLE_DIR = _REPO_ROOT / "data" / "docs"
30
+ _EVAL_PATH = _REPO_ROOT / "data" / "eval.jsonl"
31
 
32
  engine = RagEngine()
33