Skip to content

Commit 542c780

Browse files
beveradbclaude
andcommitted
fix(ci): move Separator import inside functions for Modal deploy
The audio_separator.separator import has heavy dependencies (torch, etc.) that aren't available on the GitHub Actions runner. Moving the import inside the Modal functions ensures it only runs in the container where all dependencies are installed. Also added fastapi and filetype to workflow dependencies. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8ae7c74 commit 542c780

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

.github/workflows/deploy-to-modal.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ jobs:
3333
with:
3434
python-version: '3.12'
3535

36-
- name: Install Modal CLI
37-
run: pip install modal
36+
- name: Install Modal CLI and dependencies
37+
run: |
38+
pip install modal
39+
# Install dependencies needed to parse deploy_modal.py
40+
pip install fastapi filetype
3841
3942
- name: Deploy to Modal
4043
env:

audio_separator/remote/deploy_modal.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
import filetype
4141
import modal
4242

43-
# Local imports
44-
from audio_separator.separator import Separator
43+
# Note: Separator is imported inside functions to allow Modal to parse this file
44+
# without requiring audio_separator to be installed on the deployment machine
4545

4646
# Constants
4747
DEFAULT_MODEL_NAME = "default" # Used when no model is specified
@@ -195,6 +195,8 @@ def separate_audio_function(
195195
"""
196196
Separate audio into stems using one or more models
197197
"""
198+
from audio_separator.separator import Separator
199+
198200
if task_id is None:
199201
task_id = str(uuid.uuid4())
200202

@@ -489,6 +491,8 @@ def list_available_models() -> dict:
489491
"""
490492
List available separation models using the same approach as CLI
491493
"""
494+
from audio_separator.separator import Separator
495+
492496
# Use the persistent model directory
493497
model_dir = "/models"
494498

@@ -510,6 +514,8 @@ def get_simplified_models(filter_sort_by: str = None) -> dict:
510514
"""
511515
Get simplified model list using the same approach as CLI --list_models
512516
"""
517+
from audio_separator.separator import Separator
518+
513519
# Use the persistent model directory
514520
model_dir = "/models"
515521

0 commit comments

Comments
 (0)