Spaces:
Running
Running
Update app.py
Browse files
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
|
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 |
-
#
|
|
|
|
|
|
|
52 |
with col1:
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
else:
|
56 |
-
st.error("
|
57 |
-
|
58 |
-
# Index check
|
59 |
with col2:
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
else:
|
63 |
-
st.error("
|
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",
|