Update app/streamlit_app.py
Browse filesAdding section to force system initialization
- app/streamlit_app.py +38 -0
app/streamlit_app.py
CHANGED
|
@@ -1706,6 +1706,44 @@ def render_system_status():
|
|
| 1706 |
else:
|
| 1707 |
st.warning("No model metadata available")
|
| 1708 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1709 |
def render_monitoring_dashboard():
|
| 1710 |
"""Render real-time monitoring dashboard"""
|
| 1711 |
st.subheader("π Real-time Monitoring Dashboard")
|
|
|
|
| 1706 |
else:
|
| 1707 |
st.warning("No model metadata available")
|
| 1708 |
|
| 1709 |
+
# Reinitialize System
|
| 1710 |
+
def reinitialize_system():
|
| 1711 |
+
"""Run system reinitialization with progress tracking"""
|
| 1712 |
+
progress_bar = st.progress(0)
|
| 1713 |
+
status_text = st.empty()
|
| 1714 |
+
|
| 1715 |
+
try:
|
| 1716 |
+
status_text.text("Starting ensemble training...")
|
| 1717 |
+
progress_bar.progress(10)
|
| 1718 |
+
|
| 1719 |
+
# Import and run ensemble training
|
| 1720 |
+
import subprocess
|
| 1721 |
+
import sys
|
| 1722 |
+
|
| 1723 |
+
# Run initialization in subprocess to capture output
|
| 1724 |
+
result = subprocess.run([
|
| 1725 |
+
sys.executable,
|
| 1726 |
+
"/app/initialize_system.py",
|
| 1727 |
+
"--force-ensemble"
|
| 1728 |
+
], capture_output=True, text=True, timeout=300) # 5 min timeout
|
| 1729 |
+
|
| 1730 |
+
if result.returncode == 0:
|
| 1731 |
+
progress_bar.progress(100)
|
| 1732 |
+
status_text.text("β
Ensemble training completed successfully!")
|
| 1733 |
+
st.success("System reinitialized with ensemble model")
|
| 1734 |
+
st.balloons()
|
| 1735 |
+
else:
|
| 1736 |
+
status_text.text("β Ensemble training failed")
|
| 1737 |
+
st.error(f"Reinitialization failed: {result.stderr}")
|
| 1738 |
+
|
| 1739 |
+
except subprocess.TimeoutExpired:
|
| 1740 |
+
status_text.text("β° Training timeout - using fallback")
|
| 1741 |
+
st.warning("Ensemble training timed out, system may have fallen back to basic model")
|
| 1742 |
+
except Exception as e:
|
| 1743 |
+
status_text.text(f"β Error: {str(e)}")
|
| 1744 |
+
st.error(f"Reinitialization error: {str(e)}")
|
| 1745 |
+
|
| 1746 |
+
|
| 1747 |
def render_monitoring_dashboard():
|
| 1748 |
"""Render real-time monitoring dashboard"""
|
| 1749 |
st.subheader("π Real-time Monitoring Dashboard")
|