karaoke-gen 0.86.7__py3-none-any.whl → 0.96.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- backend/.coveragerc +20 -0
- backend/.gitignore +37 -0
- backend/Dockerfile +43 -0
- backend/Dockerfile.base +74 -0
- backend/README.md +242 -0
- backend/__init__.py +0 -0
- backend/api/__init__.py +0 -0
- backend/api/dependencies.py +457 -0
- backend/api/routes/__init__.py +0 -0
- backend/api/routes/admin.py +742 -0
- backend/api/routes/audio_search.py +903 -0
- backend/api/routes/auth.py +348 -0
- backend/api/routes/file_upload.py +2076 -0
- backend/api/routes/health.py +344 -0
- backend/api/routes/internal.py +435 -0
- backend/api/routes/jobs.py +1610 -0
- backend/api/routes/review.py +652 -0
- backend/api/routes/themes.py +162 -0
- backend/api/routes/users.py +1014 -0
- backend/config.py +172 -0
- backend/main.py +133 -0
- backend/middleware/__init__.py +5 -0
- backend/middleware/audit_logging.py +124 -0
- backend/models/__init__.py +0 -0
- backend/models/job.py +519 -0
- backend/models/requests.py +123 -0
- backend/models/theme.py +153 -0
- backend/models/user.py +254 -0
- backend/models/worker_log.py +164 -0
- backend/pyproject.toml +29 -0
- backend/quick-check.sh +93 -0
- backend/requirements.txt +29 -0
- backend/run_tests.sh +60 -0
- backend/services/__init__.py +0 -0
- backend/services/audio_analysis_service.py +243 -0
- backend/services/audio_editing_service.py +278 -0
- backend/services/audio_search_service.py +702 -0
- backend/services/auth_service.py +630 -0
- backend/services/credential_manager.py +792 -0
- backend/services/discord_service.py +172 -0
- backend/services/dropbox_service.py +301 -0
- backend/services/email_service.py +1093 -0
- backend/services/encoding_interface.py +454 -0
- backend/services/encoding_service.py +405 -0
- backend/services/firestore_service.py +512 -0
- backend/services/flacfetch_client.py +573 -0
- backend/services/gce_encoding/README.md +72 -0
- backend/services/gce_encoding/__init__.py +22 -0
- backend/services/gce_encoding/main.py +589 -0
- backend/services/gce_encoding/requirements.txt +16 -0
- backend/services/gdrive_service.py +356 -0
- backend/services/job_logging.py +258 -0
- backend/services/job_manager.py +842 -0
- backend/services/job_notification_service.py +271 -0
- backend/services/local_encoding_service.py +590 -0
- backend/services/local_preview_encoding_service.py +407 -0
- backend/services/lyrics_cache_service.py +216 -0
- backend/services/metrics.py +413 -0
- backend/services/packaging_service.py +287 -0
- backend/services/rclone_service.py +106 -0
- backend/services/storage_service.py +209 -0
- backend/services/stripe_service.py +275 -0
- backend/services/structured_logging.py +254 -0
- backend/services/template_service.py +330 -0
- backend/services/theme_service.py +469 -0
- backend/services/tracing.py +543 -0
- backend/services/user_service.py +721 -0
- backend/services/worker_service.py +558 -0
- backend/services/youtube_service.py +112 -0
- backend/services/youtube_upload_service.py +445 -0
- backend/tests/__init__.py +4 -0
- backend/tests/conftest.py +224 -0
- backend/tests/emulator/__init__.py +7 -0
- backend/tests/emulator/conftest.py +88 -0
- backend/tests/emulator/test_e2e_cli_backend.py +1053 -0
- backend/tests/emulator/test_emulator_integration.py +356 -0
- backend/tests/emulator/test_style_loading_direct.py +436 -0
- backend/tests/emulator/test_worker_logs_direct.py +229 -0
- backend/tests/emulator/test_worker_logs_subcollection.py +443 -0
- backend/tests/requirements-test.txt +10 -0
- backend/tests/requirements.txt +6 -0
- backend/tests/test_admin_email_endpoints.py +411 -0
- backend/tests/test_api_integration.py +460 -0
- backend/tests/test_api_routes.py +93 -0
- backend/tests/test_audio_analysis_service.py +294 -0
- backend/tests/test_audio_editing_service.py +386 -0
- backend/tests/test_audio_search.py +1398 -0
- backend/tests/test_audio_services.py +378 -0
- backend/tests/test_auth_firestore.py +231 -0
- backend/tests/test_config_extended.py +68 -0
- backend/tests/test_credential_manager.py +377 -0
- backend/tests/test_dependencies.py +54 -0
- backend/tests/test_discord_service.py +244 -0
- backend/tests/test_distribution_services.py +820 -0
- backend/tests/test_dropbox_service.py +472 -0
- backend/tests/test_email_service.py +492 -0
- backend/tests/test_emulator_integration.py +322 -0
- backend/tests/test_encoding_interface.py +412 -0
- backend/tests/test_file_upload.py +1739 -0
- backend/tests/test_flacfetch_client.py +632 -0
- backend/tests/test_gdrive_service.py +524 -0
- backend/tests/test_instrumental_api.py +431 -0
- backend/tests/test_internal_api.py +343 -0
- backend/tests/test_job_creation_regression.py +583 -0
- backend/tests/test_job_manager.py +339 -0
- backend/tests/test_job_manager_notifications.py +329 -0
- backend/tests/test_job_notification_service.py +443 -0
- backend/tests/test_jobs_api.py +273 -0
- backend/tests/test_local_encoding_service.py +423 -0
- backend/tests/test_local_preview_encoding_service.py +567 -0
- backend/tests/test_main.py +87 -0
- backend/tests/test_models.py +918 -0
- backend/tests/test_packaging_service.py +382 -0
- backend/tests/test_requests.py +201 -0
- backend/tests/test_routes_jobs.py +282 -0
- backend/tests/test_routes_review.py +337 -0
- backend/tests/test_services.py +556 -0
- backend/tests/test_services_extended.py +112 -0
- backend/tests/test_storage_service.py +448 -0
- backend/tests/test_style_upload.py +261 -0
- backend/tests/test_template_service.py +295 -0
- backend/tests/test_theme_service.py +516 -0
- backend/tests/test_unicode_sanitization.py +522 -0
- backend/tests/test_upload_api.py +256 -0
- backend/tests/test_validate.py +156 -0
- backend/tests/test_video_worker_orchestrator.py +847 -0
- backend/tests/test_worker_log_subcollection.py +509 -0
- backend/tests/test_worker_logging.py +365 -0
- backend/tests/test_workers.py +1116 -0
- backend/tests/test_workers_extended.py +178 -0
- backend/tests/test_youtube_service.py +247 -0
- backend/tests/test_youtube_upload_service.py +568 -0
- backend/validate.py +173 -0
- backend/version.py +27 -0
- backend/workers/README.md +597 -0
- backend/workers/__init__.py +11 -0
- backend/workers/audio_worker.py +618 -0
- backend/workers/lyrics_worker.py +683 -0
- backend/workers/render_video_worker.py +483 -0
- backend/workers/screens_worker.py +525 -0
- backend/workers/style_helper.py +198 -0
- backend/workers/video_worker.py +1277 -0
- backend/workers/video_worker_orchestrator.py +701 -0
- backend/workers/worker_logging.py +278 -0
- karaoke_gen/instrumental_review/static/index.html +7 -4
- karaoke_gen/karaoke_finalise/karaoke_finalise.py +6 -1
- karaoke_gen/style_loader.py +3 -1
- karaoke_gen/utils/__init__.py +163 -8
- karaoke_gen/video_background_processor.py +9 -4
- {karaoke_gen-0.86.7.dist-info → karaoke_gen-0.96.0.dist-info}/METADATA +2 -1
- {karaoke_gen-0.86.7.dist-info → karaoke_gen-0.96.0.dist-info}/RECORD +187 -42
- lyrics_transcriber/correction/agentic/providers/config.py +9 -5
- lyrics_transcriber/correction/agentic/providers/langchain_bridge.py +1 -51
- lyrics_transcriber/correction/corrector.py +192 -130
- lyrics_transcriber/correction/operations.py +24 -9
- lyrics_transcriber/frontend/package-lock.json +2 -2
- lyrics_transcriber/frontend/package.json +1 -1
- lyrics_transcriber/frontend/src/components/AIFeedbackModal.tsx +1 -1
- lyrics_transcriber/frontend/src/components/CorrectedWordWithActions.tsx +11 -7
- lyrics_transcriber/frontend/src/components/EditActionBar.tsx +31 -5
- lyrics_transcriber/frontend/src/components/EditModal.tsx +28 -10
- lyrics_transcriber/frontend/src/components/EditTimelineSection.tsx +123 -27
- lyrics_transcriber/frontend/src/components/EditWordList.tsx +112 -60
- lyrics_transcriber/frontend/src/components/Header.tsx +90 -76
- lyrics_transcriber/frontend/src/components/LyricsAnalyzer.tsx +53 -31
- lyrics_transcriber/frontend/src/components/LyricsSynchronizer/SyncControls.tsx +44 -13
- lyrics_transcriber/frontend/src/components/LyricsSynchronizer/TimelineCanvas.tsx +66 -50
- lyrics_transcriber/frontend/src/components/LyricsSynchronizer/index.tsx +124 -30
- lyrics_transcriber/frontend/src/components/ReferenceView.tsx +1 -1
- lyrics_transcriber/frontend/src/components/TimelineEditor.tsx +12 -5
- lyrics_transcriber/frontend/src/components/TimingOffsetModal.tsx +3 -3
- lyrics_transcriber/frontend/src/components/TranscriptionView.tsx +1 -1
- lyrics_transcriber/frontend/src/components/WordDivider.tsx +11 -7
- lyrics_transcriber/frontend/src/components/shared/components/Word.tsx +4 -2
- lyrics_transcriber/frontend/src/hooks/useManualSync.ts +103 -1
- lyrics_transcriber/frontend/src/theme.ts +42 -15
- lyrics_transcriber/frontend/tsconfig.tsbuildinfo +1 -1
- lyrics_transcriber/frontend/vite.config.js +5 -0
- lyrics_transcriber/frontend/web_assets/assets/{index-BECn1o8Q.js → index-BSMgOq4Z.js} +6959 -5782
- lyrics_transcriber/frontend/web_assets/assets/index-BSMgOq4Z.js.map +1 -0
- lyrics_transcriber/frontend/web_assets/index.html +6 -2
- lyrics_transcriber/frontend/web_assets/nomad-karaoke-logo.svg +5 -0
- lyrics_transcriber/output/generator.py +17 -3
- lyrics_transcriber/output/video.py +60 -95
- lyrics_transcriber/frontend/web_assets/assets/index-BECn1o8Q.js.map +0 -1
- {karaoke_gen-0.86.7.dist-info → karaoke_gen-0.96.0.dist-info}/WHEEL +0 -0
- {karaoke_gen-0.86.7.dist-info → karaoke_gen-0.96.0.dist-info}/entry_points.txt +0 -0
- {karaoke_gen-0.86.7.dist-info → karaoke_gen-0.96.0.dist-info}/licenses/LICENSE +0 -0
backend/.coveragerc
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[run]
|
|
2
|
+
source = backend
|
|
3
|
+
omit =
|
|
4
|
+
backend/tests/*
|
|
5
|
+
backend/validate.py
|
|
6
|
+
backend/tests/emulator/*
|
|
7
|
+
# Workers that require external APIs are tested via integration tests
|
|
8
|
+
backend/workers/screens_worker.py
|
|
9
|
+
backend/workers/video_worker.py
|
|
10
|
+
|
|
11
|
+
[report]
|
|
12
|
+
exclude_lines =
|
|
13
|
+
pragma: no cover
|
|
14
|
+
def __repr__
|
|
15
|
+
raise NotImplementedError
|
|
16
|
+
if __name__ == .__main__.:
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
show_missing = True
|
|
20
|
+
|
backend/.gitignore
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Ignore Python cache and virtual environments
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
env/
|
|
8
|
+
venv/
|
|
9
|
+
ENV/
|
|
10
|
+
env.bak/
|
|
11
|
+
venv.bak/
|
|
12
|
+
|
|
13
|
+
# Environment files
|
|
14
|
+
.env
|
|
15
|
+
.env.local
|
|
16
|
+
|
|
17
|
+
# IDE
|
|
18
|
+
.vscode/
|
|
19
|
+
.idea/
|
|
20
|
+
*.swp
|
|
21
|
+
*.swo
|
|
22
|
+
*~
|
|
23
|
+
|
|
24
|
+
# Temporary files
|
|
25
|
+
*.log
|
|
26
|
+
temp/
|
|
27
|
+
tmp/
|
|
28
|
+
|
|
29
|
+
# Google Cloud
|
|
30
|
+
.gcloud/
|
|
31
|
+
*.json
|
|
32
|
+
|
|
33
|
+
# Testing
|
|
34
|
+
.pytest_cache/
|
|
35
|
+
.coverage
|
|
36
|
+
htmlcov/
|
|
37
|
+
|
backend/Dockerfile
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Fast application image - uses pre-built base with all dependencies
|
|
2
|
+
#
|
|
3
|
+
# The base image (karaoke-backend-base) contains:
|
|
4
|
+
# - Python 3.11, ffmpeg, sox, system deps
|
|
5
|
+
# - All pip dependencies from requirements-frozen.txt (NO code)
|
|
6
|
+
#
|
|
7
|
+
# This Dockerfile adds the actual application code on top.
|
|
8
|
+
# Build time: ~1-2 minutes (deps already cached in base)
|
|
9
|
+
#
|
|
10
|
+
# If the base image doesn't exist yet, build it first:
|
|
11
|
+
# gcloud builds submit --config=cloudbuild-base.yaml --project=nomadkaraoke
|
|
12
|
+
|
|
13
|
+
# Use pre-built base image with all dependencies
|
|
14
|
+
# Override with --build-arg BASE_IMAGE=karaoke-backend-base:local for local testing
|
|
15
|
+
ARG BASE_IMAGE=us-central1-docker.pkg.dev/nomadkaraoke/karaoke-repo/karaoke-backend-base:latest
|
|
16
|
+
FROM ${BASE_IMAGE}
|
|
17
|
+
|
|
18
|
+
# Set working directory (should already exist from base)
|
|
19
|
+
WORKDIR /app
|
|
20
|
+
|
|
21
|
+
# Copy backend code (this is the only thing that changes frequently)
|
|
22
|
+
COPY backend /app/backend
|
|
23
|
+
|
|
24
|
+
# Copy and reinstall karaoke_gen from local source
|
|
25
|
+
# This ensures new modules (like style_loader.py) are included without rebuilding base image
|
|
26
|
+
# Note: lyrics_transcriber is vendored in lyrics_transcriber_temp/ and bundled via pyproject.toml
|
|
27
|
+
COPY karaoke_gen /app/karaoke_gen
|
|
28
|
+
COPY lyrics_transcriber_temp /app/lyrics_transcriber_temp
|
|
29
|
+
COPY pyproject.toml README.md LICENSE /app/
|
|
30
|
+
RUN pip install --no-cache-dir -e .
|
|
31
|
+
|
|
32
|
+
# Set environment variables
|
|
33
|
+
ENV PYTHONUNBUFFERED=1
|
|
34
|
+
ENV PORT=8080
|
|
35
|
+
|
|
36
|
+
# Expose port
|
|
37
|
+
EXPOSE 8080
|
|
38
|
+
|
|
39
|
+
# Run uvicorn directly
|
|
40
|
+
# Note: Transmission daemon removed - torrent downloads now handled by
|
|
41
|
+
# dedicated flacfetch VM service (see docs/00-current-plan/TORRENT-SERVICE-PLAN.md)
|
|
42
|
+
# Using --loop asyncio (instead of uvloop) to support nest_asyncio for remote flacfetch calls
|
|
43
|
+
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8080", "--loop", "asyncio"]
|
backend/Dockerfile.base
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Base image with all Python dependencies pre-installed
|
|
2
|
+
# This image is rebuilt only when poetry.lock changes
|
|
3
|
+
#
|
|
4
|
+
# Build with: gcloud builds submit --config=cloudbuild-base.yaml
|
|
5
|
+
# Or manually: docker build -f backend/Dockerfile.base -t karaoke-backend-base .
|
|
6
|
+
|
|
7
|
+
FROM python:3.11-slim
|
|
8
|
+
|
|
9
|
+
# Install system dependencies required by karaoke-gen
|
|
10
|
+
# Note: Transmission daemon removed - torrent downloads now handled by
|
|
11
|
+
# dedicated flacfetch VM service (see docs/00-current-plan/TORRENT-SERVICE-PLAN.md)
|
|
12
|
+
RUN apt-get update && apt-get install -y \
|
|
13
|
+
libsndfile1 \
|
|
14
|
+
libsox-dev \
|
|
15
|
+
sox \
|
|
16
|
+
build-essential \
|
|
17
|
+
curl \
|
|
18
|
+
xz-utils \
|
|
19
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
20
|
+
|
|
21
|
+
# Install comprehensive font support for international lyrics and symbols
|
|
22
|
+
# Noto fonts provide full Unicode coverage including:
|
|
23
|
+
# - Latin, Greek, Cyrillic (core)
|
|
24
|
+
# - CJK: Chinese, Japanese, Korean (~150MB)
|
|
25
|
+
# - Arabic, Hebrew, Thai, Hindi, and other scripts (extra)
|
|
26
|
+
# - Color emoji (limited support in libass, but available)
|
|
27
|
+
# - Musical symbols (♪ ♫ etc.)
|
|
28
|
+
# Note: This adds ~200-300MB to the image but ensures all languages render correctly
|
|
29
|
+
RUN apt-get update && apt-get install -y \
|
|
30
|
+
fonts-noto-core \
|
|
31
|
+
fonts-noto-cjk \
|
|
32
|
+
fonts-noto-extra \
|
|
33
|
+
fonts-noto-color-emoji \
|
|
34
|
+
fontconfig \
|
|
35
|
+
&& fc-cache -f \
|
|
36
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
37
|
+
|
|
38
|
+
# Install optimized static FFmpeg build (7.0.2) instead of Debian package (5.1.8)
|
|
39
|
+
# John Van Sickle's builds are compiled with better optimizations for x86_64
|
|
40
|
+
# This provides ~20-40% performance improvement for encoding tasks
|
|
41
|
+
# Source: https://johnvansickle.com/ffmpeg/
|
|
42
|
+
RUN curl -L https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o /tmp/ffmpeg.tar.xz && \
|
|
43
|
+
tar -xf /tmp/ffmpeg.tar.xz -C /tmp && \
|
|
44
|
+
cp /tmp/ffmpeg-*-amd64-static/ffmpeg /usr/local/bin/ && \
|
|
45
|
+
cp /tmp/ffmpeg-*-amd64-static/ffprobe /usr/local/bin/ && \
|
|
46
|
+
chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe && \
|
|
47
|
+
rm -rf /tmp/ffmpeg* && \
|
|
48
|
+
ffmpeg -version
|
|
49
|
+
|
|
50
|
+
# Set working directory
|
|
51
|
+
WORKDIR /app
|
|
52
|
+
|
|
53
|
+
# Copy dependency files and source code needed for pip install
|
|
54
|
+
COPY pyproject.toml README.md LICENSE /app/
|
|
55
|
+
COPY karaoke_gen /app/karaoke_gen
|
|
56
|
+
COPY lyrics_transcriber_temp /app/lyrics_transcriber_temp
|
|
57
|
+
|
|
58
|
+
# Install all Python dependencies (the slow part - cached in base image)
|
|
59
|
+
RUN pip install --no-cache-dir --upgrade pip && \
|
|
60
|
+
pip install --no-cache-dir -e .
|
|
61
|
+
|
|
62
|
+
# Download spaCy language model for lyrics transcription
|
|
63
|
+
# This must be done at build time, not runtime (Cloud Run network restrictions)
|
|
64
|
+
RUN python -m spacy download en_core_web_sm
|
|
65
|
+
|
|
66
|
+
# Label with build info
|
|
67
|
+
ARG BUILD_DATE
|
|
68
|
+
ARG BUILD_ID
|
|
69
|
+
ARG BASE_CONTENT_HASH
|
|
70
|
+
LABEL org.opencontainers.image.created="${BUILD_DATE}"
|
|
71
|
+
LABEL org.opencontainers.image.revision="${BUILD_ID}"
|
|
72
|
+
LABEL org.opencontainers.image.title="karaoke-backend-base"
|
|
73
|
+
LABEL org.opencontainers.image.description="Base image with Python dependencies and system tools for karaoke-backend"
|
|
74
|
+
LABEL base.content.hash="${BASE_CONTENT_HASH}"
|
backend/README.md
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# Backend Development Setup
|
|
2
|
+
|
|
3
|
+
## One-Time Setup
|
|
4
|
+
|
|
5
|
+
### 1. Create Virtual Environment
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd /Users/andrew/Projects/karaoke-gen
|
|
9
|
+
python3 -m venv backend/venv
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### 2. Activate Virtual Environment
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
source backend/venv/bin/activate
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### 3. Install Dependencies
|
|
19
|
+
|
|
20
|
+
**IMPORTANT:** Use Python 3.12 (not 3.13/3.14 - pydantic has compatibility issues)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Backend dependencies
|
|
24
|
+
pip install -r backend/requirements.txt
|
|
25
|
+
|
|
26
|
+
# Install karaoke_gen in development mode
|
|
27
|
+
pip install -e .
|
|
28
|
+
|
|
29
|
+
# Install lyrics_transcriber submodule
|
|
30
|
+
pip install -e lyrics_transcriber_local/
|
|
31
|
+
|
|
32
|
+
# Install Google API client (for YouTube upload)
|
|
33
|
+
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 4. Add Shell Alias (Optional)
|
|
37
|
+
|
|
38
|
+
Add to `~/.zshrc`:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
alias backend='cd /Users/andrew/Projects/karaoke-gen && source backend/venv/bin/activate'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Then you can just run:
|
|
45
|
+
```bash
|
|
46
|
+
backend
|
|
47
|
+
# Now you're in the project directory with venv activated!
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Daily Workflow
|
|
53
|
+
|
|
54
|
+
### Before Making Changes
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Activate venv
|
|
58
|
+
source backend/venv/bin/activate
|
|
59
|
+
|
|
60
|
+
# Or if you set up the alias:
|
|
61
|
+
backend
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### After Making Changes
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# 1. Run full validation (catches import errors!)
|
|
68
|
+
python3 backend/validate.py
|
|
69
|
+
|
|
70
|
+
# 2. If validation passes, deploy
|
|
71
|
+
./scripts/deploy.sh
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Validation Options
|
|
77
|
+
|
|
78
|
+
### Full Validation (Recommended - Requires venv)
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
source backend/venv/bin/activate
|
|
82
|
+
python3 backend/validate.py
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Catches:**
|
|
86
|
+
- ✅ Syntax errors
|
|
87
|
+
- ✅ **Import errors** (like the processing_service issue!)
|
|
88
|
+
- ✅ Configuration issues
|
|
89
|
+
- ✅ FastAPI app creation problems
|
|
90
|
+
- ✅ Missing dependencies
|
|
91
|
+
|
|
92
|
+
**This would have caught the ModuleNotFoundError!**
|
|
93
|
+
|
|
94
|
+
### Quick Check (No venv needed)
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
./backend/quick-check.sh
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Catches:**
|
|
101
|
+
- ✅ Syntax errors
|
|
102
|
+
- ✅ Missing files
|
|
103
|
+
- ✅ Some obvious import issues
|
|
104
|
+
|
|
105
|
+
**Good for quick checks, but won't catch all import errors**
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Example: Complete Development Session
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# 1. Activate environment
|
|
113
|
+
backend # or: source backend/venv/bin/activate
|
|
114
|
+
|
|
115
|
+
# 2. Make your changes
|
|
116
|
+
vim backend/api/routes/jobs.py
|
|
117
|
+
|
|
118
|
+
# 3. Validate (catches import errors!)
|
|
119
|
+
python3 backend/validate.py
|
|
120
|
+
# ✅ All validations passed!
|
|
121
|
+
|
|
122
|
+
# 4. Deploy
|
|
123
|
+
./scripts/deploy.sh
|
|
124
|
+
|
|
125
|
+
# 5. Test
|
|
126
|
+
export BACKEND_URL="https://karaoke-backend-ipzqd2k4yq-uc.a.run.app"
|
|
127
|
+
export AUTH_TOKEN=$(gcloud auth print-identity-token)
|
|
128
|
+
curl -H "Authorization: Bearer $AUTH_TOKEN" $BACKEND_URL/api/health
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## What About karaoke_gen Imports?
|
|
134
|
+
|
|
135
|
+
The backend imports from `karaoke_gen` (the CLI package):
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from karaoke_gen.karaoke_gen import KaraokePrep
|
|
139
|
+
from karaoke_gen.audio_processor import AudioProcessor
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Options:**
|
|
143
|
+
|
|
144
|
+
### Option 1: Install in development mode (Recommended)
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
source backend/venv/bin/activate
|
|
148
|
+
pip install -e .
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
This makes `karaoke_gen` available in the venv without copying files.
|
|
152
|
+
|
|
153
|
+
### Option 2: Use system Python
|
|
154
|
+
|
|
155
|
+
Your system Python already has `karaoke_gen` installed, so validation will work even if the venv doesn't have it (Python will fall back to system packages).
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Running the Backend Locally
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Activate venv
|
|
163
|
+
source backend/venv/bin/activate
|
|
164
|
+
|
|
165
|
+
# Set required environment variables
|
|
166
|
+
export GOOGLE_CLOUD_PROJECT="nomadkaraoke"
|
|
167
|
+
export GCS_BUCKET_NAME="karaoke-gen-storage-nomadkaraoke"
|
|
168
|
+
|
|
169
|
+
# Optional: Point to local credentials
|
|
170
|
+
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
|
|
171
|
+
|
|
172
|
+
# Run the server
|
|
173
|
+
cd backend
|
|
174
|
+
uvicorn main:app --reload --port 8080
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Visit: http://localhost:8080/api/health
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Troubleshooting
|
|
182
|
+
|
|
183
|
+
### "No module named 'fastapi'"
|
|
184
|
+
|
|
185
|
+
**Fix:**
|
|
186
|
+
```bash
|
|
187
|
+
source backend/venv/bin/activate
|
|
188
|
+
pip install -r backend/requirements.txt
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### "No module named 'karaoke_gen'"
|
|
192
|
+
|
|
193
|
+
**Fix:**
|
|
194
|
+
```bash
|
|
195
|
+
source backend/venv/bin/activate
|
|
196
|
+
cd /Users/andrew/Projects/karaoke-gen
|
|
197
|
+
pip install -e .
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Validation passes locally but fails in Cloud Run
|
|
201
|
+
|
|
202
|
+
**Check:**
|
|
203
|
+
1. Is `requirements.txt` up to date?
|
|
204
|
+
2. Did you add a new dependency without adding it to `requirements.txt`?
|
|
205
|
+
3. Run: `pip freeze | grep <package-name>`
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Updating Dependencies
|
|
210
|
+
|
|
211
|
+
When you add new packages:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# 1. Install in venv
|
|
215
|
+
source backend/venv/bin/activate
|
|
216
|
+
pip install new-package
|
|
217
|
+
|
|
218
|
+
# 2. Update requirements.txt
|
|
219
|
+
pip freeze > backend/requirements.txt
|
|
220
|
+
|
|
221
|
+
# 3. Or manually add just the new package:
|
|
222
|
+
echo "new-package==1.2.3" >> backend/requirements.txt
|
|
223
|
+
|
|
224
|
+
# 4. Validate
|
|
225
|
+
python3 backend/validate.py
|
|
226
|
+
|
|
227
|
+
# 5. Deploy
|
|
228
|
+
./scripts/deploy.sh
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Summary
|
|
234
|
+
|
|
235
|
+
**Best practice workflow:**
|
|
236
|
+
|
|
237
|
+
1. **One-time setup:** Create venv and install dependencies
|
|
238
|
+
2. **Daily:** Activate venv when working on backend
|
|
239
|
+
3. **Before deploy:** Run `python3 backend/validate.py` (catches import errors!)
|
|
240
|
+
4. **Deploy:** Use `./scripts/deploy.sh`
|
|
241
|
+
|
|
242
|
+
**The import error would have been caught if you ran validation in a venv!** ✅
|
backend/__init__.py
ADDED
|
File without changes
|
backend/api/__init__.py
ADDED
|
File without changes
|