Update core/globals.py
Browse files- core/globals.py +22 -0
core/globals.py
CHANGED
|
@@ -9,4 +9,26 @@ except ImportError:
|
|
| 9 |
print("⚠️ Supabase library not installed. Background jobs will fail.")
|
| 10 |
supabase = None
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
client = None
|
|
|
|
| 9 |
print("⚠️ Supabase library not installed. Background jobs will fail.")
|
| 10 |
supabase = None
|
| 11 |
|
| 12 |
+
# Second, INDEPENDENT Supabase client for the video-editor project (routers/
|
| 13 |
+
# editor.py's /editor/create-project + process_project_background) — a
|
| 14 |
+
# separate Supabase project from the one above (which serves media_jobs for
|
| 15 |
+
# the older plottie-editor), so this never touches that app's data. Uses the
|
| 16 |
+
# service_role/secret key (bypasses RLS) since background jobs run with no
|
| 17 |
+
# user session. Degrades to None (instead of crashing the whole app at
|
| 18 |
+
# import time, unlike the block above) when unset — /editor/create-project
|
| 19 |
+
# just 500s with a clear message until SUPABASE_URL_EDITOR/
|
| 20 |
+
# SUPABASE_SERVICE_KEY_EDITOR are set as HF Space secrets.
|
| 21 |
+
try:
|
| 22 |
+
from supabase import create_client as _create_client_editor
|
| 23 |
+
SUPABASE_URL_EDITOR = os.getenv("SUPABASE_URL_EDITOR")
|
| 24 |
+
SUPABASE_SERVICE_KEY_EDITOR = os.getenv("SUPABASE_SERVICE_KEY_EDITOR")
|
| 25 |
+
supabase_editor = (
|
| 26 |
+
_create_client_editor(SUPABASE_URL_EDITOR, SUPABASE_SERVICE_KEY_EDITOR)
|
| 27 |
+
if SUPABASE_URL_EDITOR and SUPABASE_SERVICE_KEY_EDITOR else None
|
| 28 |
+
)
|
| 29 |
+
if supabase_editor is None:
|
| 30 |
+
print("⚠️ SUPABASE_URL_EDITOR/SUPABASE_SERVICE_KEY_EDITOR not set — the video editor's /editor/create-project will fail.")
|
| 31 |
+
except ImportError:
|
| 32 |
+
supabase_editor = None
|
| 33 |
+
|
| 34 |
client = None
|