gremlin97 commited on
Commit
d9fe250
·
1 Parent(s): 37754c7

Fix First Author links to render as clickable HTML and add author fields to submission form

Browse files
Files changed (1) hide show
  1. app.py +81 -33
app.py CHANGED
@@ -40,6 +40,39 @@ def filter_and_search(df, search, datasets, models, organizations, columns):
40
  return filtered
41
 
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  def build_tab(df, name):
44
  """Build a leaderboard tab from a DataFrame"""
45
  if df.empty:
@@ -61,10 +94,7 @@ def build_tab(df, name):
61
  first_author = model_org_data["First Author"].values[0]
62
  author_link = model_org_data["Author Link"].values[0]
63
 
64
- # Create HTML link for First Author
65
- author_html = f'<a href="{author_link}" target="_blank">{first_author}</a>'
66
-
67
- row = {"Model": model, "Organization": org, "First Author": author_html}
68
  for dataset in datasets:
69
  dataset_data = model_org_data[model_org_data["Dataset"] == dataset]
70
  if not dataset_data.empty:
@@ -87,6 +117,9 @@ def build_tab(df, name):
87
 
88
  all_cols = ["Model", "Organization", "First Author"] + metric_combo_cols
89
 
 
 
 
90
  with gr.TabItem(name, elem_id="llm-benchmark-tab-table"):
91
  with gr.Row():
92
  with gr.Column(scale=4):
@@ -97,18 +130,15 @@ def build_tab(df, name):
97
  )
98
 
99
  col_selector = gr.CheckboxGroup(
100
- choices=all_cols,
101
- value=all_cols,
102
  label="Select Columns to Display:",
103
  elem_classes="column-select"
104
  )
105
 
106
- table = gr.Dataframe(
107
- value=pivoted_df,
108
- wrap=True,
109
- interactive=False,
110
- elem_id="leaderboard-table",
111
- datatype=["str"] * len(pivoted_df.columns)
112
  )
113
 
114
  with gr.Column(scale=1):
@@ -141,10 +171,13 @@ def build_tab(df, name):
141
  filtered = filtered[filtered["Organization"].isin(org)]
142
 
143
  if cols:
 
144
  display_cols = [col for col in cols if col in filtered.columns]
 
 
145
  filtered = filtered[display_cols]
146
 
147
- return filtered
148
 
149
  search_bar.change(update, [search_bar, model_filter, org_filter, col_selector], table)
150
  model_filter.change(update, [search_bar, model_filter, org_filter, col_selector], table)
@@ -161,29 +194,37 @@ custom_css = """
161
  margin-top: 15px;
162
  max-height: 600px;
163
  overflow-y: auto;
 
164
  }
165
 
166
- #leaderboard-table table {
167
  width: 100%;
 
168
  table-layout: auto;
169
  }
170
 
171
- #leaderboard-table thead th {
172
  font-weight: bold;
173
  text-align: center;
174
  padding: 12px 8px;
175
  white-space: normal;
176
  word-wrap: break-word;
 
177
  }
178
 
179
- #leaderboard-table tbody td {
180
  text-align: center;
181
  padding: 10px 8px;
182
  white-space: nowrap;
 
183
  }
184
 
185
- #leaderboard-table tbody td:first-child,
186
- #leaderboard-table thead th:first-child {
 
 
 
 
187
  text-align: left;
188
  font-weight: 500;
189
  min-width: 120px;
@@ -191,14 +232,14 @@ custom_css = """
191
  white-space: nowrap;
192
  }
193
 
194
- #leaderboard-table tbody td:nth-child(2),
195
- #leaderboard-table thead th:nth-child(2) {
196
  text-align: left;
197
  min-width: 100px;
198
  }
199
 
200
- #leaderboard-table tbody td:nth-child(3),
201
- #leaderboard-table thead th:nth-child(3) {
202
  text-align: left;
203
  min-width: 120px;
204
  }
@@ -211,12 +252,7 @@ custom_css = """
211
 
212
  #leaderboard-table a:hover {
213
  text-decoration: underline;
214
- }
215
-
216
- /* Remove any interactive elements from table */
217
- #leaderboard-table input[type="range"],
218
- #leaderboard-table .slider {
219
- display: none !important;
220
  }
221
 
222
  #search-bar {
@@ -318,6 +354,16 @@ with demo:
318
  )
319
 
320
  with gr.Column():
 
 
 
 
 
 
 
 
 
 
321
  submit_metrics = gr.Textbox(
322
  label="Metrics (JSON format)",
323
  placeholder='{"Accuracy": 95.8, "F1-Score": 94.9}',
@@ -358,9 +404,9 @@ with demo:
358
  We'll review your submission and add it to the leaderboard if approved.
359
  """)
360
 
361
- def generate_submission_text(task, model, org, dataset, metrics, paper, code, email, notes):
362
- if not all([task, model, org, dataset, metrics, email]):
363
- return "❌ Error: Please fill in all required fields (Task Type, Model Name, Organization, Dataset, Metrics, Contact Email)"
364
 
365
  submission_text = f"""## New Model Submission
366
 
@@ -368,6 +414,8 @@ with demo:
368
  **Model Name:** {model}
369
  **Organization:** {org}
370
  **Dataset:** {dataset}
 
 
371
 
372
  ### Metrics
373
  ```json
@@ -391,8 +439,8 @@ with demo:
391
 
392
  generate_btn.click(
393
  generate_submission_text,
394
- inputs=[submit_task, submit_model, submit_org, submit_dataset, submit_metrics,
395
- submit_paper, submit_code, submit_email, submit_notes],
396
  outputs=submission_output
397
  )
398
 
 
40
  return filtered
41
 
42
 
43
+ def df_to_html(df):
44
+ """Convert DataFrame to HTML table with clickable links in First Author column"""
45
+ if df.empty:
46
+ return "<p>No data to display</p>"
47
+
48
+ html = '<table class="dataframe">\n<thead>\n<tr>'
49
+
50
+ # Add headers
51
+ for col in df.columns:
52
+ if col != "Author Link": # Skip Author Link column in display
53
+ html += f'<th>{col}</th>'
54
+ html += '</tr>\n</thead>\n<tbody>\n'
55
+
56
+ # Add rows
57
+ for _, row in df.iterrows():
58
+ html += '<tr>'
59
+ for col in df.columns:
60
+ if col != "Author Link": # Skip Author Link column in display
61
+ if col == "First Author" and "Author Link" in df.columns:
62
+ # Create clickable link for First Author
63
+ author_link = row["Author Link"]
64
+ if pd.notna(author_link) and author_link.strip():
65
+ html += f'<td><a href="{author_link}" target="_blank">{row[col]}</a></td>'
66
+ else:
67
+ html += f'<td>{row[col]}</td>'
68
+ else:
69
+ html += f'<td>{row[col]}</td>'
70
+ html += '</tr>\n'
71
+
72
+ html += '</tbody>\n</table>'
73
+ return html
74
+
75
+
76
  def build_tab(df, name):
77
  """Build a leaderboard tab from a DataFrame"""
78
  if df.empty:
 
94
  first_author = model_org_data["First Author"].values[0]
95
  author_link = model_org_data["Author Link"].values[0]
96
 
97
+ row = {"Model": model, "Organization": org, "First Author": first_author, "Author Link": author_link}
 
 
 
98
  for dataset in datasets:
99
  dataset_data = model_org_data[model_org_data["Dataset"] == dataset]
100
  if not dataset_data.empty:
 
117
 
118
  all_cols = ["Model", "Organization", "First Author"] + metric_combo_cols
119
 
120
+ # Keep Author Link for internal use but don't show in column selector
121
+ display_cols_for_selector = [col for col in all_cols if col != "Author Link"]
122
+
123
  with gr.TabItem(name, elem_id="llm-benchmark-tab-table"):
124
  with gr.Row():
125
  with gr.Column(scale=4):
 
130
  )
131
 
132
  col_selector = gr.CheckboxGroup(
133
+ choices=display_cols_for_selector,
134
+ value=display_cols_for_selector,
135
  label="Select Columns to Display:",
136
  elem_classes="column-select"
137
  )
138
 
139
+ table = gr.HTML(
140
+ value=df_to_html(pivoted_df),
141
+ elem_id="leaderboard-table"
 
 
 
142
  )
143
 
144
  with gr.Column(scale=1):
 
171
  filtered = filtered[filtered["Organization"].isin(org)]
172
 
173
  if cols:
174
+ # Always include "Author Link" for rendering, even if not in selection
175
  display_cols = [col for col in cols if col in filtered.columns]
176
+ if "First Author" in display_cols and "Author Link" in filtered.columns:
177
+ display_cols.append("Author Link")
178
  filtered = filtered[display_cols]
179
 
180
+ return df_to_html(filtered)
181
 
182
  search_bar.change(update, [search_bar, model_filter, org_filter, col_selector], table)
183
  model_filter.change(update, [search_bar, model_filter, org_filter, col_selector], table)
 
194
  margin-top: 15px;
195
  max-height: 600px;
196
  overflow-y: auto;
197
+ overflow-x: auto;
198
  }
199
 
200
+ #leaderboard-table table.dataframe {
201
  width: 100%;
202
+ border-collapse: collapse;
203
  table-layout: auto;
204
  }
205
 
206
+ #leaderboard-table table.dataframe thead th {
207
  font-weight: bold;
208
  text-align: center;
209
  padding: 12px 8px;
210
  white-space: normal;
211
  word-wrap: break-word;
212
+ border-bottom: 2px solid #ddd;
213
  }
214
 
215
+ #leaderboard-table table.dataframe tbody td {
216
  text-align: center;
217
  padding: 10px 8px;
218
  white-space: nowrap;
219
+ border-bottom: 1px solid #eee;
220
  }
221
 
222
+ #leaderboard-table table.dataframe tbody tr:hover {
223
+ background-color: #f5f5f5;
224
+ }
225
+
226
+ #leaderboard-table table.dataframe tbody td:first-child,
227
+ #leaderboard-table table.dataframe thead th:first-child {
228
  text-align: left;
229
  font-weight: 500;
230
  min-width: 120px;
 
232
  white-space: nowrap;
233
  }
234
 
235
+ #leaderboard-table table.dataframe tbody td:nth-child(2),
236
+ #leaderboard-table table.dataframe thead th:nth-child(2) {
237
  text-align: left;
238
  min-width: 100px;
239
  }
240
 
241
+ #leaderboard-table table.dataframe tbody td:nth-child(3),
242
+ #leaderboard-table table.dataframe thead th:nth-child(3) {
243
  text-align: left;
244
  min-width: 120px;
245
  }
 
252
 
253
  #leaderboard-table a:hover {
254
  text-decoration: underline;
255
+ color: #004499;
 
 
 
 
 
256
  }
257
 
258
  #search-bar {
 
354
  )
355
 
356
  with gr.Column():
357
+ submit_first_author = gr.Textbox(
358
+ label="First Author",
359
+ placeholder="e.g., K. He",
360
+ info="Name of the first author"
361
+ )
362
+ submit_author_link = gr.Textbox(
363
+ label="Author Page Link (Optional)",
364
+ placeholder="https://scholar.google.com/... or https://github.com/...",
365
+ info="Link to author's Google Scholar, GitHub, or personal page"
366
+ )
367
  submit_metrics = gr.Textbox(
368
  label="Metrics (JSON format)",
369
  placeholder='{"Accuracy": 95.8, "F1-Score": 94.9}',
 
404
  We'll review your submission and add it to the leaderboard if approved.
405
  """)
406
 
407
+ def generate_submission_text(task, model, org, dataset, first_author, author_link, metrics, paper, code, email, notes):
408
+ if not all([task, model, org, dataset, first_author, metrics, email]):
409
+ return "❌ Error: Please fill in all required fields (Task Type, Model Name, Organization, Dataset, First Author, Metrics, Contact Email)"
410
 
411
  submission_text = f"""## New Model Submission
412
 
 
414
  **Model Name:** {model}
415
  **Organization:** {org}
416
  **Dataset:** {dataset}
417
+ **First Author:** {first_author}
418
+ **Author Page Link:** {author_link if author_link else "N/A"}
419
 
420
  ### Metrics
421
  ```json
 
439
 
440
  generate_btn.click(
441
  generate_submission_text,
442
+ inputs=[submit_task, submit_model, submit_org, submit_dataset, submit_first_author,
443
+ submit_author_link, submit_metrics, submit_paper, submit_code, submit_email, submit_notes],
444
  outputs=submission_output
445
  )
446