Spaces:
Sleeping
Sleeping
Fix firebase cred issue
Browse files
app.py
CHANGED
|
@@ -59,14 +59,18 @@ SEQUENCE_LENGTH_MIN = 24 # Minimum historical data required
|
|
| 59 |
ROLLING_WINDOW = 24 * 14 # 336h rolling-median window (CONFIRMED from training notebook)
|
| 60 |
|
| 61 |
# Initialize Firebase using environment variables
|
|
|
|
|
|
|
| 62 |
firebase_credential_json = os.environ.get("FIREBASE_CREDENTIAL_JSON")
|
| 63 |
firebase_initialized = False
|
| 64 |
|
| 65 |
if firebase_credential_json:
|
| 66 |
try:
|
| 67 |
-
|
|
|
|
|
|
|
| 68 |
f.write(firebase_credential_json)
|
| 69 |
-
|
| 70 |
|
| 71 |
FIREBASE_DATABASE_URL = os.getenv("FIREBASE_DATABASE_URL")
|
| 72 |
if not os.path.exists(firebase_credential_path):
|
|
|
|
| 59 |
ROLLING_WINDOW = 24 * 14 # 336h rolling-median window (CONFIRMED from training notebook)
|
| 60 |
|
| 61 |
# Initialize Firebase using environment variables
|
| 62 |
+
import tempfile
|
| 63 |
+
|
| 64 |
firebase_credential_json = os.environ.get("FIREBASE_CREDENTIAL_JSON")
|
| 65 |
firebase_initialized = False
|
| 66 |
|
| 67 |
if firebase_credential_json:
|
| 68 |
try:
|
| 69 |
+
temp_dir = tempfile.gettempdir()
|
| 70 |
+
firebase_credential_path = os.path.join(temp_dir, "firebase-credentials.json")
|
| 71 |
+
with open(firebase_credential_path, "w", encoding="utf-8") as f:
|
| 72 |
f.write(firebase_credential_json)
|
| 73 |
+
print(f"Wrote Firebase credentials to writable temp path: {firebase_credential_path}")
|
| 74 |
|
| 75 |
FIREBASE_DATABASE_URL = os.getenv("FIREBASE_DATABASE_URL")
|
| 76 |
if not os.path.exists(firebase_credential_path):
|