File size: 1,753 Bytes
b1b6ed6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import gradio as gr

from src.leaderboard import BGB_COLUMN_MAPPING, get_bgb_leaderboard_df, get_leaderboard_df
from src.llm_perf import get_eval_df, get_llm_perf_df


def select_columns_fn(machine, columns, search, llm_perf_df=None):
    if llm_perf_df is None:
        llm_perf_df = get_llm_perf_df(machine=machine)

    selected_leaderboard_df = get_leaderboard_df(llm_perf_df)
    selected_leaderboard_df = selected_leaderboard_df[
        selected_leaderboard_df["Model 🤗"].str.contains(search, case=False)
    ]
    selected_leaderboard_df = selected_leaderboard_df[columns]

    return selected_leaderboard_df


def select_columns_bgb_fn(machine, columns, search, type_checkboxes, param_slider, eval_df=None):
    if eval_df is None:
        eval_df = get_eval_df(machine)

    selected_leaderboard_df = get_bgb_leaderboard_df(eval_df)
    selected_leaderboard_df = selected_leaderboard_df[
        selected_leaderboard_df["Model 🤗"].str.contains(search, case=False)
    ]

    print(param_slider)

    import pdb

    pdb.set_trace()

    columns = ["Model 🤗"] + columns + type_checkboxes

    return selected_leaderboard_df[columns]


def create_select_callback(
    # fixed
    machine_textbox,
    # interactive
    columns_checkboxes,
    search_bar,
    type_checkboxes,
    param_slider,
    # outputs
    leaderboard_table,
):
    columns_checkboxes.change(
        fn=select_columns_bgb_fn,
        inputs=[machine_textbox, columns_checkboxes, search_bar, type_checkboxes, param_slider],
        outputs=[leaderboard_table],
    )
    search_bar.change(
        fn=select_columns_bgb_fn,
        inputs=[machine_textbox, columns_checkboxes, search_bar, type_checkboxes, param_slider],
        outputs=[leaderboard_table],
    )