Skip to content

Make audio separator async with Firestore + GCS#280

Merged
beveradb merged 9 commits intomainfrom
feat/sess-20260325-2130-async-separator
Mar 26, 2026
Merged

Make audio separator async with Firestore + GCS#280
beveradb merged 9 commits intomainfrom
feat/sess-20260325-2130-async-separator

Conversation

@beveradb
Copy link
Copy Markdown
Collaborator

Summary

  • Make /separate endpoint return immediately (fire-and-forget), enabling client polling via existing /status and /download endpoints
  • Replace in-memory job_status_store dict with Firestore (audio_separation_jobs collection) for multi-instance scaling
  • Upload output files to GCS (nomadkaraoke-audio-separator-outputs bucket) so any instance can serve downloads
  • Add threading.Semaphore(1) to serialize GPU access per instance, preventing OOM
  • Reduce client POST timeout from 300s to 60s (server returns immediately now)
  • Add google-cloud-firestore to Dockerfile

Fixes the 300s HTTP timeout when ensemble presets take >5 minutes on large WAV files. Backward-compatible — old clients work with new server and vice versa.

Test plan

  • 256 unit tests passing (7 new for job store, 5 new for output store, 6 new for async behavior)
  • Deploy to Cloud Run GPU and submit a separation with ensemble preset on a large WAV
  • Verify POST returns immediately (< 5s) with status: submitted
  • Verify polling shows queuedprocessingcompleted transitions
  • Verify output files download successfully from any instance
  • Submit two concurrent jobs — verify second queues behind GPU semaphore

@coderabbitai ignore

🤖 Generated with Claude Code

beveradb and others added 6 commits March 25, 2026 22:06
Introduces FirestoreJobStore to replace the in-memory job_status_store dict,
enabling any Cloud Run instance to read/write job status for multi-instance GPU scaling.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements GCSOutputStore to upload separation results to GCS so any
Cloud Run instance can serve download requests, replacing local disk storage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Convert the /separate endpoint from synchronous (await) to fire-and-forget
pattern so it returns immediately while separation runs in background.
Replace in-memory job_status_store with Firestore reads/writes and local
file downloads with GCS, enabling cross-instance status polling and file
serving. Add GPU semaphore to serialize concurrent separation requests on
a single instance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
beveradb and others added 3 commits March 26, 2026 00:14
Move google.cloud imports inside __init__ methods so modules can be
imported without the packages installed. Add google-cloud-firestore and
google-cloud-storage to dev dependencies so CI has them available.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The TestLazyInit tests import deploy_cloudrun.py which requires uvicorn
and fastapi - server-only dependencies not in the test environment.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
beveradb added a commit to nomadkaraoke/karaoke-gen that referenced this pull request Mar 26, 2026
## Summary

- Update audio separator Cloud Run service:
`max_instance_request_concurrency` 1→50, `max_instances` 5→10
- Add `OUTPUT_BUCKET` and `GCP_PROJECT` env vars for the separator
service
- Create `nomadkaraoke-audio-separator-outputs` GCS bucket with 1-day
lifecycle policy
- Grant separator service account `roles/datastore.user` for Firestore
and `roles/storage.objectAdmin` for the output bucket
- Add Firestore composite index on `audio_separation_jobs` (status +
updated_at) for cleanup queries

Companion to nomadkaraoke/python-audio-separator#280. Deploy order: this
PR's infra first (`pulumi up`), then the separator service.

## Test plan

- [ ] `pulumi preview` shows expected resource changes
- [ ] `pulumi up` applies cleanly
- [ ] Verify GCS bucket created with lifecycle policy
- [ ] Verify Firestore index created
- [ ] Verify separator service updated with new concurrency/scaling
settings

@coderabbitai ignore

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@beveradb beveradb merged commit 349ba98 into main Mar 26, 2026
17 of 19 checks passed
@beveradb beveradb deleted the feat/sess-20260325-2130-async-separator branch March 26, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant