Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -315,17 +315,17 @@ with gr.Blocks() as demo_leaderboard:
|
|
315 |
shown_columns_dict[task_type.name] = shown_column
|
316 |
with gr.Row():
|
317 |
gr.Button("全選択", size="sm").click(
|
318 |
-
fn=lambda
|
319 |
-
outputs=
|
320 |
)
|
321 |
gr.Button("全解除", size="sm").click(
|
322 |
-
fn=lambda
|
323 |
-
outputs=
|
324 |
)
|
325 |
gr.Button("AVGのみ", size="sm").click(
|
326 |
-
fn=lambda
|
327 |
-
outputs=
|
328 |
-
)
|
329 |
# with gr.Row(height=110):
|
330 |
# shown_column = gr.CheckboxGroup(
|
331 |
# show_label=False,
|
@@ -447,27 +447,36 @@ with gr.Blocks() as demo_leaderboard:
|
|
447 |
# Check query parameter once at startup and update search bar + hidden component
|
448 |
demo_leaderboard.load(fn=load_query, outputs=[search_bar, hidden_search_bar])
|
449 |
|
450 |
-
def
|
451 |
-
"""
|
452 |
-
|
453 |
-
|
454 |
-
if
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
return []
|
462 |
-
elif action == "avg_only":
|
463 |
-
if task_type == TaskType.AVG.name:
|
464 |
-
return columns # 全体AVGの場合
|
465 |
-
return [
|
466 |
-
c.name for c in fields(AutoEvalColumn)
|
467 |
-
if not c.hidden and not c.never_hidden and c.average
|
468 |
-
and c.task_type.name == task_type # カテゴリー別AVGの場合
|
469 |
]
|
470 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
471 |
|
472 |
# Submission demo
|
473 |
|
|
|
315 |
shown_columns_dict[task_type.name] = shown_column
|
316 |
with gr.Row():
|
317 |
gr.Button("全選択", size="sm").click(
|
318 |
+
fn=lambda: toggle_all_categories("all", shown_columns_dict),
|
319 |
+
outputs=[shown_columns_dict[task_type.name] for task_type in TaskType if task_type != TaskType.NotTask]
|
320 |
)
|
321 |
gr.Button("全解除", size="sm").click(
|
322 |
+
fn=lambda: toggle_all_categories("none", shown_columns_dict),
|
323 |
+
outputs=[shown_columns_dict[task_type.name] for task_type in TaskType if task_type != TaskType.NotTask]
|
324 |
)
|
325 |
gr.Button("AVGのみ", size="sm").click(
|
326 |
+
fn=lambda: toggle_all_categories("avg_only", shown_columns_dict),
|
327 |
+
outputs=[shown_columns_dict[task_type.name] for task_type in TaskType if task_type != TaskType.NotTask]
|
328 |
+
)
|
329 |
# with gr.Row(height=110):
|
330 |
# shown_column = gr.CheckboxGroup(
|
331 |
# show_label=False,
|
|
|
447 |
# Check query parameter once at startup and update search bar + hidden component
|
448 |
demo_leaderboard.load(fn=load_query, outputs=[search_bar, hidden_search_bar])
|
449 |
|
450 |
+
def toggle_all_categories(action: str, shown_columns_dict: dict):
|
451 |
+
"""全カテゴリーのチェックボックスを一括制御する関数"""
|
452 |
+
results = {}
|
453 |
+
for task_type in TaskType:
|
454 |
+
if task_type == TaskType.NotTask:
|
455 |
+
continue
|
456 |
+
|
457 |
+
columns = [
|
458 |
+
c.name
|
459 |
+
for c in fields(AutoEvalColumn)
|
460 |
+
if not c.hidden and not c.never_hidden and not c.dummy and c.task_type == task_type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
461 |
]
|
462 |
+
|
463 |
+
if action == "all":
|
464 |
+
results[task_type.name] = columns
|
465 |
+
elif action == "none":
|
466 |
+
results[task_type.name] = []
|
467 |
+
elif action == "avg_only":
|
468 |
+
results[task_type.name] = [
|
469 |
+
c.name
|
470 |
+
for c in fields(AutoEvalColumn)
|
471 |
+
if not c.hidden and not c.never_hidden
|
472 |
+
and c.task_type == task_type
|
473 |
+
and (
|
474 |
+
(task_type == TaskType.AVG) or # AVGカテゴリの場合は全て
|
475 |
+
(task_type != TaskType.AVG and c.average) # その他のカテゴリはAVGのみ
|
476 |
+
)
|
477 |
+
]
|
478 |
+
|
479 |
+
return [results[task_type.name] for task_type in TaskType if task_type != TaskType.NotTask]
|
480 |
|
481 |
# Submission demo
|
482 |
|