Ali-C137 commited on
Commit
866ba51
1 Parent(s): deb0dda

Update src/populate.py

Browse files
Files changed (1) hide show
  1. src/populate.py +53 -9
src/populate.py CHANGED
@@ -22,18 +22,57 @@ def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchm
22
  return raw_data, df
23
 
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
26
- """Creates the different dataframes for the evaluation queues requestes"""
27
  entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
28
  all_evals = []
29
 
30
  for entry in entries:
31
  if ".json" in entry:
32
  file_path = os.path.join(save_path, entry)
33
- with open(file_path) as fp:
34
- print(file_path)
35
- print("\n")
36
- data = json.load(fp)
 
 
37
 
38
  data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
39
  data[EvalQueueColumn.revision.name] = data.get("revision", "main")
@@ -44,10 +83,15 @@ def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
44
  sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if not e.startswith(".")]
45
  for sub_entry in sub_entries:
46
  file_path = os.path.join(save_path, entry, sub_entry)
47
- with open(file_path) as fp:
48
- print(file_path)
49
- print("\n")
50
- data = json.load(fp)
 
 
 
 
 
51
 
52
  data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
53
  data[EvalQueueColumn.revision.name] = data.get("revision", "main")
 
22
  return raw_data, df
23
 
24
 
25
+ # def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
26
+ # """Creates the different dataframes for the evaluation queues requestes"""
27
+ # entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
28
+ # all_evals = []
29
+
30
+ # for entry in entries:
31
+ # if ".json" in entry:
32
+ # file_path = os.path.join(save_path, entry)
33
+ # with open(file_path) as fp:
34
+ # print(file_path)
35
+ # print("\n")
36
+ # data = json.load(fp)
37
+
38
+ # data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
39
+ # data[EvalQueueColumn.revision.name] = data.get("revision", "main")
40
+
41
+ # all_evals.append(data)
42
+ # elif ".md" not in entry:
43
+ # # this is a folder
44
+ # sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if not e.startswith(".")]
45
+ # for sub_entry in sub_entries:
46
+ # file_path = os.path.join(save_path, entry, sub_entry)
47
+ # with open(file_path) as fp:
48
+ # print(file_path)
49
+ # print("\n")
50
+ # data = json.load(fp)
51
+
52
+ # data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
53
+ # data[EvalQueueColumn.revision.name] = data.get("revision", "main")
54
+ # all_evals.append(data)
55
+
56
+ # pending_list = [e for e in all_evals if e["status"] in ["PENDING", "RERUN"]]
57
+ # running_list = [e for e in all_evals if e["status"] == "RUNNING"]
58
+ # finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
59
+ # df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
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
  def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
 
64
  entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
65
  all_evals = []
66
 
67
  for entry in entries:
68
  if ".json" in entry:
69
  file_path = os.path.join(save_path, entry)
70
+ try:
71
+ with open(file_path, encoding='utf-8') as fp:
72
+ data = json.load(fp)
73
+ except UnicodeDecodeError as e:
74
+ print(f"Unicode decoding error in {file_path}: {e}")
75
+ continue
76
 
77
  data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
78
  data[EvalQueueColumn.revision.name] = data.get("revision", "main")
 
83
  sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if not e.startswith(".")]
84
  for sub_entry in sub_entries:
85
  file_path = os.path.join(save_path, entry, sub_entry)
86
+ try:
87
+ with open(file_path, encoding='utf-8') as fp:
88
+ data = json.load(fp)
89
+ except json.JSONDecodeError:
90
+ print(f"Error reading {file_path}")
91
+ continue
92
+ except UnicodeDecodeError as e:
93
+ print(f"Unicode decoding error in {file_path}: {e}")
94
+ continue
95
 
96
  data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
97
  data[EvalQueueColumn.revision.name] = data.get("revision", "main")