deployment 13
Browse files- Dockerfile +6 -3
- backend/main.py +10 -4
- backend/tasks.py +8 -2
Dockerfile
CHANGED
|
@@ -25,9 +25,12 @@ COPY . .
|
|
| 25 |
RUN git lfs pull 2>/dev/null || echo "Git LFS files skipped (may be pre-downloaded)"
|
| 26 |
|
| 27 |
# Install Python dependencies
|
| 28 |
-
|
| 29 |
-
RUN pip install --no-cache-dir
|
|
|
|
| 30 |
RUN pip install --no-cache-dir -r backend/requirements.txt
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# Create storage directory
|
| 33 |
RUN mkdir -p /app/storage && chmod 777 /app/storage
|
|
@@ -42,7 +45,7 @@ WORKDIR /app/backend
|
|
| 42 |
ENV API_PORT=7860
|
| 43 |
ENV API_HOST=0.0.0.0
|
| 44 |
ENV PYTHONPATH=/app/backend
|
| 45 |
-
ENV
|
| 46 |
|
| 47 |
# Health check
|
| 48 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
|
|
| 25 |
RUN git lfs pull 2>/dev/null || echo "Git LFS files skipped (may be pre-downloaded)"
|
| 26 |
|
| 27 |
# Install Python dependencies
|
| 28 |
+
# Force numpy<2 first to prevent numpy 2.x from being installed
|
| 29 |
+
RUN pip install --no-cache-dir 'numpy<2.0.0' 'scipy<1.14.0' Cython
|
| 30 |
+
RUN pip install --no-cache-dir 'fakeredis[lua]' mir_eval
|
| 31 |
RUN pip install --no-cache-dir -r backend/requirements.txt
|
| 32 |
+
# Re-install numpy<2 to override any upgrades from requirements.txt
|
| 33 |
+
RUN pip install --no-cache-dir --force-reinstall 'numpy<2.0.0'
|
| 34 |
|
| 35 |
# Create storage directory
|
| 36 |
RUN mkdir -p /app/storage && chmod 777 /app/storage
|
|
|
|
| 45 |
ENV API_PORT=7860
|
| 46 |
ENV API_HOST=0.0.0.0
|
| 47 |
ENV PYTHONPATH=/app/backend
|
| 48 |
+
ENV USE_FAKE_REDIS=true
|
| 49 |
|
| 50 |
# Health check
|
| 51 |
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
backend/main.py
CHANGED
|
@@ -13,6 +13,7 @@ import json
|
|
| 13 |
import asyncio
|
| 14 |
import tempfile
|
| 15 |
import shutil
|
|
|
|
| 16 |
from typing import Optional
|
| 17 |
from app_config import settings
|
| 18 |
from app_utils import validate_youtube_url, check_video_availability
|
|
@@ -34,10 +35,15 @@ app = FastAPI(
|
|
| 34 |
)
|
| 35 |
|
| 36 |
# Redis client (initialized before middleware)
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
# YourMT3+ transcriber (loaded on startup)
|
| 43 |
yourmt3_transcriber: Optional[YourMT3Transcriber] = None
|
|
|
|
| 13 |
import asyncio
|
| 14 |
import tempfile
|
| 15 |
import shutil
|
| 16 |
+
import os
|
| 17 |
from typing import Optional
|
| 18 |
from app_config import settings
|
| 19 |
from app_utils import validate_youtube_url, check_video_availability
|
|
|
|
| 35 |
)
|
| 36 |
|
| 37 |
# Redis client (initialized before middleware)
|
| 38 |
+
# Use fakeredis if USE_FAKE_REDIS environment variable is set
|
| 39 |
+
if os.getenv('USE_FAKE_REDIS', '').lower() == 'true':
|
| 40 |
+
import fakeredis
|
| 41 |
+
redis_client = fakeredis.FakeStrictRedis(decode_responses=True)
|
| 42 |
+
async_redis_client = fakeredis.FakeAsyncRedis(decode_responses=True)
|
| 43 |
+
print("Using fakeredis for in-memory caching")
|
| 44 |
+
else:
|
| 45 |
+
redis_client = redis.Redis.from_url(settings.redis_url, decode_responses=True)
|
| 46 |
+
async_redis_client = redis.asyncio.Redis.from_url(settings.redis_url, decode_responses=True)
|
| 47 |
|
| 48 |
# YourMT3+ transcriber (loaded on startup)
|
| 49 |
yourmt3_transcriber: Optional[YourMT3Transcriber] = None
|
backend/tasks.py
CHANGED
|
@@ -4,13 +4,19 @@ from celery_app import celery_app
|
|
| 4 |
from pipeline import TranscriptionPipeline, run_transcription_pipeline
|
| 5 |
import redis
|
| 6 |
import json
|
|
|
|
| 7 |
from datetime import datetime
|
| 8 |
from pathlib import Path
|
| 9 |
from app_config import settings
|
| 10 |
import shutil
|
| 11 |
|
| 12 |
-
# Redis client
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
class TranscriptionTask(Task):
|
|
|
|
| 4 |
from pipeline import TranscriptionPipeline, run_transcription_pipeline
|
| 5 |
import redis
|
| 6 |
import json
|
| 7 |
+
import os
|
| 8 |
from datetime import datetime
|
| 9 |
from pathlib import Path
|
| 10 |
from app_config import settings
|
| 11 |
import shutil
|
| 12 |
|
| 13 |
+
# Redis client - use fakeredis if USE_FAKE_REDIS is set
|
| 14 |
+
if os.getenv('USE_FAKE_REDIS', '').lower() == 'true':
|
| 15 |
+
import fakeredis
|
| 16 |
+
redis_client = fakeredis.FakeStrictRedis(decode_responses=True)
|
| 17 |
+
print("Using fakeredis for in-memory caching")
|
| 18 |
+
else:
|
| 19 |
+
redis_client = redis.Redis.from_url(settings.redis_url, decode_responses=True)
|
| 20 |
|
| 21 |
|
| 22 |
class TranscriptionTask(Task):
|