Spaces:
Running
Running
Mandark-droid
commited on
Commit
·
0fca968
1
Parent(s):
d0bd9af
Move GPU metrics from Trace Detail to Run Detail screen
Browse files- Add GPU Metrics tab to Run Detail screen (Screen 3)
- Remove GPU Metrics tab from Trace Detail screen (Screen 4)
- Update run detail handlers to load and display GPU metrics
- GPU metrics now show at run level instead of trace level
- Makes more sense as metrics are per-run, not per-trace
app.py
CHANGED
|
@@ -229,23 +229,6 @@ def on_test_case_select(evt: gr.SelectData, df):
|
|
| 229 |
# Create span details table
|
| 230 |
span_table_df = create_span_details_table(spans)
|
| 231 |
|
| 232 |
-
# Load GPU metrics (if available)
|
| 233 |
-
gpu_summary_html = "<div style='padding: 20px; text-align: center;'>⚠️ No GPU metrics available (expected for API models)</div>"
|
| 234 |
-
gpu_plot = None
|
| 235 |
-
gpu_json_data = {}
|
| 236 |
-
|
| 237 |
-
try:
|
| 238 |
-
if 'metrics_dataset' in current_selected_run and current_selected_run['metrics_dataset']:
|
| 239 |
-
metrics_dataset = current_selected_run['metrics_dataset']
|
| 240 |
-
gpu_metrics_data = data_loader.load_metrics(metrics_dataset)
|
| 241 |
-
|
| 242 |
-
if gpu_metrics_data is not None and not gpu_metrics_data.empty:
|
| 243 |
-
gpu_plot = create_gpu_metrics_dashboard(gpu_metrics_data)
|
| 244 |
-
gpu_summary_html = create_gpu_summary_cards(gpu_metrics_data)
|
| 245 |
-
gpu_json_data = gpu_metrics_data.to_dict('records')
|
| 246 |
-
except Exception as e:
|
| 247 |
-
print(f"[WARNING] Could not load GPU metrics: {e}")
|
| 248 |
-
|
| 249 |
# Return dictionary with visibility updates and data
|
| 250 |
return {
|
| 251 |
run_detail_screen: gr.update(visible=False),
|
|
@@ -255,10 +238,7 @@ def on_test_case_select(evt: gr.SelectData, df):
|
|
| 255 |
trace_thought_graph: gr.update(value=thought_graph_plot),
|
| 256 |
span_visualization: gr.update(value=span_viz_plot),
|
| 257 |
span_details_table: gr.update(value=span_table_df),
|
| 258 |
-
span_details_json: gr.update(value=span_details_data)
|
| 259 |
-
gpu_summary_cards_html: gr.update(value=gpu_summary_html),
|
| 260 |
-
gpu_metrics_plot: gr.update(value=gpu_plot),
|
| 261 |
-
gpu_metrics_json: gr.update(value=gpu_json_data)
|
| 262 |
}
|
| 263 |
|
| 264 |
except Exception as e:
|
|
@@ -863,6 +843,24 @@ def on_html_table_row_click(row_index_str):
|
|
| 863 |
if display_columns:
|
| 864 |
display_df = display_df[display_columns]
|
| 865 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 866 |
print(f"[DEBUG] Successfully loaded run detail for: {run_data.get('model', 'Unknown')}")
|
| 867 |
|
| 868 |
return {
|
|
@@ -872,7 +870,11 @@ def on_html_table_row_click(row_index_str):
|
|
| 872 |
run_metadata_html: gr.update(value=metadata_html),
|
| 873 |
test_cases_table: gr.update(value=display_df),
|
| 874 |
run_card_html: gr.update(value=run_card_html_content),
|
| 875 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 876 |
}
|
| 877 |
|
| 878 |
except Exception as e:
|
|
@@ -886,7 +888,11 @@ def on_html_table_row_click(row_index_str):
|
|
| 886 |
run_metadata_html: gr.update(),
|
| 887 |
test_cases_table: gr.update(),
|
| 888 |
run_card_html: gr.update(),
|
| 889 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 890 |
}
|
| 891 |
|
| 892 |
|
|
@@ -1072,6 +1078,24 @@ def on_drilldown_select(evt: gr.SelectData, df):
|
|
| 1072 |
if display_columns:
|
| 1073 |
display_df = display_df[display_columns]
|
| 1074 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1075 |
print(f"[DEBUG] Successfully loaded run detail for: {run_data.get('model', 'Unknown')}")
|
| 1076 |
|
| 1077 |
return {
|
|
@@ -1081,7 +1105,10 @@ def on_drilldown_select(evt: gr.SelectData, df):
|
|
| 1081 |
run_metadata_html: gr.update(value=metadata_html),
|
| 1082 |
test_cases_table: gr.update(value=display_df),
|
| 1083 |
performance_charts: gr.update(value=perf_chart),
|
| 1084 |
-
run_card_html: gr.update(value=run_card_html_content)
|
|
|
|
|
|
|
|
|
|
| 1085 |
}
|
| 1086 |
|
| 1087 |
except Exception as e:
|
|
@@ -1097,7 +1124,10 @@ def on_drilldown_select(evt: gr.SelectData, df):
|
|
| 1097 |
run_metadata_html: gr.update(value="<h3>Error loading run detail</h3>"),
|
| 1098 |
test_cases_table: gr.update(value=pd.DataFrame()),
|
| 1099 |
performance_charts: gr.update(),
|
| 1100 |
-
run_card_html: gr.update()
|
|
|
|
|
|
|
|
|
|
| 1101 |
}
|
| 1102 |
|
| 1103 |
|
|
@@ -1534,6 +1564,17 @@ with gr.Blocks(title="TraceMind-AI", theme=theme) as app:
|
|
| 1534 |
gr.Markdown("*Performance metrics and charts*")
|
| 1535 |
performance_charts = gr.Plot(label="Performance Analysis", show_label=False)
|
| 1536 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1537 |
# Screen 4: Trace Detail with Sub-tabs
|
| 1538 |
with gr.Column(visible=False) as trace_detail_screen:
|
| 1539 |
with gr.Row():
|
|
@@ -1564,17 +1605,6 @@ with gr.Blocks(title="TraceMind-AI", theme=theme) as app:
|
|
| 1564 |
gr.Markdown("*Hover over spans for details. Drag to zoom, double-click to reset.*")
|
| 1565 |
span_visualization = gr.Plot(label="Trace Waterfall", show_label=False)
|
| 1566 |
|
| 1567 |
-
with gr.TabItem("🖥️ GPU Metrics"):
|
| 1568 |
-
gr.Markdown("*Performance metrics for GPU-based models (not available for API models)*")
|
| 1569 |
-
gpu_summary_cards_html = gr.HTML(label="GPU Summary", show_label=False)
|
| 1570 |
-
|
| 1571 |
-
with gr.Tabs():
|
| 1572 |
-
with gr.TabItem("📈 Time Series Dashboard"):
|
| 1573 |
-
gpu_metrics_plot = gr.Plot(label="GPU Metrics Over Time", show_label=False)
|
| 1574 |
-
|
| 1575 |
-
with gr.TabItem("📋 Raw Metrics Data"):
|
| 1576 |
-
gpu_metrics_json = gr.JSON(label="GPU Metrics Data")
|
| 1577 |
-
|
| 1578 |
with gr.TabItem("📝 Span Details"):
|
| 1579 |
gr.Markdown("*Detailed span information with token and cost data*")
|
| 1580 |
span_details_table = gr.Dataframe(
|
|
@@ -1910,7 +1940,17 @@ with gr.Blocks(title="TraceMind-AI", theme=theme) as app:
|
|
| 1910 |
leaderboard_table.select(
|
| 1911 |
fn=on_drilldown_select,
|
| 1912 |
inputs=[leaderboard_table], # Pass dataframe to handler (like MockTraceMind)
|
| 1913 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1914 |
)
|
| 1915 |
|
| 1916 |
back_to_leaderboard_btn.click(
|
|
@@ -1931,10 +1971,7 @@ with gr.Blocks(title="TraceMind-AI", theme=theme) as app:
|
|
| 1931 |
trace_thought_graph,
|
| 1932 |
span_visualization,
|
| 1933 |
span_details_table,
|
| 1934 |
-
span_details_json
|
| 1935 |
-
gpu_summary_cards_html,
|
| 1936 |
-
gpu_metrics_plot,
|
| 1937 |
-
gpu_metrics_json
|
| 1938 |
]
|
| 1939 |
)
|
| 1940 |
|
|
@@ -1948,7 +1985,18 @@ with gr.Blocks(title="TraceMind-AI", theme=theme) as app:
|
|
| 1948 |
selected_row_index.change(
|
| 1949 |
fn=on_html_table_row_click,
|
| 1950 |
inputs=[selected_row_index],
|
| 1951 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1952 |
)
|
| 1953 |
|
| 1954 |
# Download run report card as PNG
|
|
|
|
| 229 |
# Create span details table
|
| 230 |
span_table_df = create_span_details_table(spans)
|
| 231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
# Return dictionary with visibility updates and data
|
| 233 |
return {
|
| 234 |
run_detail_screen: gr.update(visible=False),
|
|
|
|
| 238 |
trace_thought_graph: gr.update(value=thought_graph_plot),
|
| 239 |
span_visualization: gr.update(value=span_viz_plot),
|
| 240 |
span_details_table: gr.update(value=span_table_df),
|
| 241 |
+
span_details_json: gr.update(value=span_details_data)
|
|
|
|
|
|
|
|
|
|
| 242 |
}
|
| 243 |
|
| 244 |
except Exception as e:
|
|
|
|
| 843 |
if display_columns:
|
| 844 |
display_df = display_df[display_columns]
|
| 845 |
|
| 846 |
+
# Load GPU metrics (if available)
|
| 847 |
+
gpu_summary_html = "<div style='padding: 20px; text-align: center;'>⚠️ No GPU metrics available (expected for API models)</div>"
|
| 848 |
+
gpu_plot = None
|
| 849 |
+
gpu_json_data = {}
|
| 850 |
+
|
| 851 |
+
try:
|
| 852 |
+
if 'metrics_dataset' in run_data and run_data.get('metrics_dataset'):
|
| 853 |
+
metrics_dataset = run_data['metrics_dataset']
|
| 854 |
+
gpu_metrics_data = data_loader.load_metrics(metrics_dataset)
|
| 855 |
+
|
| 856 |
+
if gpu_metrics_data is not None and not gpu_metrics_data.empty:
|
| 857 |
+
from screens.trace_detail import create_gpu_metrics_dashboard, create_gpu_summary_cards
|
| 858 |
+
gpu_plot = create_gpu_metrics_dashboard(gpu_metrics_data)
|
| 859 |
+
gpu_summary_html = create_gpu_summary_cards(gpu_metrics_data)
|
| 860 |
+
gpu_json_data = gpu_metrics_data.to_dict('records')
|
| 861 |
+
except Exception as e:
|
| 862 |
+
print(f"[WARNING] Could not load GPU metrics for run: {e}")
|
| 863 |
+
|
| 864 |
print(f"[DEBUG] Successfully loaded run detail for: {run_data.get('model', 'Unknown')}")
|
| 865 |
|
| 866 |
return {
|
|
|
|
| 870 |
run_metadata_html: gr.update(value=metadata_html),
|
| 871 |
test_cases_table: gr.update(value=display_df),
|
| 872 |
run_card_html: gr.update(value=run_card_html_content),
|
| 873 |
+
performance_charts: gr.update(value=perf_chart),
|
| 874 |
+
selected_row_index: gr.update(value=""), # Clear textbox
|
| 875 |
+
run_gpu_summary_cards_html: gr.update(value=gpu_summary_html),
|
| 876 |
+
run_gpu_metrics_plot: gr.update(value=gpu_plot),
|
| 877 |
+
run_gpu_metrics_json: gr.update(value=gpu_json_data)
|
| 878 |
}
|
| 879 |
|
| 880 |
except Exception as e:
|
|
|
|
| 888 |
run_metadata_html: gr.update(),
|
| 889 |
test_cases_table: gr.update(),
|
| 890 |
run_card_html: gr.update(),
|
| 891 |
+
performance_charts: gr.update(),
|
| 892 |
+
selected_row_index: gr.update(value=""), # Clear textbox
|
| 893 |
+
run_gpu_summary_cards_html: gr.update(),
|
| 894 |
+
run_gpu_metrics_plot: gr.update(),
|
| 895 |
+
run_gpu_metrics_json: gr.update()
|
| 896 |
}
|
| 897 |
|
| 898 |
|
|
|
|
| 1078 |
if display_columns:
|
| 1079 |
display_df = display_df[display_columns]
|
| 1080 |
|
| 1081 |
+
# Load GPU metrics (if available)
|
| 1082 |
+
gpu_summary_html = "<div style='padding: 20px; text-align: center;'>⚠️ No GPU metrics available (expected for API models)</div>"
|
| 1083 |
+
gpu_plot = None
|
| 1084 |
+
gpu_json_data = {}
|
| 1085 |
+
|
| 1086 |
+
try:
|
| 1087 |
+
if 'metrics_dataset' in run_data and run_data.get('metrics_dataset'):
|
| 1088 |
+
metrics_dataset = run_data['metrics_dataset']
|
| 1089 |
+
gpu_metrics_data = data_loader.load_metrics(metrics_dataset)
|
| 1090 |
+
|
| 1091 |
+
if gpu_metrics_data is not None and not gpu_metrics_data.empty:
|
| 1092 |
+
from screens.trace_detail import create_gpu_metrics_dashboard, create_gpu_summary_cards
|
| 1093 |
+
gpu_plot = create_gpu_metrics_dashboard(gpu_metrics_data)
|
| 1094 |
+
gpu_summary_html = create_gpu_summary_cards(gpu_metrics_data)
|
| 1095 |
+
gpu_json_data = gpu_metrics_data.to_dict('records')
|
| 1096 |
+
except Exception as e:
|
| 1097 |
+
print(f"[WARNING] Could not load GPU metrics for run: {e}")
|
| 1098 |
+
|
| 1099 |
print(f"[DEBUG] Successfully loaded run detail for: {run_data.get('model', 'Unknown')}")
|
| 1100 |
|
| 1101 |
return {
|
|
|
|
| 1105 |
run_metadata_html: gr.update(value=metadata_html),
|
| 1106 |
test_cases_table: gr.update(value=display_df),
|
| 1107 |
performance_charts: gr.update(value=perf_chart),
|
| 1108 |
+
run_card_html: gr.update(value=run_card_html_content),
|
| 1109 |
+
run_gpu_summary_cards_html: gr.update(value=gpu_summary_html),
|
| 1110 |
+
run_gpu_metrics_plot: gr.update(value=gpu_plot),
|
| 1111 |
+
run_gpu_metrics_json: gr.update(value=gpu_json_data)
|
| 1112 |
}
|
| 1113 |
|
| 1114 |
except Exception as e:
|
|
|
|
| 1124 |
run_metadata_html: gr.update(value="<h3>Error loading run detail</h3>"),
|
| 1125 |
test_cases_table: gr.update(value=pd.DataFrame()),
|
| 1126 |
performance_charts: gr.update(),
|
| 1127 |
+
run_card_html: gr.update(),
|
| 1128 |
+
run_gpu_summary_cards_html: gr.update(),
|
| 1129 |
+
run_gpu_metrics_plot: gr.update(),
|
| 1130 |
+
run_gpu_metrics_json: gr.update()
|
| 1131 |
}
|
| 1132 |
|
| 1133 |
|
|
|
|
| 1564 |
gr.Markdown("*Performance metrics and charts*")
|
| 1565 |
performance_charts = gr.Plot(label="Performance Analysis", show_label=False)
|
| 1566 |
|
| 1567 |
+
with gr.TabItem("🖥️ GPU Metrics"):
|
| 1568 |
+
gr.Markdown("*Performance metrics for GPU-based models (not available for API models)*")
|
| 1569 |
+
run_gpu_summary_cards_html = gr.HTML(label="GPU Summary", show_label=False)
|
| 1570 |
+
|
| 1571 |
+
with gr.Tabs():
|
| 1572 |
+
with gr.TabItem("📈 Time Series Dashboard"):
|
| 1573 |
+
run_gpu_metrics_plot = gr.Plot(label="GPU Metrics Over Time", show_label=False)
|
| 1574 |
+
|
| 1575 |
+
with gr.TabItem("📋 Raw Metrics Data"):
|
| 1576 |
+
run_gpu_metrics_json = gr.JSON(label="GPU Metrics Data")
|
| 1577 |
+
|
| 1578 |
# Screen 4: Trace Detail with Sub-tabs
|
| 1579 |
with gr.Column(visible=False) as trace_detail_screen:
|
| 1580 |
with gr.Row():
|
|
|
|
| 1605 |
gr.Markdown("*Hover over spans for details. Drag to zoom, double-click to reset.*")
|
| 1606 |
span_visualization = gr.Plot(label="Trace Waterfall", show_label=False)
|
| 1607 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1608 |
with gr.TabItem("📝 Span Details"):
|
| 1609 |
gr.Markdown("*Detailed span information with token and cost data*")
|
| 1610 |
span_details_table = gr.Dataframe(
|
|
|
|
| 1940 |
leaderboard_table.select(
|
| 1941 |
fn=on_drilldown_select,
|
| 1942 |
inputs=[leaderboard_table], # Pass dataframe to handler (like MockTraceMind)
|
| 1943 |
+
outputs=[
|
| 1944 |
+
leaderboard_screen,
|
| 1945 |
+
run_detail_screen,
|
| 1946 |
+
run_metadata_html,
|
| 1947 |
+
test_cases_table,
|
| 1948 |
+
performance_charts,
|
| 1949 |
+
run_card_html,
|
| 1950 |
+
run_gpu_summary_cards_html,
|
| 1951 |
+
run_gpu_metrics_plot,
|
| 1952 |
+
run_gpu_metrics_json
|
| 1953 |
+
]
|
| 1954 |
)
|
| 1955 |
|
| 1956 |
back_to_leaderboard_btn.click(
|
|
|
|
| 1971 |
trace_thought_graph,
|
| 1972 |
span_visualization,
|
| 1973 |
span_details_table,
|
| 1974 |
+
span_details_json
|
|
|
|
|
|
|
|
|
|
| 1975 |
]
|
| 1976 |
)
|
| 1977 |
|
|
|
|
| 1985 |
selected_row_index.change(
|
| 1986 |
fn=on_html_table_row_click,
|
| 1987 |
inputs=[selected_row_index],
|
| 1988 |
+
outputs=[
|
| 1989 |
+
leaderboard_screen,
|
| 1990 |
+
run_detail_screen,
|
| 1991 |
+
run_metadata_html,
|
| 1992 |
+
test_cases_table,
|
| 1993 |
+
run_card_html,
|
| 1994 |
+
performance_charts,
|
| 1995 |
+
selected_row_index,
|
| 1996 |
+
run_gpu_summary_cards_html,
|
| 1997 |
+
run_gpu_metrics_plot,
|
| 1998 |
+
run_gpu_metrics_json
|
| 1999 |
+
]
|
| 2000 |
)
|
| 2001 |
|
| 2002 |
# Download run report card as PNG
|