Update src/populate.py
Browse files- src/populate.py +10 -20
src/populate.py
CHANGED
@@ -1,8 +1,12 @@
|
|
|
|
|
|
1 |
import json
|
2 |
import os
|
3 |
|
4 |
import pandas as pd
|
5 |
|
|
|
|
|
6 |
from src.display.formatting import has_no_nan_values, make_clickable_model
|
7 |
from src.display.utils import AutoEvalColumn, EvalQueueColumn
|
8 |
from src.leaderboard.read_evals import get_raw_eval_results
|
@@ -16,11 +20,11 @@ def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchm
|
|
16 |
df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
17 |
df = df[cols].round(decimals=2)
|
18 |
|
19 |
-
#
|
20 |
if "model" in df.columns:
|
21 |
df["model"] = df["model"].apply(make_clickable_model)
|
22 |
|
23 |
-
# ๋ชจ๋ ๋ฒค์น๋งํฌ๊ฐ ์์ฐ๋์ง ์์
|
24 |
df = df[has_no_nan_values(df, benchmark_cols)]
|
25 |
return df
|
26 |
|
@@ -42,8 +46,10 @@ def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
|
42 |
all_evals.append(data)
|
43 |
elif ".md" not in entry:
|
44 |
# ํด๋์ธ ๊ฒฝ์ฐ: ํ์ผ ์ฌ๋ถ๋ฅผ ํ์ธํ ๋ ์ ์ฒด ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉ
|
45 |
-
sub_entries = [
|
46 |
-
|
|
|
|
|
47 |
for sub_entry in sub_entries:
|
48 |
file_path = os.path.join(save_path, entry, sub_entry)
|
49 |
with open(file_path) as fp:
|
@@ -60,19 +66,3 @@ def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
|
60 |
df_running = pd.DataFrame.from_records(running_list, columns=cols)
|
61 |
df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
|
62 |
return df_finished[cols], df_running[cols], df_pending[cols]
|
63 |
-
|
64 |
-
def make_clickable_model(model_name):
|
65 |
-
print("make_clickable_model ํธ์ถ:", model_name) # ๋๋ฒ๊น
์ฉ ์ถ๋ ฅ
|
66 |
-
if model_name in MODEL_MAPPING:
|
67 |
-
mapping_value = MODEL_MAPPING[model_name]
|
68 |
-
if isinstance(mapping_value, tuple):
|
69 |
-
new_name, new_url = mapping_value
|
70 |
-
else:
|
71 |
-
new_name = mapping_value
|
72 |
-
new_url = f"https://huggingface.co/{new_name}"
|
73 |
-
result = model_hyperlink(new_url, new_name)
|
74 |
-
else:
|
75 |
-
link = f"https://huggingface.co/{model_name}"
|
76 |
-
result = model_hyperlink(link, model_name)
|
77 |
-
print("๋ณํ ๊ฒฐ๊ณผ:", result) # ๋๋ฒ๊น
์ฉ ์ถ๋ ฅ
|
78 |
-
return result
|
|
|
1 |
+
# src/populate.py
|
2 |
+
|
3 |
import json
|
4 |
import os
|
5 |
|
6 |
import pandas as pd
|
7 |
|
8 |
+
# ์๋ ์๋ local `make_clickable_model` ์ ๊ฑฐํ๊ณ ,
|
9 |
+
# ์ธ๋ถ์์ ์ ์๋ ํจ์๋ฅผ import ํด์ต๋๋ค.
|
10 |
from src.display.formatting import has_no_nan_values, make_clickable_model
|
11 |
from src.display.utils import AutoEvalColumn, EvalQueueColumn
|
12 |
from src.leaderboard.read_evals import get_raw_eval_results
|
|
|
20 |
df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
21 |
df = df[cols].round(decimals=2)
|
22 |
|
23 |
+
# "model" ์ปฌ๋ผ์ make_clickable_model ์ ์ฉ
|
24 |
if "model" in df.columns:
|
25 |
df["model"] = df["model"].apply(make_clickable_model)
|
26 |
|
27 |
+
# ๋ชจ๋ ๋ฒค์น๋งํฌ๊ฐ ์์ฐ๋์ง ์์ ํ์ ํํฐ๋ง
|
28 |
df = df[has_no_nan_values(df, benchmark_cols)]
|
29 |
return df
|
30 |
|
|
|
46 |
all_evals.append(data)
|
47 |
elif ".md" not in entry:
|
48 |
# ํด๋์ธ ๊ฒฝ์ฐ: ํ์ผ ์ฌ๋ถ๋ฅผ ํ์ธํ ๋ ์ ์ฒด ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉ
|
49 |
+
sub_entries = [
|
50 |
+
e for e in os.listdir(os.path.join(save_path, entry))
|
51 |
+
if os.path.isfile(os.path.join(save_path, entry, e)) and not e.startswith(".")
|
52 |
+
]
|
53 |
for sub_entry in sub_entries:
|
54 |
file_path = os.path.join(save_path, entry, sub_entry)
|
55 |
with open(file_path) as fp:
|
|
|
66 |
df_running = pd.DataFrame.from_records(running_list, columns=cols)
|
67 |
df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
|
68 |
return df_finished[cols], df_running[cols], df_pending[cols]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|