added route to download model
Browse files
app.py
CHANGED
|
@@ -463,6 +463,19 @@ def download_video(job_id: str):
|
|
| 463 |
|
| 464 |
return FileResponse(path, media_type='video/mp4', filename=f"training_replay_{job_id}.mp4")
|
| 465 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 466 |
# WebSocket Endpoint
|
| 467 |
|
| 468 |
@app.websocket("/ws/render/{job_id}")
|
|
|
|
| 463 |
|
| 464 |
return FileResponse(path, media_type='video/mp4', filename=f"training_replay_{job_id}.mp4")
|
| 465 |
|
| 466 |
+
@app.get("/download/{job_id}/model")
|
| 467 |
+
def download_model(job_id: str):
|
| 468 |
+
"""Download model with filesystem fallback"""
|
| 469 |
+
# 1. Try memory
|
| 470 |
+
job = training_jobs.get(job_id)
|
| 471 |
+
file_path = None
|
| 472 |
+
if job and job.get("results"):
|
| 473 |
+
file_path = job["results"].get("model_path")
|
| 474 |
+
|
| 475 |
+
if not file_path or not os.path.exists(file_path):
|
| 476 |
+
raise HTTPException(status_code=404, detail="Model file not found")
|
| 477 |
+
|
| 478 |
+
return FileResponse(file_path, media_type='application/octet-stream', filename=f"model_{job_id}.zip")
|
| 479 |
# WebSocket Endpoint
|
| 480 |
|
| 481 |
@app.websocket("/ws/render/{job_id}")
|