Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,9 @@ import gradio as gr
|
|
2 |
import pandas as pd
|
3 |
from apscheduler.schedulers.background import BackgroundScheduler
|
4 |
# Removed Hugging Face Hub imports as they are not needed for the simplified leaderboard
|
5 |
-
|
|
|
|
|
6 |
from src.about import (
|
7 |
CITATION_BUTTON_LABEL,
|
8 |
CITATION_BUTTON_TEXT,
|
@@ -11,18 +13,28 @@ from src.about import (
|
|
11 |
LLM_BENCHMARKS_TEXT,
|
12 |
TITLE,
|
13 |
)
|
14 |
-
# Assuming this is correctly defined in your src.display.css_html_js module
|
15 |
from src.display.css_html_js import custom_css
|
16 |
-
# Assuming this is correctly defined in your src.envs module
|
17 |
from src.envs import REPO_ID # Keep if needed for restart_space or other functions
|
18 |
-
# Assuming this is correctly defined in your src.submission.submit module
|
19 |
from src.submission.submit import add_new_eval # Keep if using the submit tab
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# --- Elo Leaderboard Configuration ---
|
23 |
# Enhanced data with Rank (placeholder), Organizer, License, and URL
|
24 |
-
#
|
25 |
-
#
|
26 |
data = [
|
27 |
{'model_name': 'gpt-4o-mini', 'url': 'https://openai.com/index/hello-gpt-4o/', 'organizer': 'OpenAI', 'license': 'Proprietary', 'MLE-Lite_Elo': 753, 'Tabular_Elo': 839, 'NLP_Elo': 758, 'CV_Elo': 754, 'Overall': 778},
|
28 |
{'model_name': 'gpt-4o', 'url': 'https://openai.com/index/hello-gpt-4o/', 'organizer': 'OpenAI', 'license': 'Proprietary', 'MLE-Lite_Elo': 830, 'Tabular_Elo': 861, 'NLP_Elo': 903, 'CV_Elo': 761, 'Overall': 841},
|
@@ -63,7 +75,7 @@ def update_leaderboard(category):
|
|
63 |
score_column = category_to_column[DEFAULT_CATEGORY]
|
64 |
if score_column not in master_df.columns: # Check fallback column too
|
65 |
# Return empty df with correct columns if still invalid
|
66 |
-
#
|
67 |
return pd.DataFrame({
|
68 |
"Rank": [],
|
69 |
"Model": [],
|
@@ -94,12 +106,10 @@ def update_leaderboard(category):
|
|
94 |
# Rename the score column to 'Elo Score' for consistent display
|
95 |
df.rename(columns={score_column: 'Elo Score'}, inplace=True)
|
96 |
|
97 |
-
# --- FIX APPLIED HERE ---
|
98 |
# Select and reorder columns for final display using the ACTUAL column names in df
|
99 |
# Use lowercase 'organizer' and 'license' here because they haven't been renamed.
|
100 |
final_columns = ["Rank", "Model", "organizer", "license", "Elo Score"]
|
101 |
df = df[final_columns]
|
102 |
-
# -----------------------
|
103 |
|
104 |
# Note: The DataFrame returned now has columns:
|
105 |
# 'Rank', 'Model', 'organizer', 'license', 'Elo Score'
|
@@ -118,27 +128,28 @@ EVAL_TYPES = ["str", "str", "str", "str"] # Define for the dataframe types
|
|
118 |
|
119 |
# --- Keep restart function if relevant ---
|
120 |
def restart_space():
|
|
|
121 |
print(f"Attempting to restart space: {REPO_ID}")
|
122 |
-
# Replace with your actual space restart mechanism if needed
|
123 |
|
124 |
# --- Gradio App Definition ---
|
125 |
-
# Add
|
126 |
-
# Example CSS
|
127 |
# table { width: 100%; border-collapse: collapse; }
|
128 |
-
# th, td { padding: 8px 12px; border: 1px solid #ddd; text-align: left; }
|
129 |
-
# th { background-color: #f2f2f2; font-weight: bold; }
|
130 |
# tr:nth-child(even) { background-color: #f9f9f9; }
|
131 |
# tr:hover { background-color: #e9e9e9; }
|
132 |
-
# td a { color: #007bff; text-decoration: none; }
|
133 |
# td a:hover { text-decoration: underline; }
|
134 |
|
135 |
# Use a theme for better default styling
|
136 |
demo = gr.Blocks(css=custom_css, theme=gr.themes.Soft())
|
137 |
|
138 |
with demo:
|
139 |
-
# Use the TITLE variable imported
|
140 |
gr.HTML(TITLE)
|
141 |
-
# Use the INTRODUCTION_TEXT variable imported
|
142 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
143 |
|
144 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
@@ -157,14 +168,14 @@ with demo:
|
|
157 |
# Headers for DISPLAY remain capitalized
|
158 |
headers=["Rank", "Model", "Organizer", "License", "Elo Score"],
|
159 |
# Datatype maps to the final df columns: Rank, Model, organizer, license, Elo Score
|
160 |
-
# 'html' is used for the 'Model' column containing the <a> tag
|
161 |
datatype=["number", "html", "str", "str", "number"],
|
162 |
interactive=False,
|
163 |
-
|
|
|
164 |
row_count=(len(master_df), "fixed"),
|
165 |
col_count=(5, "fixed"),
|
166 |
wrap=True, # Allow text wrapping
|
167 |
-
elem_id="leaderboard-table" # CSS hook
|
168 |
)
|
169 |
# Link the radio button change to the update function
|
170 |
category_selector.change(
|
@@ -174,15 +185,15 @@ with demo:
|
|
174 |
)
|
175 |
|
176 |
with gr.TabItem("π About", elem_id="llm-benchmark-tab-about", id=1):
|
177 |
-
# Use the LLM_BENCHMARKS_TEXT variable imported
|
178 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
179 |
|
180 |
# --- Submit Tab (Commented out as in original request) ---
|
181 |
-
# Make sure EVALUATION_QUEUE_TEXT and add_new_eval are imported if uncommented
|
182 |
# with gr.TabItem("π Submit here! ", elem_id="llm-benchmark-tab-submit", id=2):
|
183 |
# with gr.Column():
|
184 |
# with gr.Row():
|
185 |
-
# gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text") # Requires import
|
186 |
# with gr.Column():
|
187 |
# with gr.Accordion(f"β
Finished Evaluations ({len(finished_eval_queue_df)})", open=False):
|
188 |
# finished_eval_table = gr.components.Dataframe(
|
@@ -200,19 +211,18 @@ with demo:
|
|
200 |
# gr.Markdown("# βοΈβ¨ Submit your model here!", elem_classes="markdown-text")
|
201 |
# with gr.Row():
|
202 |
# with gr.Column():
|
203 |
-
# model_name_textbox = gr.Textbox(label="Model name (on Hugging Face Hub)")
|
204 |
# revision_name_textbox = gr.Textbox(label="Revision / Commit Hash", placeholder="main")
|
205 |
-
#
|
206 |
-
# model_type = gr.Dropdown(choices=["Type A", "Type B", "Type C"], label="Model type", multiselect=False, value=None, interactive=True)
|
207 |
# with gr.Column():
|
208 |
# precision = gr.Dropdown(choices=["float16", "bfloat16", "float32", "int8", "auto"], label="Precision", multiselect=False, value="auto", interactive=True)
|
209 |
# weight_type = gr.Dropdown(choices=["Original", "Adapter", "Delta"], label="Weights type", multiselect=False, value="Original", interactive=True)
|
210 |
# base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
|
211 |
# submit_button = gr.Button("Submit Eval")
|
212 |
-
# submission_result = gr.Markdown()
|
213 |
-
# # Ensure add_new_eval is correctly imported and handles these inputs
|
214 |
# submit_button.click(
|
215 |
-
# add_new_eval, # Requires import
|
216 |
# [ model_name_textbox, base_model_name_textbox, revision_name_textbox, precision, weight_type, model_type, ],
|
217 |
# submission_result,
|
218 |
# )
|
@@ -220,11 +230,11 @@ with demo:
|
|
220 |
|
221 |
# --- Citation Row (at the bottom, outside Tabs) ---
|
222 |
with gr.Accordion("π Citation", open=False):
|
223 |
-
# Use the CITATION_BUTTON_TEXT and CITATION_BUTTON_LABEL variables imported
|
224 |
citation_button = gr.Textbox(
|
225 |
value=CITATION_BUTTON_TEXT,
|
226 |
label=CITATION_BUTTON_LABEL,
|
227 |
-
lines=10,
|
228 |
elem_id="citation-button",
|
229 |
show_copy_button=True,
|
230 |
)
|
@@ -238,5 +248,5 @@ with demo:
|
|
238 |
# Ensures the app launches only when the script is run directly
|
239 |
if __name__ == "__main__":
|
240 |
# Ensure you have installed necessary libraries: pip install gradio pandas apscheduler
|
241 |
-
# Make sure your src module files (about.py etc.) are
|
242 |
demo.launch()
|
|
|
2 |
import pandas as pd
|
3 |
from apscheduler.schedulers.background import BackgroundScheduler
|
4 |
# Removed Hugging Face Hub imports as they are not needed for the simplified leaderboard
|
5 |
+
|
6 |
+
# --- Make sure these imports work relative to your file structure ---
|
7 |
+
# Option 1: If src is a directory in the same folder as your script:
|
8 |
from src.about import (
|
9 |
CITATION_BUTTON_LABEL,
|
10 |
CITATION_BUTTON_TEXT,
|
|
|
13 |
LLM_BENCHMARKS_TEXT,
|
14 |
TITLE,
|
15 |
)
|
|
|
16 |
from src.display.css_html_js import custom_css
|
|
|
17 |
from src.envs import REPO_ID # Keep if needed for restart_space or other functions
|
|
|
18 |
from src.submission.submit import add_new_eval # Keep if using the submit tab
|
19 |
|
20 |
+
# Option 2: If you don't have these files, define placeholders (REMOVE THIS if using Option 1)
|
21 |
+
# print("Warning: Using placeholder values for src module imports.")
|
22 |
+
# CITATION_BUTTON_LABEL="Citation"
|
23 |
+
# CITATION_BUTTON_TEXT="Please cite us if you use this benchmark..."
|
24 |
+
# EVALUATION_QUEUE_TEXT="Current evaluation queue:"
|
25 |
+
# INTRODUCTION_TEXT="Welcome to the MLE-Dojo Benchmark Leaderboard."
|
26 |
+
# LLM_BENCHMARKS_TEXT="Information about the benchmarks..."
|
27 |
+
# TITLE="<h1>π MLE-Dojo Benchmark Leaderboard</h1>"
|
28 |
+
# custom_css=""
|
29 |
+
# REPO_ID="your/space-id" # Replace with actual ID if needed
|
30 |
+
# def add_new_eval(*args): return "Submission placeholder."
|
31 |
+
# --- End Placeholder Definitions ---
|
32 |
+
|
33 |
|
34 |
# --- Elo Leaderboard Configuration ---
|
35 |
# Enhanced data with Rank (placeholder), Organizer, License, and URL
|
36 |
+
# !!! IMPORTANT: Replace placeholder URLs with actual model/project pages. !!!
|
37 |
+
# Verify organizer and license information for accuracy.
|
38 |
data = [
|
39 |
{'model_name': 'gpt-4o-mini', 'url': 'https://openai.com/index/hello-gpt-4o/', 'organizer': 'OpenAI', 'license': 'Proprietary', 'MLE-Lite_Elo': 753, 'Tabular_Elo': 839, 'NLP_Elo': 758, 'CV_Elo': 754, 'Overall': 778},
|
40 |
{'model_name': 'gpt-4o', 'url': 'https://openai.com/index/hello-gpt-4o/', 'organizer': 'OpenAI', 'license': 'Proprietary', 'MLE-Lite_Elo': 830, 'Tabular_Elo': 861, 'NLP_Elo': 903, 'CV_Elo': 761, 'Overall': 841},
|
|
|
75 |
score_column = category_to_column[DEFAULT_CATEGORY]
|
76 |
if score_column not in master_df.columns: # Check fallback column too
|
77 |
# Return empty df with correct columns if still invalid
|
78 |
+
# Use lowercase keys here consistent with master_df for the empty case
|
79 |
return pd.DataFrame({
|
80 |
"Rank": [],
|
81 |
"Model": [],
|
|
|
106 |
# Rename the score column to 'Elo Score' for consistent display
|
107 |
df.rename(columns={score_column: 'Elo Score'}, inplace=True)
|
108 |
|
|
|
109 |
# Select and reorder columns for final display using the ACTUAL column names in df
|
110 |
# Use lowercase 'organizer' and 'license' here because they haven't been renamed.
|
111 |
final_columns = ["Rank", "Model", "organizer", "license", "Elo Score"]
|
112 |
df = df[final_columns]
|
|
|
113 |
|
114 |
# Note: The DataFrame returned now has columns:
|
115 |
# 'Rank', 'Model', 'organizer', 'license', 'Elo Score'
|
|
|
128 |
|
129 |
# --- Keep restart function if relevant ---
|
130 |
def restart_space():
|
131 |
+
# Make sure REPO_ID is correctly defined/imported if this function is used
|
132 |
print(f"Attempting to restart space: {REPO_ID}")
|
133 |
+
# Replace with your actual space restart mechanism if needed (e.g., HfApi().restart_space(REPO_ID))
|
134 |
|
135 |
# --- Gradio App Definition ---
|
136 |
+
# Add custom CSS rules here or ensure custom_css is imported correctly
|
137 |
+
# Example CSS rules you might want in your custom_css:
|
138 |
# table { width: 100%; border-collapse: collapse; }
|
139 |
+
# th, td { padding: 8px 12px; border: 1px solid #ddd; text-align: left; white-space: normal; } /* Allow wrapping */
|
140 |
+
# th { background-color: #f2f2f2; font-weight: bold; }
|
141 |
# tr:nth-child(even) { background-color: #f9f9f9; }
|
142 |
# tr:hover { background-color: #e9e9e9; }
|
143 |
+
# td a { color: #007bff; text-decoration: none; }
|
144 |
# td a:hover { text-decoration: underline; }
|
145 |
|
146 |
# Use a theme for better default styling
|
147 |
demo = gr.Blocks(css=custom_css, theme=gr.themes.Soft())
|
148 |
|
149 |
with demo:
|
150 |
+
# Use the TITLE variable imported or defined above
|
151 |
gr.HTML(TITLE)
|
152 |
+
# Use the INTRODUCTION_TEXT variable imported or defined above
|
153 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
154 |
|
155 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
|
|
168 |
# Headers for DISPLAY remain capitalized
|
169 |
headers=["Rank", "Model", "Organizer", "License", "Elo Score"],
|
170 |
# Datatype maps to the final df columns: Rank, Model, organizer, license, Elo Score
|
|
|
171 |
datatype=["number", "html", "str", "str", "number"],
|
172 |
interactive=False,
|
173 |
+
# --- FIX APPLIED: Removed unsupported 'height' argument ---
|
174 |
+
# row_count determines the number of rows to display
|
175 |
row_count=(len(master_df), "fixed"),
|
176 |
col_count=(5, "fixed"),
|
177 |
wrap=True, # Allow text wrapping
|
178 |
+
elem_id="leaderboard-table" # CSS hook for custom styling
|
179 |
)
|
180 |
# Link the radio button change to the update function
|
181 |
category_selector.change(
|
|
|
185 |
)
|
186 |
|
187 |
with gr.TabItem("π About", elem_id="llm-benchmark-tab-about", id=1):
|
188 |
+
# Use the LLM_BENCHMARKS_TEXT variable imported or defined above
|
189 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
190 |
|
191 |
# --- Submit Tab (Commented out as in original request) ---
|
192 |
+
# Make sure EVALUATION_QUEUE_TEXT and add_new_eval are imported/defined if uncommented
|
193 |
# with gr.TabItem("π Submit here! ", elem_id="llm-benchmark-tab-submit", id=2):
|
194 |
# with gr.Column():
|
195 |
# with gr.Row():
|
196 |
+
# gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text") # Requires import/definition
|
197 |
# with gr.Column():
|
198 |
# with gr.Accordion(f"β
Finished Evaluations ({len(finished_eval_queue_df)})", open=False):
|
199 |
# finished_eval_table = gr.components.Dataframe(
|
|
|
211 |
# gr.Markdown("# βοΈβ¨ Submit your model here!", elem_classes="markdown-text")
|
212 |
# with gr.Row():
|
213 |
# with gr.Column():
|
214 |
+
# model_name_textbox = gr.Textbox(label="Model name (on Hugging Face Hub)")
|
215 |
# revision_name_textbox = gr.Textbox(label="Revision / Commit Hash", placeholder="main")
|
216 |
+
# model_type = gr.Dropdown(choices=["Type A", "Type B", "Type C"], label="Model type", multiselect=False, value=None, interactive=True) # Example choices
|
|
|
217 |
# with gr.Column():
|
218 |
# precision = gr.Dropdown(choices=["float16", "bfloat16", "float32", "int8", "auto"], label="Precision", multiselect=False, value="auto", interactive=True)
|
219 |
# weight_type = gr.Dropdown(choices=["Original", "Adapter", "Delta"], label="Weights type", multiselect=False, value="Original", interactive=True)
|
220 |
# base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
|
221 |
# submit_button = gr.Button("Submit Eval")
|
222 |
+
# submission_result = gr.Markdown()
|
223 |
+
# # Ensure add_new_eval is correctly imported/defined and handles these inputs
|
224 |
# submit_button.click(
|
225 |
+
# add_new_eval, # Requires import/definition
|
226 |
# [ model_name_textbox, base_model_name_textbox, revision_name_textbox, precision, weight_type, model_type, ],
|
227 |
# submission_result,
|
228 |
# )
|
|
|
230 |
|
231 |
# --- Citation Row (at the bottom, outside Tabs) ---
|
232 |
with gr.Accordion("π Citation", open=False):
|
233 |
+
# Use the CITATION_BUTTON_TEXT and CITATION_BUTTON_LABEL variables imported or defined above
|
234 |
citation_button = gr.Textbox(
|
235 |
value=CITATION_BUTTON_TEXT,
|
236 |
label=CITATION_BUTTON_LABEL,
|
237 |
+
lines=10,
|
238 |
elem_id="citation-button",
|
239 |
show_copy_button=True,
|
240 |
)
|
|
|
248 |
# Ensures the app launches only when the script is run directly
|
249 |
if __name__ == "__main__":
|
250 |
# Ensure you have installed necessary libraries: pip install gradio pandas apscheduler
|
251 |
+
# Make sure your src module files (about.py etc.) are accessible OR use the placeholder definitions above.
|
252 |
demo.launch()
|