Estherrr777 commited on
Commit
ab69d6d
·
verified ·
1 Parent(s): 29c6ddb

Update backend/app/main.py

Browse files
Files changed (1) hide show
  1. backend/app/main.py +4 -3
backend/app/main.py CHANGED
@@ -8,17 +8,18 @@ app = FastAPI(
8
  version="1.0.0"
9
  )
10
 
 
11
  @app.get("/")
12
  def root():
13
  return {"message": "👶 Hello from Mila-Wellnest Backend API"}
14
 
15
- # Mount your prediction endpoint
16
  app.include_router(router)
17
 
18
- # Optional: Run training once on startup if model is missing
19
  @app.on_event("startup")
20
  async def startup_event():
21
- checkpoint_path = "./data/best_model" # ✅ persistent path
22
  if not os.path.exists(checkpoint_path):
23
  os.makedirs(checkpoint_path, exist_ok=True)
24
  print("⚙️ No checkpoint found. Starting training...")
 
8
  version="1.0.0"
9
  )
10
 
11
+ # Root health check
12
  @app.get("/")
13
  def root():
14
  return {"message": "👶 Hello from Mila-Wellnest Backend API"}
15
 
16
+ # Mount the /predict endpoint from routes.py
17
  app.include_router(router)
18
 
19
+ # On startup: Train the model if no saved checkpoint exists
20
  @app.on_event("startup")
21
  async def startup_event():
22
+ checkpoint_path = "./data/best_model"
23
  if not os.path.exists(checkpoint_path):
24
  os.makedirs(checkpoint_path, exist_ok=True)
25
  print("⚙️ No checkpoint found. Starting training...")