jenyag commited on
Commit
f3c59e4
β€’
1 Parent(s): 9ea9349

Create Dataset filtering for code completion

Browse files
Files changed (1) hide show
  1. app.py +40 -8
app.py CHANGED
@@ -44,6 +44,19 @@ def get_leaderboard_for_task(task_pretty: str) -> gr.components.Dataframe:
44
  )
45
 
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  with gr.Blocks() as demo:
48
  # intro
49
  gr.HTML(INTRODUCTION_TITLE)
@@ -58,15 +71,34 @@ with gr.Blocks() as demo:
58
  with gr.Row():
59
  gr.Markdown(TASKS_DESCRIPTIONS[TASKS_PRETTY_REVERSE[task_pretty]])
60
 
61
- leaderboard_table = get_leaderboard_for_task(task_pretty)
62
- task_input = gr.Text(value=task_pretty, visible=False)
 
 
 
63
 
64
- refresh_button = gr.Button("πŸ”„ Refresh", variant="secondary")
65
- refresh_button.click(
66
- fn=get_leaderboard_for_task,
67
- inputs=task_input,
68
- outputs=leaderboard_table,
69
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  # submission
72
  gr.HTML(SUBMISSION_TITLE)
 
44
  )
45
 
46
 
47
+ def get_leaderboard_for_completion_task(dataset_name: str | None):
48
+ df = get_results_for_task(TASKS_PRETTY['project_code_completion'])
49
+ code_completion_dataset_names = df['Dataset'].unique()
50
+ if dataset_name is None:
51
+ dataset_name = code_completion_dataset_names[0]
52
+ filtered_df = df[df['Dataset']==dataset_name]
53
+ return gr.components.Dataframe(
54
+ value=filtered_df,
55
+ interactive=False,
56
+ datatype=get_types_per_task('project_code_completion'),
57
+ )
58
+
59
+
60
  with gr.Blocks() as demo:
61
  # intro
62
  gr.HTML(INTRODUCTION_TITLE)
 
71
  with gr.Row():
72
  gr.Markdown(TASKS_DESCRIPTIONS[TASKS_PRETTY_REVERSE[task_pretty]])
73
 
74
+ if task_pretty == TASKS_PRETTY['project_code_completion']:
75
+ leaderboard_table = get_leaderboard_for_completion_task(dataset_name=None)
76
+ code_completion_dataset_names = get_results_for_task(TASKS_PRETTY['project_code_completion'])['Dataset'].unique().tolist()
77
+ else:
78
+ leaderboard_table = get_leaderboard_for_task(task_pretty)
79
 
80
+ task_input = gr.Text(value=task_pretty, visible=False)
81
+
82
+ if task_pretty == TASKS_PRETTY['project_code_completion']:
83
+ dataset_dropdown = gr.Dropdown(choices=code_completion_dataset_names, label="Select the Dataset")
84
+ dataset_dropdown.change(
85
+ fn=get_leaderboard_for_completion_task,
86
+ inputs=dataset_dropdown,
87
+ outputs=leaderboard_table
88
+ )
89
+ refresh_button = gr.Button("πŸ”„ Refresh", variant="secondary")
90
+ refresh_button.click(
91
+ fn=get_leaderboard_for_completion_task,
92
+ inputs=dataset_dropdown,
93
+ outputs=leaderboard_table,
94
+ )
95
+ else:
96
+ refresh_button = gr.Button("πŸ”„ Refresh", variant="secondary")
97
+ refresh_button.click(
98
+ fn=get_leaderboard_for_task,
99
+ inputs=task_input,
100
+ outputs=leaderboard_table,
101
+ )
102
 
103
  # submission
104
  gr.HTML(SUBMISSION_TITLE)