Spaces:
Build error
Build error
AdarshRajDS commited on
Commit ·
c4bd82a
1
Parent(s): b1316bc
Fix outputs directory for HF runtime
Browse files- app/main.py +8 -9
app/main.py
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from fastapi.staticfiles import StaticFiles
|
| 3 |
-
from app.api.routes import rag
|
| 4 |
-
from app.api.routes import rag, visualize
|
| 5 |
-
from app.api.routes import rag, visualize, grading
|
| 6 |
|
| 7 |
from app.api.routes import rag, visualize, grading, upload
|
| 8 |
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
|
|
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
app = FastAPI(title="Multimodal RAG API")
|
| 15 |
|
| 16 |
app.include_router(rag.router)
|
| 17 |
-
|
| 18 |
app.include_router(visualize.router)
|
| 19 |
-
|
| 20 |
app.include_router(grading.router)
|
| 21 |
-
|
| 22 |
app.include_router(upload.router)
|
| 23 |
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
app.mount("/outputs", StaticFiles(directory="outputs"), name="outputs")
|
| 28 |
|
| 29 |
|
| 30 |
@app.get("/")
|
|
|
|
| 1 |
+
import os
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from fastapi.staticfiles import StaticFiles
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
from app.api.routes import rag, visualize, grading, upload
|
| 6 |
|
| 7 |
|
| 8 |
+
# ✅ Use persistent storage on HF, local folder otherwise
|
| 9 |
+
BASE_DATA_DIR = os.getenv("HF_HOME", ".")
|
| 10 |
|
| 11 |
+
OUTPUT_DIR = os.path.join(BASE_DATA_DIR, "outputs")
|
| 12 |
|
| 13 |
+
# ✅ Create the folder BEFORE mounting
|
| 14 |
+
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
| 15 |
|
| 16 |
|
| 17 |
app = FastAPI(title="Multimodal RAG API")
|
| 18 |
|
| 19 |
app.include_router(rag.router)
|
|
|
|
| 20 |
app.include_router(visualize.router)
|
|
|
|
| 21 |
app.include_router(grading.router)
|
|
|
|
| 22 |
app.include_router(upload.router)
|
| 23 |
|
| 24 |
|
| 25 |
+
# ✅ Mount the real path (not hardcoded "outputs")
|
| 26 |
+
app.mount("/outputs", StaticFiles(directory=OUTPUT_DIR), name="outputs")
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
@app.get("/")
|