Alina Lozovskaia commited on
Commit
f073c67
1 Parent(s): 2e74c81

updated utils.py

Browse files
Files changed (3) hide show
  1. .python-version +0 -1
  2. src/display/utils.py +11 -1
  3. src/populate.py +10 -10
.python-version DELETED
@@ -1 +0,0 @@
1
- 3.10.0
 
 
src/display/utils.py CHANGED
@@ -1,9 +1,19 @@
1
  from dataclasses import dataclass, make_dataclass
2
  from enum import Enum
3
-
4
  import pandas as pd
5
 
6
 
 
 
 
 
 
 
 
 
 
 
7
  def fields(raw_class):
8
  return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
9
 
 
1
  from dataclasses import dataclass, make_dataclass
2
  from enum import Enum
3
+ import json
4
  import pandas as pd
5
 
6
 
7
+ def load_json_data(file_path):
8
+ """Safely load JSON data from a file."""
9
+ try:
10
+ with open(file_path, "r") as file:
11
+ return json.load(file)
12
+ except json.JSONDecodeError:
13
+ print(f"Error reading JSON from {file_path}")
14
+ return None # Or raise an exception
15
+
16
+
17
  def fields(raw_class):
18
  return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
19
 
src/populate.py CHANGED
@@ -6,16 +6,16 @@ from src.display.formatting import has_no_nan_values, make_clickable_model
6
  from src.display.utils import AutoEvalColumn, EvalQueueColumn, baseline_row
7
  from src.leaderboard.filter_models import filter_models_flags
8
  from src.leaderboard.read_evals import get_raw_eval_results
 
9
 
10
-
11
- def _load_json_data(file_path):
12
- """Safely load JSON data from a file."""
13
- try:
14
- with open(file_path, "r") as file:
15
- return json.load(file)
16
- except json.JSONDecodeError:
17
- print(f"Error reading JSON from {file_path}")
18
- return None # Or raise an exception
19
 
20
 
21
  def _process_model_data(entry, model_name_key="model", revision_key="revision"):
@@ -38,7 +38,7 @@ def get_evaluation_queue_df(save_path, cols):
38
  if path.name.endswith('.md'):
39
  continue
40
 
41
- data = _load_json_data(path)
42
  if data:
43
  all_evals.append(_process_model_data(data))
44
 
 
6
  from src.display.utils import AutoEvalColumn, EvalQueueColumn, baseline_row
7
  from src.leaderboard.filter_models import filter_models_flags
8
  from src.leaderboard.read_evals import get_raw_eval_results
9
+ from src.display.utils import load_json_data
10
 
11
+ # def _load_json_data(file_path):
12
+ # """Safely load JSON data from a file."""
13
+ # try:
14
+ # with open(file_path, "r") as file:
15
+ # return json.load(file)
16
+ # except json.JSONDecodeError:
17
+ # print(f"Error reading JSON from {file_path}")
18
+ # return None # Or raise an exception
 
19
 
20
 
21
  def _process_model_data(entry, model_name_key="model", revision_key="revision"):
 
38
  if path.name.endswith('.md'):
39
  continue
40
 
41
+ data = load_json_data(path)
42
  if data:
43
  all_evals.append(_process_model_data(data))
44