fix karaoke: lazy-load unsandbox SDK to avoid import failure in CI
This commit is contained in:
parent
1135eb24e4
commit
f8ce118305
1 changed files with 12 additions and 4 deletions
|
|
@ -17,9 +17,16 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Use the unsandbox Python SDK for API requests
|
||||
sys.path.insert(0, os.path.expanduser("~/git/un-inception"))
|
||||
from un import _make_request, _resolve_credentials # noqa: E402
|
||||
_un_loaded = False
|
||||
|
||||
|
||||
def _load_un():
|
||||
global _un_loaded
|
||||
if not _un_loaded:
|
||||
sys.path.insert(0, os.path.expanduser("~/git/un-inception"))
|
||||
_un_loaded = True
|
||||
from un import _make_request, _resolve_credentials, validate_keys
|
||||
return _make_request, _resolve_credentials, validate_keys
|
||||
|
||||
VOXSPLIT_SOURCE = os.environ.get(
|
||||
"VOXSPLIT_SOURCE_PATH",
|
||||
|
|
@ -37,6 +44,7 @@ def process_karaoke(s3_client, bucket, s3_key, s3_path,
|
|||
|
||||
Returns dict {"instrumentals": size, "vocals": size} on success, None on failure.
|
||||
"""
|
||||
_make_request, _resolve_credentials, _ = _load_un() # lazy import
|
||||
public_key, secret_key = _resolve_credentials(public_key, secret_key)
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="karaoke_") as tmpdir:
|
||||
|
|
@ -168,7 +176,7 @@ def backfill_karaoke_async(shop_id, session_factory, app_settings):
|
|||
from sqlalchemy.orm import Session as SASession
|
||||
from ..models.product import Product, get_media_type
|
||||
from ..models.shop import Shop
|
||||
from un import validate_keys
|
||||
_, _, validate_keys = _load_un()
|
||||
|
||||
session = SASession(bind=session_factory().get_bind())
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue