Ahmedik95316 commited on
Commit
9e0e49b
·
1 Parent(s): d3d769e

Update app/streamlit_app.py

Browse files
Files changed (1) hide show
  1. app/streamlit_app.py +84 -0
app/streamlit_app.py CHANGED
@@ -161,6 +161,45 @@ class StreamlitAppManager:
161
  return None
162
 
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  # Initialize app manager
165
  app_manager = StreamlitAppManager()
166
 
@@ -1539,6 +1578,9 @@ def render_system_status():
1539
  else:
1540
  st.warning("No model metadata available")
1541
 
 
 
 
1542
  # Recent activity
1543
  st.subheader("📜 Recent Activity")
1544
 
@@ -1642,6 +1684,48 @@ if st.session_state.auto_refresh:
1642
  st.session_state.last_refresh = datetime.now()
1643
  st.rerun()
1644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1645
  # Run main application
1646
  if __name__ == "__main__":
1647
  main()
 
161
  return None
162
 
163
 
164
+ def get_validation_statistics_from_api(self):
165
+ """Get validation statistics from API"""
166
+ try:
167
+ if not self.api_available:
168
+ return None
169
+
170
+ response = self.session.get(
171
+ f"{self.config['api_url']}/validation/statistics",
172
+ timeout=10
173
+ )
174
+
175
+ if response.status_code == 200:
176
+ return response.json()
177
+ else:
178
+ return None
179
+ except Exception as e:
180
+ logger.warning(f"Could not fetch validation statistics: {e}")
181
+ return None
182
+
183
+ def get_validation_health_from_api(self):
184
+ """Get validation system health from API"""
185
+ try:
186
+ if not self.api_available:
187
+ return None
188
+
189
+ response = self.session.get(
190
+ f"{self.config['api_url']}/validation/health",
191
+ timeout=10
192
+ )
193
+
194
+ if response.status_code == 200:
195
+ return response.json()
196
+ else:
197
+ return None
198
+ except Exception as e:
199
+ logger.warning(f"Could not fetch validation health: {e}")
200
+ return None
201
+
202
+
203
  # Initialize app manager
204
  app_manager = StreamlitAppManager()
205
 
 
1578
  else:
1579
  st.warning("No model metadata available")
1580
 
1581
+ st.divider()
1582
+ show_validation_status()
1583
+
1584
  # Recent activity
1585
  st.subheader("📜 Recent Activity")
1586
 
 
1684
  st.session_state.last_refresh = datetime.now()
1685
  st.rerun()
1686
 
1687
+
1688
+ def show_validation_status():
1689
+ """Display validation system status"""
1690
+ st.subheader("Data Validation Status")
1691
+
1692
+ validation_health = app_manager.get_validation_health_from_api()
1693
+ validation_stats = app_manager.get_validation_statistics_from_api()
1694
+
1695
+ if validation_health:
1696
+ health_data = validation_health.get('validation_health', {})
1697
+ overall_status = health_data.get('overall_status', 'unknown')
1698
+
1699
+ if overall_status == 'healthy':
1700
+ st.success("Validation System: Healthy")
1701
+ elif overall_status == 'degraded':
1702
+ st.warning("Validation System: Degraded")
1703
+ else:
1704
+ st.error("Validation System: Unhealthy")
1705
+
1706
+ if validation_stats and validation_stats.get('statistics_available'):
1707
+ overall_metrics = validation_stats.get('overall_metrics', {})
1708
+
1709
+ col1, col2, col3, col4 = st.columns(4)
1710
+
1711
+ with col1:
1712
+ st.metric("Total Validations", overall_metrics.get('total_validations', 0))
1713
+
1714
+ with col2:
1715
+ st.metric("Articles Processed", overall_metrics.get('total_articles_processed', 0))
1716
+
1717
+ with col3:
1718
+ success_rate = overall_metrics.get('overall_success_rate', 0)
1719
+ st.metric("Success Rate", f"{success_rate:.1%}")
1720
+
1721
+ with col4:
1722
+ quality_score = overall_metrics.get('average_quality_score', 0)
1723
+ st.metric("Quality Score", f"{quality_score:.3f}")
1724
+
1725
+ else:
1726
+ st.info("No validation statistics available yet")
1727
+
1728
+
1729
  # Run main application
1730
  if __name__ == "__main__":
1731
  main()