Testys commited on
Commit
feca57f
Β·
1 Parent(s): 4e62c61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -14
app.py CHANGED
@@ -42,30 +42,62 @@ except ImportError:
42
  logger.warning("Diagnostics module not available")
43
 
44
  def add_diagnostics_ui(search_system):
45
- """Enhanced diagnostics UI with system checks"""
46
  with st.sidebar.expander("πŸ”§ Diagnostics", expanded=False):
47
  if st.button("Run Full System Check"):
48
  with st.spinner("Performing comprehensive system check..."):
 
49
  col1, col2 = st.columns(2)
50
 
51
- # Metadata check
 
 
 
52
  with col1:
53
- if diagnose_parquet_files("metadata_shards"):
54
- st.success("βœ… Metadata shards valid")
 
 
 
 
 
 
 
 
 
 
 
55
  else:
56
- st.error("❌ Metadata issues detected")
57
-
58
- # Index check
59
  with col2:
60
- if len(search_system.index_shards) > 0:
61
- st.success(f"βœ… {len(search_system.index_shards)} FAISS shards loaded")
 
 
 
 
 
 
 
 
 
 
62
  else:
63
- st.error("❌ No FAISS shards found")
64
-
65
- # Resource check
66
- st.metric("Memory Usage", f"{psutil.Process().memory_info().rss // 1024 ** 2} MB")
67
- st.metric("CPU Utilization", f"{psutil.cpu_percent()}%")
68
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  def main():
70
  st.set_page_config(
71
  page_title="Semantic Search Engine",
 
42
  logger.warning("Diagnostics module not available")
43
 
44
  def add_diagnostics_ui(search_system):
45
+ """Enhanced diagnostics UI with proper directory checks"""
46
  with st.sidebar.expander("πŸ”§ Diagnostics", expanded=False):
47
  if st.button("Run Full System Check"):
48
  with st.spinner("Performing comprehensive system check..."):
49
+ # Create columns for organized display
50
  col1, col2 = st.columns(2)
51
 
52
+ # Get actual paths from the search system
53
+ metadata_dir = search_system.metadata_mgr.shard_dir
54
+ faiss_dir = search_system.shard_dir # From SemanticSearch class
55
+
56
  with col1:
57
+ # Metadata directory check
58
+ st.subheader("πŸ“‚ Metadata Validation")
59
+ if metadata_dir.exists():
60
+ # Check directory structure
61
+ dir_status = any(metadata_dir.glob("*.parquet"))
62
+ st.write(f"Directory: `{metadata_dir}`")
63
+ st.write(f"Parquet Files Found: {'βœ…' if dir_status else '❌'}")
64
+
65
+ # Check individual files
66
+ if diagnose_parquet_files(str(metadata_dir)):
67
+ st.success("βœ… Metadata shards valid")
68
+ else:
69
+ st.error("❌ Metadata issues detected")
70
  else:
71
+ st.error("Metadata directory not found")
72
+
 
73
  with col2:
74
+ # FAISS index check
75
+ st.subheader("πŸ“š FAISS Validation")
76
+ if faiss_dir.exists():
77
+ index_files = list(faiss_dir.glob("*.index"))
78
+ st.write(f"Directory: `{faiss_dir}`")
79
+ st.write(f"Index Files Found: {len(index_files)}")
80
+
81
+ if len(search_system.index_shards) > 0:
82
+ st.success(f"βœ… {len(search_system.index_shards)} FAISS shards loaded")
83
+ st.write(f"Total Vectors: {sum(s.ntotal for s in search_system.index_shards):,}")
84
+ else:
85
+ st.error("❌ No FAISS shards loaded")
86
  else:
87
+ st.error("FAISS directory not found")
 
 
 
 
88
 
89
+ # System resource check
90
+ st.subheader("πŸ’» System Resources")
91
+ col_res1, col_res2 = st.columns(2)
92
+ with col_res1:
93
+ st.metric("Memory Usage",
94
+ f"{psutil.Process().memory_info().rss // 1024 ** 2} MB",
95
+ help="Current process memory usage")
96
+
97
+ with col_res2:
98
+ st.metric("CPU Utilization",
99
+ f"{psutil.cpu_percent()}%",
100
+ help="Total system CPU usage")
101
  def main():
102
  st.set_page_config(
103
  page_title="Semantic Search Engine",