Spaces:
Runtime error
Runtime error
Peter Michael Gits Claude commited on
Commit ·
d764d2b
1
Parent(s): bb8fb42
Fix OpenMP warning and application restart loop
Browse filesv1.3.9 - Fixed remaining deployment issues:
1. Moved OMP_NUM_THREADS environment variable BEFORE torch import
(was causing 'Invalid value for environment variable' warning)
2. Added reload=False to uvicorn.run() to prevent restart loop
3. Updated version to v1.3.9
Both outstanding issues from logs now resolved
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
|
@@ -6,6 +6,14 @@ import os
|
|
| 6 |
from typing import Optional
|
| 7 |
from contextlib import asynccontextmanager
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
import torch
|
| 10 |
import numpy as np
|
| 11 |
from fastapi import FastAPI, WebSocket, WebSocketDisconnect, HTTPException
|
|
@@ -13,21 +21,13 @@ from fastapi.responses import JSONResponse, HTMLResponse
|
|
| 13 |
import uvicorn
|
| 14 |
|
| 15 |
# Version tracking
|
| 16 |
-
VERSION = "1.3.
|
| 17 |
COMMIT_SHA = "TBD"
|
| 18 |
|
| 19 |
# Configure logging
|
| 20 |
logging.basicConfig(level=logging.INFO)
|
| 21 |
logger = logging.getLogger(__name__)
|
| 22 |
|
| 23 |
-
# Fix OpenMP warning
|
| 24 |
-
os.environ['OMP_NUM_THREADS'] = '1'
|
| 25 |
-
|
| 26 |
-
# Fix cache directory permissions - set to writable directory
|
| 27 |
-
os.environ['HF_HOME'] = '/app/hf_cache'
|
| 28 |
-
os.environ['HUGGINGFACE_HUB_CACHE'] = '/app/hf_cache'
|
| 29 |
-
os.environ['TRANSFORMERS_CACHE'] = '/app/hf_cache'
|
| 30 |
-
|
| 31 |
# Create cache directory if it doesn't exist
|
| 32 |
os.makedirs('/app/hf_cache', exist_ok=True)
|
| 33 |
|
|
@@ -391,11 +391,12 @@ async def api_transcribe(audio_file: Optional[str] = None):
|
|
| 391 |
return result
|
| 392 |
|
| 393 |
if __name__ == "__main__":
|
| 394 |
-
# Run the server
|
| 395 |
uvicorn.run(
|
| 396 |
"app:app",
|
| 397 |
host="0.0.0.0",
|
| 398 |
port=7860,
|
| 399 |
log_level="info",
|
| 400 |
-
access_log=True
|
|
|
|
| 401 |
)
|
|
|
|
| 6 |
from typing import Optional
|
| 7 |
from contextlib import asynccontextmanager
|
| 8 |
|
| 9 |
+
# Fix OpenMP warning - MUST be set before importing torch
|
| 10 |
+
os.environ['OMP_NUM_THREADS'] = '1'
|
| 11 |
+
|
| 12 |
+
# Fix cache directory permissions - set to writable directory
|
| 13 |
+
os.environ['HF_HOME'] = '/app/hf_cache'
|
| 14 |
+
os.environ['HUGGINGFACE_HUB_CACHE'] = '/app/hf_cache'
|
| 15 |
+
os.environ['TRANSFORMERS_CACHE'] = '/app/hf_cache'
|
| 16 |
+
|
| 17 |
import torch
|
| 18 |
import numpy as np
|
| 19 |
from fastapi import FastAPI, WebSocket, WebSocketDisconnect, HTTPException
|
|
|
|
| 21 |
import uvicorn
|
| 22 |
|
| 23 |
# Version tracking
|
| 24 |
+
VERSION = "1.3.9"
|
| 25 |
COMMIT_SHA = "TBD"
|
| 26 |
|
| 27 |
# Configure logging
|
| 28 |
logging.basicConfig(level=logging.INFO)
|
| 29 |
logger = logging.getLogger(__name__)
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
# Create cache directory if it doesn't exist
|
| 32 |
os.makedirs('/app/hf_cache', exist_ok=True)
|
| 33 |
|
|
|
|
| 391 |
return result
|
| 392 |
|
| 393 |
if __name__ == "__main__":
|
| 394 |
+
# Run the server - disable reload to prevent restart loop
|
| 395 |
uvicorn.run(
|
| 396 |
"app:app",
|
| 397 |
host="0.0.0.0",
|
| 398 |
port=7860,
|
| 399 |
log_level="info",
|
| 400 |
+
access_log=True,
|
| 401 |
+
reload=False
|
| 402 |
)
|