BenchmarkBot commited on
Commit
fbc8c87
β€’
1 Parent(s): f2d0515

support querying the plot from url

Browse files
Files changed (3) hide show
  1. app.py +22 -13
  2. src/assets/css_html_js.py +1 -1
  3. src/utils.py +23 -5
app.py CHANGED
@@ -12,13 +12,14 @@ from src.assets.text_content import (
12
  CITATION_BUTTON_TEXT,
13
  )
14
  from src.utils import (
 
15
  restart_space,
16
  load_dataset_repo,
17
  make_clickable_model,
18
  make_clickable_score,
19
  num_to_str,
20
  )
21
- from src.assets.css_html_js import custom_css
22
 
23
 
24
  LLM_PERF_LEADERBOARD_REPO = "optimum/llm-perf-leaderboard"
@@ -294,18 +295,18 @@ with demo:
294
  show_label=False,
295
  )
296
 
297
- filter_button.click(
298
- filter_query,
299
- [
300
- search_bar,
301
- backend_checkboxes,
302
- datatype_checkboxes,
303
- optimizations_checkboxes,
304
- score_slider,
305
- memory_slider,
306
- ],
307
- [single_A100_leaderboard, single_A100_plotly],
308
- )
309
 
310
  with gr.Row():
311
  with gr.Accordion("πŸ“™ Citation", open=False):
@@ -315,6 +316,14 @@ with demo:
315
  elem_id="citation-button",
316
  ).style(show_copy_button=True)
317
 
 
 
 
 
 
 
 
 
318
 
319
  # Restart space every hour
320
  scheduler = BackgroundScheduler()
 
12
  CITATION_BUTTON_TEXT,
13
  )
14
  from src.utils import (
15
+ change_tab,
16
  restart_space,
17
  load_dataset_repo,
18
  make_clickable_model,
19
  make_clickable_score,
20
  num_to_str,
21
  )
22
+ from src.assets.css_html_js import custom_css, custom_js
23
 
24
 
25
  LLM_PERF_LEADERBOARD_REPO = "optimum/llm-perf-leaderboard"
 
295
  show_label=False,
296
  )
297
 
298
+ filter_button.click(
299
+ filter_query,
300
+ [
301
+ search_bar,
302
+ backend_checkboxes,
303
+ datatype_checkboxes,
304
+ optimizations_checkboxes,
305
+ score_slider,
306
+ memory_slider,
307
+ ],
308
+ [single_A100_leaderboard, single_A100_plotly],
309
+ )
310
 
311
  with gr.Row():
312
  with gr.Accordion("πŸ“™ Citation", open=False):
 
316
  elem_id="citation-button",
317
  ).style(show_copy_button=True)
318
 
319
+ dummy = gr.Textbox(visible=False)
320
+ demo.load(
321
+ change_tab,
322
+ dummy,
323
+ tabs,
324
+ _js=custom_js,
325
+ )
326
+
327
 
328
  # Restart space every hour
329
  scheduler = BackgroundScheduler()
src/assets/css_html_js.py CHANGED
@@ -41,7 +41,7 @@ table th:first-child {
41
  }
42
  """
43
 
44
- get_window_url_params = """
45
  function(url_params) {
46
  const params = new URLSearchParams(window.location.search);
47
  url_params = Object.fromEntries(params);
 
41
  }
42
  """
43
 
44
+ custom_js = """
45
  function(url_params) {
46
  const params = new URLSearchParams(window.location.search);
47
  url_params = Object.fromEntries(params);
src/utils.py CHANGED
@@ -1,10 +1,24 @@
1
  from huggingface_hub import HfApi, Repository
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
 
4
  def restart_space(LLM_PERF_LEADERBOARD_REPO, OPTIMUM_TOKEN):
5
- HfApi().restart_space(
6
- repo_id=LLM_PERF_LEADERBOARD_REPO, token=OPTIMUM_TOKEN
7
- )
8
 
9
 
10
  def load_dataset_repo(LLM_PERF_DATASET_REPO, OPTIMUM_TOKEN):
@@ -22,8 +36,12 @@ def load_dataset_repo(LLM_PERF_DATASET_REPO, OPTIMUM_TOKEN):
22
  return llm_perf_repo
23
 
24
 
25
- LLAMAS = ["huggingface/llama-7b", "huggingface/llama-13b",
26
- "huggingface/llama-30b", "huggingface/llama-65b"]
 
 
 
 
27
  KOALA_LINK = "https://huggingface.co/TheBloke/koala-13B-HF"
28
  VICUNA_LINK = "https://huggingface.co/lmsys/vicuna-13b-delta-v1.1"
29
  OASST_LINK = "https://huggingface.co/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5"
 
1
  from huggingface_hub import HfApi, Repository
2
+ import gradio as gr
3
+ import json
4
+
5
+
6
+ def change_tab(query_param):
7
+ query_param = query_param.replace("'", '"')
8
+ query_param = json.loads(query_param)
9
+
10
+ if (
11
+ isinstance(query_param, dict)
12
+ and "tab" in query_param
13
+ and query_param["tab"] == "plot"
14
+ ):
15
+ return gr.Tabs.update(selected=1)
16
+ else:
17
+ return gr.Tabs.update(selected=0)
18
 
19
 
20
  def restart_space(LLM_PERF_LEADERBOARD_REPO, OPTIMUM_TOKEN):
21
+ HfApi().restart_space(repo_id=LLM_PERF_LEADERBOARD_REPO, token=OPTIMUM_TOKEN)
 
 
22
 
23
 
24
  def load_dataset_repo(LLM_PERF_DATASET_REPO, OPTIMUM_TOKEN):
 
36
  return llm_perf_repo
37
 
38
 
39
+ LLAMAS = [
40
+ "huggingface/llama-7b",
41
+ "huggingface/llama-13b",
42
+ "huggingface/llama-30b",
43
+ "huggingface/llama-65b",
44
+ ]
45
  KOALA_LINK = "https://huggingface.co/TheBloke/koala-13B-HF"
46
  VICUNA_LINK = "https://huggingface.co/lmsys/vicuna-13b-delta-v1.1"
47
  OASST_LINK = "https://huggingface.co/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5"