openfree commited on
Commit
09776c0
ยท
verified ยท
1 Parent(s): 6439e4c

Update src/populate.py

Browse files
Files changed (1) hide show
  1. 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 = [e for e in os.listdir(os.path.join(save_path, entry))
46
- if os.path.isfile(os.path.join(save_path, entry, e)) and not e.startswith(".")]
 
 
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]