albertvillanova HF staff commited on
Commit
30a0c61
·
verified ·
1 Parent(s): b6f3b94

Import contants as submodule

Browse files
Files changed (3) hide show
  1. app.py +5 -5
  2. src/details.py +4 -4
  3. src/results.py +5 -5
app.py CHANGED
@@ -2,7 +2,7 @@ from functools import partial
2
 
3
  import gradio as gr
4
 
5
- from src.constants import SUBTASKS, TASKS
6
  from src.details import update_subtasks_component, update_load_details_component, load_details_dataframes, \
7
  display_details, update_sample_idx_component, clear_details, update_task_description_component
8
  from src.results import update_load_results_component, \
@@ -34,7 +34,7 @@ with gr.Blocks(fill_height=True, fill_width=True) as demo:
34
  load_results_btn = gr.Button("Load", interactive=False)
35
  clear_results_btn = gr.Button("Clear")
36
  results_task = gr.Radio(
37
- ["All"] + list(TASKS.values()),
38
  label="Tasks",
39
  info="Evaluation tasks to be displayed",
40
  value="All",
@@ -50,7 +50,7 @@ with gr.Blocks(fill_height=True, fill_width=True) as demo:
50
  load_configs_btn = gr.Button("Load", interactive=False)
51
  clear_configs_btn = gr.Button("Clear")
52
  configs_task = gr.Radio(
53
- ["All"] + list(TASKS.values()),
54
  label="Tasks",
55
  info="Evaluation tasks to be displayed",
56
  value="All",
@@ -64,7 +64,7 @@ with gr.Blocks(fill_height=True, fill_width=True) as demo:
64
  configs = gr.HTML()
65
  with gr.Tab("Details"):
66
  details_task = gr.Radio(
67
- list(value for value in TASKS.values() if value[1] != "leaderboard_gpqa"),
68
  label="Tasks",
69
  info="Evaluation tasks to be loaded",
70
  interactive=True,
@@ -74,7 +74,7 @@ with gr.Blocks(fill_height=True, fill_width=True) as demo:
74
  lines=3,
75
  )
76
  subtask = gr.Radio(
77
- SUBTASKS.get(details_task.value),
78
  label="Subtasks",
79
  info="Evaluation subtasks to be loaded (choose one of the Tasks above)",
80
  )
 
2
 
3
  import gradio as gr
4
 
5
+ import src.constants as constants
6
  from src.details import update_subtasks_component, update_load_details_component, load_details_dataframes, \
7
  display_details, update_sample_idx_component, clear_details, update_task_description_component
8
  from src.results import update_load_results_component, \
 
34
  load_results_btn = gr.Button("Load", interactive=False)
35
  clear_results_btn = gr.Button("Clear")
36
  results_task = gr.Radio(
37
+ ["All"] + list(constants.TASKS.values()),
38
  label="Tasks",
39
  info="Evaluation tasks to be displayed",
40
  value="All",
 
50
  load_configs_btn = gr.Button("Load", interactive=False)
51
  clear_configs_btn = gr.Button("Clear")
52
  configs_task = gr.Radio(
53
+ ["All"] + list(constants.TASKS.values()),
54
  label="Tasks",
55
  info="Evaluation tasks to be displayed",
56
  value="All",
 
64
  configs = gr.HTML()
65
  with gr.Tab("Details"):
66
  details_task = gr.Radio(
67
+ list(value for value in constants.TASKS.values() if value[1] != "leaderboard_gpqa"),
68
  label="Tasks",
69
  info="Evaluation tasks to be loaded",
70
  interactive=True,
 
74
  lines=3,
75
  )
76
  subtask = gr.Radio(
77
+ # constants.SUBTASKS.get(details_task.value),
78
  label="Subtasks",
79
  info="Evaluation subtasks to be loaded (choose one of the Tasks above)",
80
  )
src/details.py CHANGED
@@ -4,13 +4,13 @@ import gradio as gr
4
  import pandas as pd
5
  from huggingface_hub import HfFileSystem
6
 
7
- from src.constants import SUBTASKS, DETAILS_DATASET_ID, DETAILS_FILENAME, TASK_DESCRIPTIONS
8
  from src.hub import load_details_file
9
 
10
 
11
  def update_task_description_component(task):
12
  return gr.Textbox(
13
- TASK_DESCRIPTIONS.get(task),
14
  label="Task Description",
15
  lines=3,
16
  visible=True,
@@ -19,7 +19,7 @@ def update_task_description_component(task):
19
 
20
  def update_subtasks_component(task):
21
  return gr.Radio(
22
- SUBTASKS.get(task),
23
  info="Evaluation subtasks to be loaded",
24
  value=None,
25
  )
@@ -38,7 +38,7 @@ async def load_details_dataframe(model_id, subtask):
38
  return
39
  model_name_sanitized = model_id.replace("/", "__")
40
  paths = fs.glob(
41
- f"{DETAILS_DATASET_ID}/**/{DETAILS_FILENAME}".format(
42
  model_name_sanitized=model_name_sanitized, subtask=subtask
43
  )
44
  )
 
4
  import pandas as pd
5
  from huggingface_hub import HfFileSystem
6
 
7
+ import src.constants as constants
8
  from src.hub import load_details_file
9
 
10
 
11
  def update_task_description_component(task):
12
  return gr.Textbox(
13
+ constants.TASK_DESCRIPTIONS.get(task),
14
  label="Task Description",
15
  lines=3,
16
  visible=True,
 
19
 
20
  def update_subtasks_component(task):
21
  return gr.Radio(
22
+ constants.SUBTASKS.get(task),
23
  info="Evaluation subtasks to be loaded",
24
  value=None,
25
  )
 
38
  return
39
  model_name_sanitized = model_id.replace("/", "__")
40
  paths = fs.glob(
41
+ f"{constants.DETAILS_DATASET_ID}/**/{constants.DETAILS_FILENAME}".format(
42
  model_name_sanitized=model_name_sanitized, subtask=subtask
43
  )
44
  )
src/results.py CHANGED
@@ -5,13 +5,13 @@ import numpy as np
5
  import pandas as pd
6
  from huggingface_hub import HfFileSystem
7
 
8
- from src.constants import RESULTS_DATASET_ID, TASKS
9
  from src.hub import load_file
10
 
11
 
12
  def fetch_result_paths():
13
  fs = HfFileSystem()
14
- paths = fs.glob(f"{RESULTS_DATASET_ID}/**/**/*.json")
15
  return paths
16
 
17
 
@@ -20,7 +20,7 @@ def sort_result_paths_per_model(paths):
20
 
21
  d = defaultdict(list)
22
  for path in paths:
23
- model_id, _ = path[len(RESULTS_DATASET_ID) + 1:].rsplit("/", 1)
24
  d[model_id].append(path)
25
  return {model_id: sorted(paths) for model_id, paths in d.items()}
26
 
@@ -82,7 +82,7 @@ def display_tab(tab, df, task):
82
  def update_tasks_component():
83
  return (
84
  gr.Radio(
85
- ["All"] + list(TASKS.values()),
86
  label="Tasks",
87
  info="Evaluation tasks to be displayed",
88
  value="All",
@@ -98,7 +98,7 @@ def clear_results():
98
  *(gr.Button("Load", interactive=False), ) * 2,
99
  *(
100
  gr.Radio(
101
- ["All"] + list(TASKS.values()),
102
  label="Tasks",
103
  info="Evaluation tasks to be displayed",
104
  value="All",
 
5
  import pandas as pd
6
  from huggingface_hub import HfFileSystem
7
 
8
+ import src.constants as constants
9
  from src.hub import load_file
10
 
11
 
12
  def fetch_result_paths():
13
  fs = HfFileSystem()
14
+ paths = fs.glob(f"{constants.RESULTS_DATASET_ID}/**/**/*.json")
15
  return paths
16
 
17
 
 
20
 
21
  d = defaultdict(list)
22
  for path in paths:
23
+ model_id, _ = path[len(constants.RESULTS_DATASET_ID) + 1:].rsplit("/", 1)
24
  d[model_id].append(path)
25
  return {model_id: sorted(paths) for model_id, paths in d.items()}
26
 
 
82
  def update_tasks_component():
83
  return (
84
  gr.Radio(
85
+ ["All"] + list(constants.TASKS.values()),
86
  label="Tasks",
87
  info="Evaluation tasks to be displayed",
88
  value="All",
 
98
  *(gr.Button("Load", interactive=False), ) * 2,
99
  *(
100
  gr.Radio(
101
+ ["All"] + list(constants.TASKS.values()),
102
  label="Tasks",
103
  info="Evaluation tasks to be displayed",
104
  value="All",