Spaces:
Running on Zero
Running on Zero
MrNK2107 commited on
Commit ·
dca5007
1
Parent(s): dd1ae0b
fix(deploy): build index in startup event since HF Spaces ignores CMD
Browse files- Dockerfile +1 -1
- app.py +6 -0
Dockerfile
CHANGED
|
@@ -27,4 +27,4 @@ USER user
|
|
| 27 |
ENV HOME=/home/user \
|
| 28 |
PATH=/home/user/.local/bin:$PATH
|
| 29 |
|
| 30 |
-
CMD ["
|
|
|
|
| 27 |
ENV HOME=/home/user \
|
| 28 |
PATH=/home/user/.local/bin:$PATH
|
| 29 |
|
| 30 |
+
CMD ["python", "app.py"]
|
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import sys
|
| 2 |
from pathlib import Path
|
| 3 |
|
|
@@ -23,6 +24,11 @@ def _gpu_placeholder():
|
|
| 23 |
@app.on_event("startup")
|
| 24 |
def startup_event():
|
| 25 |
global harness
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
print("Initializing VoiceRAGHarness and preloading embedding model...")
|
| 27 |
harness = VoiceRAGHarness()
|
| 28 |
print("VoiceRAGHarness initialized successfully.")
|
|
|
|
| 1 |
+
import os
|
| 2 |
import sys
|
| 3 |
from pathlib import Path
|
| 4 |
|
|
|
|
| 24 |
@app.on_event("startup")
|
| 25 |
def startup_event():
|
| 26 |
global harness
|
| 27 |
+
from app.config import settings
|
| 28 |
+
if not os.path.exists(settings.sqlite_fts_path):
|
| 29 |
+
print("Index not found. Building from HF dataset (~5-10 min)...")
|
| 30 |
+
os.system("python scripts/build_index.py --languages hin --max-rows 500")
|
| 31 |
+
print("Index build complete.")
|
| 32 |
print("Initializing VoiceRAGHarness and preloading embedding model...")
|
| 33 |
harness = VoiceRAGHarness()
|
| 34 |
print("VoiceRAGHarness initialized successfully.")
|