|
|
import matplotlib.pyplot as plt |
|
|
import matplotlib |
|
|
import pandas as pd |
|
|
import gradio as gr |
|
|
|
|
|
from data import CIResults |
|
|
from utils import logger |
|
|
from summary_page import create_summary_page |
|
|
from model_page import plot_model_stats |
|
|
from time_series import create_time_series_summary, create_model_time_series |
|
|
|
|
|
|
|
|
|
|
|
matplotlib.rcParams['figure.facecolor'] = '#000000' |
|
|
matplotlib.rcParams['axes.facecolor'] = '#000000' |
|
|
matplotlib.rcParams['savefig.facecolor'] = '#000000' |
|
|
plt.ioff() |
|
|
|
|
|
|
|
|
|
|
|
Ci_results = CIResults() |
|
|
Ci_results.load_data() |
|
|
|
|
|
Ci_results.schedule_data_reload() |
|
|
|
|
|
|
|
|
|
|
|
def model_has_failures(model_name): |
|
|
"""Check if a model has any failures (AMD or NVIDIA).""" |
|
|
if Ci_results.df is None or Ci_results.df.empty: |
|
|
return False |
|
|
|
|
|
|
|
|
model_name_lower = model_name.lower() |
|
|
|
|
|
|
|
|
if model_name_lower not in Ci_results.df.index: |
|
|
return False |
|
|
row = Ci_results.df.loc[model_name_lower] |
|
|
|
|
|
|
|
|
amd_multi_failures = row.get('failed_multi_no_amd', 0) |
|
|
amd_single_failures = row.get('failed_single_no_amd', 0) |
|
|
nvidia_multi_failures = row.get('failed_multi_no_nvidia', 0) |
|
|
nvidia_single_failures = row.get('failed_single_no_nvidia', 0) |
|
|
return any([ |
|
|
amd_multi_failures > 0, |
|
|
amd_single_failures > 0, |
|
|
nvidia_multi_failures > 0, |
|
|
nvidia_single_failures > 0, |
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
def get_description_text(): |
|
|
"""Get description text with integrated last update time.""" |
|
|
msg = [ |
|
|
"Transformer CI Dashboard", |
|
|
"-", |
|
|
"AMD runs on MI325", |
|
|
"NVIDIA runs on A10", |
|
|
] |
|
|
msg = ["**" + x + "**" for x in msg] + [""] |
|
|
if Ci_results.latest_update_msg: |
|
|
msg.append(f"*({Ci_results.latest_update_msg})*") |
|
|
else: |
|
|
msg.append("*(loading...)*") |
|
|
return "<br>".join(msg) |
|
|
|
|
|
|
|
|
def load_css(): |
|
|
try: |
|
|
with open("styles.css", "r") as f: |
|
|
css_content = f.read() |
|
|
|
|
|
return css_content |
|
|
except FileNotFoundError: |
|
|
logger.warning("styles.css not found, using minimal default styles") |
|
|
return "body { background: #000; color: #fff; }" |
|
|
|
|
|
|
|
|
|
|
|
with gr.Blocks(title="Model Test Results Dashboard", css=load_css()) as demo: |
|
|
|
|
|
|
|
|
with gr.Row(): |
|
|
|
|
|
with gr.Column(scale=1, elem_classes=["sidebar"]): |
|
|
gr.Markdown("# 🤖 TCID", elem_classes=["sidebar-title"]) |
|
|
|
|
|
|
|
|
description_text = get_description_text() |
|
|
description_display = gr.Markdown(description_text, elem_classes=["sidebar-description"]) |
|
|
|
|
|
|
|
|
with gr.Row(elem_classes=["view-toggle-row"]): |
|
|
current_view_button = gr.Button( |
|
|
"current\n📊", |
|
|
variant="primary", |
|
|
size="lg", |
|
|
elem_classes=["view-toggle-button", "view-toggle-active"] |
|
|
) |
|
|
historical_view_button = gr.Button( |
|
|
"history\n📈", |
|
|
variant="secondary", |
|
|
size="lg", |
|
|
elem_classes=["view-toggle-button"] |
|
|
) |
|
|
|
|
|
|
|
|
with gr.Column(visible=False, elem_classes=["date-selection"]) as date_selection: |
|
|
gr.Markdown("**📅 Date Range Selection**", elem_classes=["date-header"]) |
|
|
|
|
|
with gr.Row(): |
|
|
start_date = gr.Dropdown( |
|
|
choices=Ci_results.available_dates, |
|
|
value=Ci_results.available_dates[0] if Ci_results.available_dates else None, |
|
|
label="Start Date", |
|
|
elem_classes=["date-dropdown"] |
|
|
) |
|
|
end_date = gr.Dropdown( |
|
|
choices=Ci_results.available_dates, |
|
|
value=Ci_results.available_dates[0] if Ci_results.available_dates else None, |
|
|
label="End Date", |
|
|
elem_classes=["date-dropdown"] |
|
|
) |
|
|
|
|
|
load_historical_button = gr.Button( |
|
|
"Load Historical Data", |
|
|
variant="primary", |
|
|
size="sm", |
|
|
elem_classes=["load-historical-button"] |
|
|
) |
|
|
|
|
|
|
|
|
summary_button = gr.Button( |
|
|
"summary\n📊", |
|
|
variant="primary", |
|
|
size="lg", |
|
|
elem_classes=["summary-button"] |
|
|
) |
|
|
|
|
|
|
|
|
model_toggle_button = gr.Button( |
|
|
f"► Select model ({len(Ci_results.available_models)})", |
|
|
variant="secondary", |
|
|
elem_classes=["model-header"] |
|
|
) |
|
|
|
|
|
|
|
|
with gr.Column(elem_classes=["model-list", "model-list-hidden"]) as model_list_container: |
|
|
|
|
|
model_buttons = [] |
|
|
model_choices = [model.lower() for model in Ci_results.available_models] if Ci_results.available_models else ["auto", "bert", "clip", "llama"] |
|
|
|
|
|
print(f"Creating {len(model_choices)} model buttons: {model_choices}") |
|
|
|
|
|
for model_name in model_choices: |
|
|
|
|
|
has_failures = model_has_failures(model_name) |
|
|
button_classes = ["model-button"] |
|
|
if has_failures: |
|
|
button_classes.append("model-button-failed") |
|
|
|
|
|
btn = gr.Button( |
|
|
model_name, |
|
|
variant="secondary", |
|
|
size="sm", |
|
|
elem_classes=button_classes |
|
|
) |
|
|
model_buttons.append(btn) |
|
|
|
|
|
|
|
|
ci_links_display = gr.Markdown("🔗 **CI Jobs:** *Loading...*", elem_classes=["sidebar-links"]) |
|
|
|
|
|
|
|
|
with gr.Column(scale=4, elem_classes=["main-content"]): |
|
|
|
|
|
with gr.Column(visible=True, elem_classes=["current-view"]) as current_view: |
|
|
|
|
|
summary_display = gr.Plot( |
|
|
value=create_summary_page(Ci_results.df, Ci_results.available_models), |
|
|
label="", |
|
|
format="png", |
|
|
elem_classes=["plot-container"], |
|
|
visible=True |
|
|
) |
|
|
|
|
|
|
|
|
with gr.Column(visible=False, elem_classes=["detail-view"]) as detail_view: |
|
|
|
|
|
plot_output = gr.Plot( |
|
|
label="", |
|
|
format="png", |
|
|
elem_classes=["plot-container"] |
|
|
) |
|
|
|
|
|
|
|
|
with gr.Row(): |
|
|
with gr.Column(scale=1): |
|
|
amd_failed_tests_output = gr.Textbox( |
|
|
value="", |
|
|
lines=8, |
|
|
max_lines=8, |
|
|
interactive=False, |
|
|
container=False, |
|
|
elem_classes=["failed-tests"] |
|
|
) |
|
|
with gr.Column(scale=1): |
|
|
nvidia_failed_tests_output = gr.Textbox( |
|
|
value="", |
|
|
lines=8, |
|
|
max_lines=8, |
|
|
interactive=False, |
|
|
container=False, |
|
|
elem_classes=["failed-tests"] |
|
|
) |
|
|
|
|
|
|
|
|
with gr.Column(visible=False, elem_classes=["historical-view"]) as historical_view: |
|
|
|
|
|
time_series_summary_display = gr.Plot( |
|
|
label="", |
|
|
format="png", |
|
|
elem_classes=["plot-container"] |
|
|
) |
|
|
|
|
|
|
|
|
with gr.Column(visible=False, elem_classes=["time-series-detail-view"]) as time_series_detail_view: |
|
|
|
|
|
time_series_plot_output = gr.Plot( |
|
|
label="", |
|
|
format="png", |
|
|
elem_classes=["plot-container"] |
|
|
) |
|
|
|
|
|
|
|
|
for i, btn in enumerate(model_buttons): |
|
|
model_name = model_choices[i] |
|
|
btn.click( |
|
|
fn=lambda selected_model=model_name: plot_model_stats(Ci_results.df, selected_model), |
|
|
outputs=[plot_output, amd_failed_tests_output, nvidia_failed_tests_output] |
|
|
).then( |
|
|
fn=lambda: [gr.update(visible=False), gr.update(visible=True)], |
|
|
outputs=[summary_display, detail_view] |
|
|
) |
|
|
|
|
|
|
|
|
def toggle_model_list(current_visible): |
|
|
"""Toggle the visibility of the model list.""" |
|
|
new_visible = not current_visible |
|
|
arrow = "▼" if new_visible else "►" |
|
|
button_text = f"{arrow} Select model ({len(Ci_results.available_models)})" |
|
|
|
|
|
|
|
|
css_classes = ["model-list"] |
|
|
if new_visible: |
|
|
css_classes.append("model-list-visible") |
|
|
else: |
|
|
css_classes.append("model-list-hidden") |
|
|
|
|
|
return gr.update(value=button_text), gr.update(elem_classes=css_classes), new_visible |
|
|
|
|
|
|
|
|
model_list_visible = gr.State(False) |
|
|
|
|
|
model_toggle_button.click( |
|
|
fn=toggle_model_list, |
|
|
inputs=[model_list_visible], |
|
|
outputs=[model_toggle_button, model_list_container, model_list_visible] |
|
|
) |
|
|
|
|
|
|
|
|
def show_summary_and_update_links(): |
|
|
"""Show summary page and update CI links.""" |
|
|
return create_summary_page(Ci_results.df, Ci_results.available_models), get_description_text(), get_ci_links() |
|
|
|
|
|
summary_button.click( |
|
|
fn=show_summary_and_update_links, |
|
|
outputs=[summary_display, description_display, ci_links_display] |
|
|
).then( |
|
|
fn=lambda: [gr.update(visible=True), gr.update(visible=False)], |
|
|
outputs=[summary_display, detail_view] |
|
|
) |
|
|
|
|
|
|
|
|
def get_ci_links(): |
|
|
"""Get CI job links from the most recent data.""" |
|
|
try: |
|
|
|
|
|
if Ci_results.df is None or Ci_results.df.empty: |
|
|
return "🔗 **CI Jobs:** *Loading...*" |
|
|
|
|
|
|
|
|
amd_multi_link = None |
|
|
amd_single_link = None |
|
|
nvidia_multi_link = None |
|
|
nvidia_single_link = None |
|
|
|
|
|
for model_name in Ci_results.df.index: |
|
|
row = Ci_results.df.loc[model_name] |
|
|
|
|
|
|
|
|
if pd.notna(row.get('job_link_amd')) and (not amd_multi_link or not amd_single_link): |
|
|
amd_link_raw = row.get('job_link_amd') |
|
|
if isinstance(amd_link_raw, dict): |
|
|
if 'multi' in amd_link_raw and not amd_multi_link: |
|
|
amd_multi_link = amd_link_raw['multi'] |
|
|
if 'single' in amd_link_raw and not amd_single_link: |
|
|
amd_single_link = amd_link_raw['single'] |
|
|
|
|
|
|
|
|
if pd.notna(row.get('job_link_nvidia')) and (not nvidia_multi_link or not nvidia_single_link): |
|
|
nvidia_link_raw = row.get('job_link_nvidia') |
|
|
if isinstance(nvidia_link_raw, dict): |
|
|
if 'multi' in nvidia_link_raw and not nvidia_multi_link: |
|
|
nvidia_multi_link = nvidia_link_raw['multi'] |
|
|
if 'single' in nvidia_link_raw and not nvidia_single_link: |
|
|
nvidia_single_link = nvidia_link_raw['single'] |
|
|
|
|
|
|
|
|
if amd_multi_link and amd_single_link and nvidia_multi_link and nvidia_single_link: |
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
links_md = "❓ [**FAQ**](https://huggingface.co/spaces/transformers-community/transformers-ci-dashboard/blob/main/README.md)\n\n" |
|
|
links_md += "🔗 **CI Jobs:**\n\n" |
|
|
|
|
|
|
|
|
if amd_multi_link or amd_single_link: |
|
|
links_md += "**AMD:**\n" |
|
|
if amd_multi_link: |
|
|
links_md += f"• [Multi GPU]({amd_multi_link})\n" |
|
|
if amd_single_link: |
|
|
links_md += f"• [Single GPU]({amd_single_link})\n" |
|
|
links_md += "\n" |
|
|
|
|
|
|
|
|
if nvidia_multi_link or nvidia_single_link: |
|
|
links_md += "**NVIDIA:**\n" |
|
|
if nvidia_multi_link: |
|
|
links_md += f"• [Multi GPU]({nvidia_multi_link})\n" |
|
|
if nvidia_single_link: |
|
|
links_md += f"• [Single GPU]({nvidia_single_link})\n" |
|
|
|
|
|
if not (amd_multi_link or amd_single_link or nvidia_multi_link or nvidia_single_link): |
|
|
links_md += "*No links available*" |
|
|
|
|
|
return links_md |
|
|
except Exception as e: |
|
|
logger.error(f"getting CI links: {e}") |
|
|
return "🔗 **CI Jobs:** *Error loading links*\n\n❓ **[FAQ](README.md)**" |
|
|
|
|
|
|
|
|
|
|
|
def toggle_to_current_view(): |
|
|
"""Switch to current view.""" |
|
|
return [ |
|
|
gr.update(visible=True), |
|
|
gr.update(visible=False), |
|
|
gr.update(visible=False), |
|
|
gr.update(visible=True), |
|
|
gr.update(variant="primary", elem_classes=["view-toggle-button", "view-toggle-active"]), |
|
|
gr.update(variant="secondary", elem_classes=["view-toggle-button"]) |
|
|
] |
|
|
|
|
|
def toggle_to_historical_view(): |
|
|
"""Switch to historical view.""" |
|
|
return [ |
|
|
gr.update(visible=False), |
|
|
gr.update(visible=True), |
|
|
gr.update(visible=True), |
|
|
gr.update(visible=False), |
|
|
gr.update(variant="secondary", elem_classes=["view-toggle-button"]), |
|
|
gr.update(variant="primary", elem_classes=["view-toggle-button", "view-toggle-active"]) |
|
|
] |
|
|
|
|
|
current_view_button.click( |
|
|
fn=toggle_to_current_view, |
|
|
outputs=[current_view, historical_view, date_selection, summary_button, current_view_button, historical_view_button] |
|
|
) |
|
|
|
|
|
historical_view_button.click( |
|
|
fn=toggle_to_historical_view, |
|
|
outputs=[current_view, historical_view, date_selection, summary_button, current_view_button, historical_view_button] |
|
|
) |
|
|
|
|
|
|
|
|
def load_historical_data(start_date, end_date): |
|
|
"""Load and display historical data.""" |
|
|
if not start_date or not end_date: |
|
|
return gr.update(), "Please select both start and end dates." |
|
|
|
|
|
try: |
|
|
Ci_results.load_historical_data(start_date, end_date) |
|
|
if Ci_results.historical_df.empty: |
|
|
return gr.update(), "No historical data found for the selected date range." |
|
|
|
|
|
|
|
|
time_series_plot = create_time_series_summary(Ci_results.historical_df) |
|
|
return time_series_plot, f"Loaded historical data from {start_date} to {end_date}" |
|
|
except Exception as e: |
|
|
logger.error(f"Error loading historical data: {e}") |
|
|
return gr.update(), f"Error loading historical data: {str(e)}" |
|
|
|
|
|
load_historical_button.click( |
|
|
fn=load_historical_data, |
|
|
inputs=[start_date, end_date], |
|
|
outputs=[time_series_summary_display, description_display] |
|
|
) |
|
|
|
|
|
|
|
|
def show_time_series_model(selected_model): |
|
|
"""Show time-series view for a specific model.""" |
|
|
if Ci_results.historical_df.empty: |
|
|
return gr.update(), "No historical data loaded. Please load historical data first." |
|
|
|
|
|
try: |
|
|
time_series_plot = create_model_time_series(Ci_results.historical_df, selected_model) |
|
|
return time_series_plot |
|
|
except Exception as e: |
|
|
logger.error(f"Error creating time-series for model {selected_model}: {e}") |
|
|
return gr.update() |
|
|
|
|
|
|
|
|
for i, btn in enumerate(model_buttons): |
|
|
model_name = model_choices[i] |
|
|
|
|
|
|
|
|
btn.click( |
|
|
fn=lambda selected_model=model_name: plot_model_stats(Ci_results.df, selected_model), |
|
|
outputs=[plot_output, amd_failed_tests_output, nvidia_failed_tests_output] |
|
|
).then( |
|
|
fn=lambda: [gr.update(visible=False), gr.update(visible=True)], |
|
|
outputs=[summary_display, detail_view] |
|
|
) |
|
|
|
|
|
|
|
|
btn.click( |
|
|
fn=lambda selected_model=model_name: show_time_series_model(selected_model), |
|
|
outputs=[time_series_plot_output] |
|
|
).then( |
|
|
fn=lambda: [gr.update(visible=False), gr.update(visible=True)], |
|
|
outputs=[time_series_summary_display, time_series_detail_view] |
|
|
) |
|
|
|
|
|
|
|
|
demo.load( |
|
|
fn=get_ci_links, |
|
|
outputs=[ci_links_display] |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch() |
|
|
|