davanstrien HF Staff commited on
Commit
c084cd8
·
verified ·
1 Parent(s): 22c5066

db: prefer bucket-mounted /data/lineage.db with baked-in fallback

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -18,7 +18,13 @@ from fastapi import FastAPI, Query, Request
18
  from fastapi.middleware.gzip import GZipMiddleware
19
  from fastapi.responses import HTMLResponse, JSONResponse
20
 
21
- DB = Path(__file__).parent / "lineage.db"
 
 
 
 
 
 
22
  # High safety ceiling only — stops a depth-2 hub exploding to tens of thousands
23
  # of nodes. Normal hubs (incl. FLAN's ~1.4k children) render fully.
24
  MAX_NODES = 2500
 
18
  from fastapi.middleware.gzip import GZipMiddleware
19
  from fastapi.responses import HTMLResponse, JSONResponse
20
 
21
+ # Prefer the bucket-mounted DB (/data/lineage.db, persistent + can grow);
22
+ # fall back to the baked-in copy if the mount isn't present (cold-mount fail,
23
+ # local dev, etc.) so the Space stays up either way.
24
+ BUCKET_DB = Path("/data/lineage.db")
25
+ LOCAL_DB = Path(__file__).parent / "lineage.db"
26
+ DB = BUCKET_DB if BUCKET_DB.exists() else LOCAL_DB
27
+ print(f"using DB: {DB} (bucket-mount={BUCKET_DB.exists()})", flush=True)
28
  # High safety ceiling only — stops a depth-2 hub exploding to tens of thousands
29
  # of nodes. Normal hubs (incl. FLAN's ~1.4k children) render fully.
30
  MAX_NODES = 2500