Spaces:
Running
Running
Commit
•
2861b85
1
Parent(s):
7f86019
leaderboard page reload on select to pull the latest dataset (#66)
Browse files- use tab.select to updaate leaderboard (82ccd8b6e0bb2ebbab5ed78fe09445bb75ffaf7d)
- clear print log (8ef4c5a1b567360f7d73a5b4fb712496b327b971)
Co-authored-by: zcy <ZeroCommand@users.noreply.huggingface.co>
- app.py +3 -1
- app_leaderboard.py +7 -5
app.py
CHANGED
@@ -11,11 +11,13 @@ try:
|
|
11 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="green")) as demo:
|
12 |
with gr.Tab("Text Classification"):
|
13 |
get_demo_text_classification()
|
14 |
-
with gr.Tab("Leaderboard"):
|
15 |
get_demo_leaderboard()
|
16 |
with gr.Tab("Logs(Debug)"):
|
17 |
get_demo_debug()
|
18 |
|
|
|
|
|
19 |
start_process_run_job()
|
20 |
|
21 |
demo.queue(max_size=1000)
|
|
|
11 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="green")) as demo:
|
12 |
with gr.Tab("Text Classification"):
|
13 |
get_demo_text_classification()
|
14 |
+
with gr.Tab("Leaderboard") as leaderboard_tab:
|
15 |
get_demo_leaderboard()
|
16 |
with gr.Tab("Logs(Debug)"):
|
17 |
get_demo_debug()
|
18 |
|
19 |
+
leaderboard_tab.select(fn=get_demo_leaderboard)
|
20 |
+
|
21 |
start_process_run_job()
|
22 |
|
23 |
demo.queue(max_size=1000)
|
app_leaderboard.py
CHANGED
@@ -7,25 +7,26 @@ from fetch_utils import (check_dataset_and_get_config,
|
|
7 |
check_dataset_and_get_split)
|
8 |
|
9 |
import leaderboard
|
|
|
10 |
|
11 |
def get_records_from_dataset_repo(dataset_id):
|
12 |
dataset_config = check_dataset_and_get_config(dataset_id)
|
13 |
|
14 |
-
|
15 |
dataset_split = check_dataset_and_get_split(dataset_id, dataset_config[0])
|
16 |
-
|
17 |
|
18 |
try:
|
19 |
ds = datasets.load_dataset(dataset_id, dataset_config[0])[dataset_split[0]]
|
20 |
df = ds.to_pandas()
|
21 |
return df
|
22 |
except Exception as e:
|
23 |
-
|
24 |
f"Failed to load dataset {dataset_id} with config {dataset_config}: {e}"
|
25 |
)
|
26 |
return None
|
27 |
|
28 |
-
|
29 |
def get_model_ids(ds):
|
30 |
logging.info(f"Dataset {ds} column names: {ds['model_id']}")
|
31 |
models = ds["model_id"].tolist()
|
@@ -74,6 +75,7 @@ def get_display_df(df):
|
|
74 |
|
75 |
|
76 |
def get_demo():
|
|
|
77 |
leaderboard.records = get_records_from_dataset_repo(leaderboard.LEADERBOARD)
|
78 |
records = leaderboard.records
|
79 |
|
@@ -138,4 +140,4 @@ def get_demo():
|
|
138 |
df = df[columns]
|
139 |
types = get_types(df)
|
140 |
display_df = get_display_df(df)
|
141 |
-
return gr.update(value=display_df, datatype=types, interactive=False)
|
|
|
7 |
check_dataset_and_get_split)
|
8 |
|
9 |
import leaderboard
|
10 |
+
logger = logging.getLogger(__name__)
|
11 |
|
12 |
def get_records_from_dataset_repo(dataset_id):
|
13 |
dataset_config = check_dataset_and_get_config(dataset_id)
|
14 |
|
15 |
+
logger.info(f"Dataset {dataset_id} has configs {dataset_config}")
|
16 |
dataset_split = check_dataset_and_get_split(dataset_id, dataset_config[0])
|
17 |
+
logger.info(f"Dataset {dataset_id} has splits {dataset_split}")
|
18 |
|
19 |
try:
|
20 |
ds = datasets.load_dataset(dataset_id, dataset_config[0])[dataset_split[0]]
|
21 |
df = ds.to_pandas()
|
22 |
return df
|
23 |
except Exception as e:
|
24 |
+
logger.warning(
|
25 |
f"Failed to load dataset {dataset_id} with config {dataset_config}: {e}"
|
26 |
)
|
27 |
return None
|
28 |
|
29 |
+
|
30 |
def get_model_ids(ds):
|
31 |
logging.info(f"Dataset {ds} column names: {ds['model_id']}")
|
32 |
models = ds["model_id"].tolist()
|
|
|
75 |
|
76 |
|
77 |
def get_demo():
|
78 |
+
logger.info("Loading leaderboard records")
|
79 |
leaderboard.records = get_records_from_dataset_repo(leaderboard.LEADERBOARD)
|
80 |
records = leaderboard.records
|
81 |
|
|
|
140 |
df = df[columns]
|
141 |
types = get_types(df)
|
142 |
display_df = get_display_df(df)
|
143 |
+
return gr.update(value=display_df, datatype=types, interactive=False)
|