Commit Β·
7856594
1
Parent(s): d8180cd
fix: make Streamlit startup resilient - handle import failures gracefully
Browse files- Dockerfile +21 -1
- app.py +6 -1
- backend/firebase_auth.py +1 -1
Dockerfile
CHANGED
|
@@ -43,6 +43,7 @@ ENV USE_SUPABASE=true
|
|
| 43 |
RUN echo '#!/bin/bash\n\
|
| 44 |
set -e\n\
|
| 45 |
\n\
|
|
|
|
| 46 |
echo "=== FocusFlow Startup ===" \n\
|
| 47 |
\n\
|
| 48 |
# Wait for DNS/networking to be ready (HF Spaces can be slow)\n\
|
|
@@ -72,9 +73,28 @@ RUN echo '#!/bin/bash\n\
|
|
| 72 |
sleep 1\n\
|
| 73 |
done\n\
|
| 74 |
\n\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
# Start Streamlit frontend\n\
|
| 76 |
echo "Starting frontend on port 8501..." \n\
|
| 77 |
-
exec streamlit run app.py --server.port 8501 --server.address 0.0.0.0 --server.headless true\n\
|
| 78 |
' > /app/start.sh && chmod +x /app/start.sh
|
| 79 |
|
| 80 |
# Run startup script
|
|
|
|
| 43 |
RUN echo '#!/bin/bash\n\
|
| 44 |
set -e\n\
|
| 45 |
\n\
|
| 46 |
+
echo "===== Application Startup at $(date) =====" \n\
|
| 47 |
echo "=== FocusFlow Startup ===" \n\
|
| 48 |
\n\
|
| 49 |
# Wait for DNS/networking to be ready (HF Spaces can be slow)\n\
|
|
|
|
| 73 |
sleep 1\n\
|
| 74 |
done\n\
|
| 75 |
\n\
|
| 76 |
+
# Test critical imports before launching Streamlit\n\
|
| 77 |
+
echo "Testing Python imports..." \n\
|
| 78 |
+
python3 -c "\n\
|
| 79 |
+
import sys\n\
|
| 80 |
+
try:\n\
|
| 81 |
+
import streamlit; print(\" β
streamlit\")\n\
|
| 82 |
+
except Exception as e: print(f\" β streamlit: {e}\"); sys.exit(1)\n\
|
| 83 |
+
try:\n\
|
| 84 |
+
import requests; print(\" β
requests\")\n\
|
| 85 |
+
except Exception as e: print(f\" β requests: {e}\")\n\
|
| 86 |
+
try:\n\
|
| 87 |
+
from streamlit_calendar import calendar; print(\" β
streamlit_calendar\")\n\
|
| 88 |
+
except Exception as e: print(f\" β streamlit_calendar: {e}\")\n\
|
| 89 |
+
try:\n\
|
| 90 |
+
import firebase_admin; print(\" β
firebase_admin\")\n\
|
| 91 |
+
except Exception as e: print(f\" β firebase_admin: {e}\")\n\
|
| 92 |
+
print(\"Import check complete.\")\n\
|
| 93 |
+
"\n\
|
| 94 |
+
\n\
|
| 95 |
# Start Streamlit frontend\n\
|
| 96 |
echo "Starting frontend on port 8501..." \n\
|
| 97 |
+
exec streamlit run app.py --server.port 8501 --server.address 0.0.0.0 --server.headless true 2>&1\n\
|
| 98 |
' > /app/start.sh && chmod +x /app/start.sh
|
| 99 |
|
| 100 |
# Run startup script
|
app.py
CHANGED
|
@@ -4,7 +4,12 @@ import pandas as pd
|
|
| 4 |
import plotly.express as px
|
| 5 |
import time
|
| 6 |
import streamlit.components.v1 as components
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
from datetime import date
|
| 9 |
import os
|
| 10 |
|
|
|
|
| 4 |
import plotly.express as px
|
| 5 |
import time
|
| 6 |
import streamlit.components.v1 as components
|
| 7 |
+
try:
|
| 8 |
+
from streamlit_calendar import calendar as st_calendar
|
| 9 |
+
_HAS_CALENDAR = True
|
| 10 |
+
except ImportError:
|
| 11 |
+
_HAS_CALENDAR = False
|
| 12 |
+
st_calendar = None
|
| 13 |
from datetime import date
|
| 14 |
import os
|
| 15 |
|
backend/firebase_auth.py
CHANGED
|
@@ -35,7 +35,7 @@ def _init_firebase():
|
|
| 35 |
logger.info("β
Firebase Admin SDK initialized successfully.")
|
| 36 |
except Exception as e:
|
| 37 |
logger.error(f"β Failed to initialize Firebase Admin SDK: {e}")
|
| 38 |
-
raise
|
| 39 |
|
| 40 |
# Run initialization at module load time
|
| 41 |
_init_firebase()
|
|
|
|
| 35 |
logger.info("β
Firebase Admin SDK initialized successfully.")
|
| 36 |
except Exception as e:
|
| 37 |
logger.error(f"β Failed to initialize Firebase Admin SDK: {e}")
|
| 38 |
+
# Don't raise β allow app to start without Firebase auth
|
| 39 |
|
| 40 |
# Run initialization at module load time
|
| 41 |
_init_firebase()
|