versae commited on
Commit
8e83d53
1 Parent(s): 92479fb

Add download option

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import json
2
  import math
3
  import subprocess
 
4
  from pathlib import Path
5
 
6
  import numpy as np
@@ -44,6 +45,13 @@ raw_data, original_df = get_leaderboard_df(DATA_PATH, COLS, BENCHMARK_COLS)
44
  leaderboard_df = original_df.copy()
45
 
46
 
 
 
 
 
 
 
 
47
  def plot_stats(data_path, plotting_library="plotly", columns=None, table=None):
48
  plots = {}
49
  files = Path(data_path).rglob("*.jsonl")
@@ -163,13 +171,14 @@ def update_table_and_plot(
163
  filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
164
  filtered_df = filter_queries(query, filtered_df)
165
  df = select_columns(filtered_df, columns)
 
166
  df = (df.style
167
  .format(precision=2, thousands=",", decimal=".")
168
  .highlight_max(props="background-color: lightgreen; color: black;", axis=0, subset=df.columns[1:])
169
  .highlight_between(props="color: red;", axis=0, subset=df.columns[1:], left=-np.inf, right=-np.inf)
170
  )
171
  fig = plot_stats(DATA_PATH, columns=columns, table=df)
172
- return df, fig
173
 
174
 
175
  def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
@@ -305,6 +314,8 @@ with demo:
305
  interactive=False,
306
  visible=True,
307
  )
 
 
308
  with gr.TabItem("📊 LLM Plots", elem_id="llm-benchmark-tab-plot", id=1):
309
  leaderboard_plot = gr.components.Plot(plot_stats(DATA_PATH))
310
 
@@ -329,6 +340,7 @@ with demo:
329
  [
330
  leaderboard_table,
331
  leaderboard_plot,
 
332
  ],
333
  )
334
  for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size,
@@ -347,6 +359,7 @@ with demo:
347
  [
348
  leaderboard_table,
349
  leaderboard_plot,
 
350
  ],
351
  queue=True,
352
  )
 
1
  import json
2
  import math
3
  import subprocess
4
+ import tempfile
5
  from pathlib import Path
6
 
7
  import numpy as np
 
45
  leaderboard_df = original_df.copy()
46
 
47
 
48
+
49
+ def export_csv(df):
50
+ csv_filename = Path(tempfile._get_default_tempdir()) / f"scandeval_leaderboard_{next(tempfile._get_candidate_names())}.csv"
51
+ df.to_csv(csv_filename)
52
+ return str(csv_filename)
53
+
54
+
55
  def plot_stats(data_path, plotting_library="plotly", columns=None, table=None):
56
  plots = {}
57
  files = Path(data_path).rglob("*.jsonl")
 
171
  filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
172
  filtered_df = filter_queries(query, filtered_df)
173
  df = select_columns(filtered_df, columns)
174
+ export_filename = export_csv(df)
175
  df = (df.style
176
  .format(precision=2, thousands=",", decimal=".")
177
  .highlight_max(props="background-color: lightgreen; color: black;", axis=0, subset=df.columns[1:])
178
  .highlight_between(props="color: red;", axis=0, subset=df.columns[1:], left=-np.inf, right=-np.inf)
179
  )
180
  fig = plot_stats(DATA_PATH, columns=columns, table=df)
181
+ return df, fig, export_filename
182
 
183
 
184
  def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
 
314
  interactive=False,
315
  visible=True,
316
  )
317
+ leaderboard_file = gr.File(interactive=False, value=export_csv(leaderboard_df[cols_to_show]), visible=True)
318
+
319
  with gr.TabItem("📊 LLM Plots", elem_id="llm-benchmark-tab-plot", id=1):
320
  leaderboard_plot = gr.components.Plot(plot_stats(DATA_PATH))
321
 
 
340
  [
341
  leaderboard_table,
342
  leaderboard_plot,
343
+ leaderboard_file,
344
  ],
345
  )
346
  for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size,
 
359
  [
360
  leaderboard_table,
361
  leaderboard_plot,
362
+ leaderboard_file,
363
  ],
364
  queue=True,
365
  )