Jerrycool commited on
Commit
306046a
·
verified ·
1 Parent(s): c13e962

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -41
app.py CHANGED
@@ -3,20 +3,17 @@ import pandas as pd
3
  from apscheduler.schedulers.background import BackgroundScheduler
4
 
5
  """
6
- MLE‑Dojo Benchmark Leaderboard — Dark Elegance Edition
7
- =====================================================
8
- A refined, low‑glare UI with larger table text, richer surface layering, and a
9
- subtle neon accent that pops on dark slate backgrounds.
10
-
11
- HOW TO
12
- ------
13
- * `pip install gradio pandas apscheduler`
14
- * `python mle_dojo_leaderboard_app.py`
15
- * Replace placeholder copy (TITLE …) with your own or keep the try/except.
16
  """
17
 
18
  # ---------------------------------------------------------------------------
19
- # Import app copy (falls back to placeholders if src/ is absent)
20
  # ---------------------------------------------------------------------------
21
  try:
22
  from src.about import (
@@ -26,15 +23,14 @@ try:
26
  LLM_BENCHMARKS_TEXT,
27
  TITLE,
28
  )
29
- from src.display.css_html_js import custom_css # optional extra rules
30
  from src.envs import REPO_ID
31
  from src.submission.submit import add_new_eval
32
  except ImportError:
33
- # ── Placeholders ───────────────────────────────────────────────────────────
34
  CITATION_BUTTON_LABEL = "Citation"
35
  CITATION_BUTTON_TEXT = "Please cite us if you use this benchmark…"
36
- INTRODUCTION_TEXT = "Welcome to the **MLE‑Dojo Benchmark Leaderboard** — compare LLM agents across realistic ML engineering tasks."
37
- LLM_BENCHMARKS_TEXT = "Further details about tasks, metrics and evaluation pipelines."
38
  TITLE = (
39
  "<h1 class='hero-title gradient-text'>🏆 MLE‑Dojo Benchmark Leaderboard</h1>"
40
  "<p class='subtitle'>Interactive, reproducible &amp; community‑driven ML‑agent benchmarking</p>"
@@ -72,6 +68,8 @@ CATEGORY_MAP = {
72
  "CV": "CV_Elo",
73
  }
74
 
 
 
75
  def update_leaderboard(category: str, ascending: bool):
76
  col = CATEGORY_MAP.get(category, CATEGORY_MAP[DEFAULT_CATEGORY])
77
  df = (
@@ -79,49 +77,45 @@ def update_leaderboard(category: str, ascending: bool):
79
  .sort_values(by=col, ascending=ascending)
80
  .reset_index(drop=True)
81
  )
 
82
  df.insert(0, "Rank", df.index + 1)
 
83
  df["Model"] = df.apply(lambda r: f"<a href='{r.url}' target='_blank'>{r.model_name}</a>", axis=1)
 
84
  df.rename(columns={"organizer": "Organizer", "license": "License", col: "Elo Score"}, inplace=True)
85
  return df[["Rank", "Model", "Organizer", "License", "Elo Score"]]
86
 
87
  # ---------------------------------------------------------------------------
88
- # Dark‑mode CSS & Larger Table Fonts
89
  # ---------------------------------------------------------------------------
90
  custom_css += """
91
- /* ————— Core Typography ————— */
92
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
93
- html,body {
94
- font-family: 'Inter', sans-serif !important;
95
- font-size: 18px !important;
96
- line-height: 1.55;
97
- color: #e2e8f0;
98
- background:#0f172a;
99
- }
100
 
101
- /* Accent gradient for titles */
102
- .gradient-text {
103
- background:linear-gradient(90deg,#6366f1 0%,#06b6d4 100%);
104
- -webkit-background-clip:text; -webkit-text-fill-color:transparent;
105
- }
106
 
107
- /* Markdown headings */
108
- .markdown-text h2{font-weight:600;margin-top:1.3em;color:#f1f5f9;}
 
109
 
110
- /* Radio & checkbox containers */
111
- .gr-radio, .gr-checkbox{background:#1e293b;border-radius:8px;padding:6px 12px;box-shadow:0 1px 3px rgba(0,0,0,.4);}
112
- .gr-radio input:checked+label, .gr-checkbox input:checked+label{color:#38bdf8;}
113
 
114
- /* Table Styling */
115
  #leaderboard-table table{width:100%;border-collapse:collapse;background:#1e293b;border-radius:8px;overflow:hidden;}
116
- #leaderboard-table th{background:#334155;font-size:0.9rem;font-weight:600;padding:0.7em;color:#f1f5f9;text-transform:uppercase;letter-spacing:.04em;}
117
- #leaderboard-table td{padding:0.6em;font-size:1.05rem;border-top:1px solid #334155;}
118
  #leaderboard-table tr:nth-child(even){background:#1c2431;}
119
  #leaderboard-table tr:hover{background:#475569;}
120
 
 
 
 
 
121
  /* Links */
122
  a{color:#38bdf8;} a:hover{text-decoration:underline;}
123
 
124
- /* Accordion */
125
  .gr-accordion .label{font-weight:600;font-size:1rem;color:#f1f5f9;}
126
  """
127
 
@@ -136,18 +130,20 @@ with app:
136
 
137
  with gr.Tabs():
138
  with gr.TabItem("🏅 Leaderboard"):
139
- gr.Markdown("### Model Elo Rankings by Category", elem_classes="markdown-text")
140
  with gr.Row():
141
  category_radio = gr.Radio(CATEGORIES, value=DEFAULT_CATEGORY, label="Category")
142
- asc_check = gr.Checkbox(label="⬆️ Ascending order", value=False)
 
143
  board = gr.Dataframe(
144
  value=update_leaderboard(DEFAULT_CATEGORY, False),
145
  headers=["Rank", "Model", "Organizer", "License", "Elo Score"],
146
- datatype=["number", "html", "str", "str", "number"],
147
  row_count=(len(master_df), "fixed"),
148
  col_count=(5, "fixed"),
149
  interactive=False,
150
  elem_id="leaderboard-table",
 
151
  )
152
  category_radio.change(update_leaderboard, [category_radio, asc_check], board)
153
  asc_check.change(update_leaderboard, [category_radio, asc_check], board)
 
3
  from apscheduler.schedulers.background import BackgroundScheduler
4
 
5
  """
6
+ MLE‑Dojo Benchmark Leaderboard — Dark Elegance v2
7
+ ================================================
8
+ Upgrades:
9
+ * richer heading with emoji icon
10
+ * larger fonts throughout
11
+ * medal icons for top‑3 ranks
12
+ * scrollable leaderboard (fixed height)
 
 
 
13
  """
14
 
15
  # ---------------------------------------------------------------------------
16
+ # Import app copy (fallback placeholders if src/ missing)
17
  # ---------------------------------------------------------------------------
18
  try:
19
  from src.about import (
 
23
  LLM_BENCHMARKS_TEXT,
24
  TITLE,
25
  )
26
+ from src.display.css_html_js import custom_css # may exist
27
  from src.envs import REPO_ID
28
  from src.submission.submit import add_new_eval
29
  except ImportError:
 
30
  CITATION_BUTTON_LABEL = "Citation"
31
  CITATION_BUTTON_TEXT = "Please cite us if you use this benchmark…"
32
+ INTRODUCTION_TEXT = "Welcome to the **MLE‑Dojo Benchmark Leaderboard** — compare LLM agents across realistic MLengineering tasks."
33
+ LLM_BENCHMARKS_TEXT = "Further details about tasks, metrics, and evaluation pipelines."
34
  TITLE = (
35
  "<h1 class='hero-title gradient-text'>🏆 MLE‑Dojo Benchmark Leaderboard</h1>"
36
  "<p class='subtitle'>Interactive, reproducible &amp; community‑driven ML‑agent benchmarking</p>"
 
68
  "CV": "CV_Elo",
69
  }
70
 
71
+ MEDALS = {1: "🥇", 2: "🥈", 3: "🥉"}
72
+
73
  def update_leaderboard(category: str, ascending: bool):
74
  col = CATEGORY_MAP.get(category, CATEGORY_MAP[DEFAULT_CATEGORY])
75
  df = (
 
77
  .sort_values(by=col, ascending=ascending)
78
  .reset_index(drop=True)
79
  )
80
+
81
  df.insert(0, "Rank", df.index + 1)
82
+ df["Rank"] = df["Rank"].apply(lambda r: MEDALS.get(r, str(r)))
83
  df["Model"] = df.apply(lambda r: f"<a href='{r.url}' target='_blank'>{r.model_name}</a>", axis=1)
84
+
85
  df.rename(columns={"organizer": "Organizer", "license": "License", col: "Elo Score"}, inplace=True)
86
  return df[["Rank", "Model", "Organizer", "License", "Elo Score"]]
87
 
88
  # ---------------------------------------------------------------------------
89
+ # CSS (dark + bigger fonts + heading icon)
90
  # ---------------------------------------------------------------------------
91
  custom_css += """
 
92
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
93
+ html,body{font-family:'Inter',sans-serif!important;font-size:18px!important;line-height:1.6;color:#e2e8f0;background:#0f172a;}
 
 
 
 
 
 
94
 
95
+ .gradient-text{background:linear-gradient(90deg,#6366f1 0%,#06b6d4 100%);-webkit-background-clip:text;-webkit-text-fill-color:transparent;}
 
 
 
 
96
 
97
+ /* Section title */
98
+ .section-title{font-size:1.7rem;font-weight:700;color:#f1f5f9;display:flex;align-items:center;gap:.4em;margin:1.1em 0 .8em;}
99
+ .section-title .icon{font-size:1.4em;}
100
 
101
+ /* Radio & checkbox */
102
+ .gr-radio,.gr-checkbox{background:#1e293b;border-radius:8px;padding:6px 12px;box-shadow:0 1px 3px rgba(0,0,0,.4);}
103
+ .gr-radio input:checked+label,.gr-checkbox input:checked+label{color:#38bdf8;}
104
 
105
+ /* Leaderboard table */
106
  #leaderboard-table table{width:100%;border-collapse:collapse;background:#1e293b;border-radius:8px;overflow:hidden;}
107
+ #leaderboard-table th{background:#334155;font-size:1rem;font-weight:600;padding:.8em;color:#f1f5f9;text-transform:uppercase;letter-spacing:.04em;}
108
+ #leaderboard-table td{padding:.7em;font-size:1.15rem;border-top:1px solid #334155;}
109
  #leaderboard-table tr:nth-child(even){background:#1c2431;}
110
  #leaderboard-table tr:hover{background:#475569;}
111
 
112
+ /* Scrollbar styling */
113
+ #leaderboard-table tbody{display:block;max-height:520px;overflow-y:auto;}
114
+ #leaderboard-table thead, #leaderboard-table tbody tr{display:table;width:100%;table-layout:fixed;}
115
+
116
  /* Links */
117
  a{color:#38bdf8;} a:hover{text-decoration:underline;}
118
 
 
119
  .gr-accordion .label{font-weight:600;font-size:1rem;color:#f1f5f9;}
120
  """
121
 
 
130
 
131
  with gr.Tabs():
132
  with gr.TabItem("🏅 Leaderboard"):
133
+ gr.HTML("<h3 class='section-title'><span class='icon'>📊</span>Model Elo Rankings by Category</h3>")
134
  with gr.Row():
135
  category_radio = gr.Radio(CATEGORIES, value=DEFAULT_CATEGORY, label="Category")
136
+ asc_check = gr.Checkbox(label="⬆️ Asc. order", value=False)
137
+
138
  board = gr.Dataframe(
139
  value=update_leaderboard(DEFAULT_CATEGORY, False),
140
  headers=["Rank", "Model", "Organizer", "License", "Elo Score"],
141
+ datatype=["html", "html", "str", "str", "number"],
142
  row_count=(len(master_df), "fixed"),
143
  col_count=(5, "fixed"),
144
  interactive=False,
145
  elem_id="leaderboard-table",
146
+ height=560,
147
  )
148
  category_radio.change(update_leaderboard, [category_radio, asc_check], board)
149
  asc_check.change(update_leaderboard, [category_radio, asc_check], board)