lukehinds commited on
Commit
3ea291e
·
1 Parent(s): 7a3d0ce

UI working

Browse files
src/display/utils.py CHANGED
@@ -12,8 +12,14 @@ class ColumnContent:
12
  never_hidden: bool = False
13
 
14
  def fields(raw_class):
15
- """Get all fields from a dataclass instance."""
16
- return [getattr(raw_class, field.name) for field in dataclass_fields(raw_class)]
 
 
 
 
 
 
17
 
18
  ## Leaderboard columns
19
  def create_column_field(name: str, type: str, displayed_by_default: bool, hidden: bool = False, never_hidden: bool = False):
@@ -40,8 +46,9 @@ model_info_columns = [
40
  ]
41
 
42
  def make_valid_identifier(name):
43
- # Replace invalid characters with underscores and make lowercase
44
- valid = name.lower().replace(" ", "_").replace("-", "_")
 
45
  valid = "".join(c if c.isalnum() or c == "_" else "" for c in valid)
46
  # Ensure it starts with a letter
47
  if valid[0].isdigit():
 
12
  never_hidden: bool = False
13
 
14
  def fields(raw_class):
15
+ """Get all fields from a dataclass instance or class."""
16
+ if isinstance(raw_class, type):
17
+ # If raw_class is a class, create an instance first
18
+ instance = raw_class()
19
+ return [getattr(instance, field.name) for field in dataclass_fields(instance)]
20
+ else:
21
+ # If raw_class is already an instance
22
+ return [getattr(raw_class, field.name) for field in dataclass_fields(raw_class)]
23
 
24
  ## Leaderboard columns
25
  def create_column_field(name: str, type: str, displayed_by_default: bool, hidden: bool = False, never_hidden: bool = False):
 
46
  ]
47
 
48
  def make_valid_identifier(name):
49
+ # Replace spaces and hyphens with underscores but preserve case
50
+ valid = name.replace(" ", "_").replace("-", "_").replace("⬆️", "up")
51
+ # Remove any other invalid characters but preserve case
52
  valid = "".join(c if c.isalnum() or c == "_" else "" for c in valid)
53
  # Ensure it starts with a letter
54
  if valid[0].isdigit():
src/leaderboard/read_evals.py CHANGED
@@ -40,10 +40,9 @@ class EvalResult:
40
 
41
  config = data.get("config")
42
 
43
- # Precision
44
  precision = Precision.from_str(config.get("model_dtype"))
45
 
46
- # Get model and org
47
  org_and_model = config.get("model_name", config.get("model_args", None))
48
  org_and_model = org_and_model.split("/", 1)
49
 
 
40
 
41
  config = data.get("config")
42
 
 
43
  precision = Precision.from_str(config.get("model_dtype"))
44
 
45
+ # Get model and org, e.g. stacklok/codellama-3.1-8b-instruct
46
  org_and_model = config.get("model_name", config.get("model_args", None))
47
  org_and_model = org_and_model.split("/", 1)
48
 
src/submission/check_validity.py CHANGED
@@ -117,14 +117,22 @@ def already_submitted_models(requested_models_dir: str) -> tuple[set[str], defau
117
  for file in files:
118
  if not file.endswith(".json"):
119
  continue
120
- with open(os.path.join(root, file), "r") as f:
121
- info = json.load(f)
122
- file_names.append(f"{info['model']}_{info['revision']}_{info['precision']}")
123
-
124
- # Select organisation
125
- if info["model"].count("/") == 0 or "submitted_time" not in info:
126
- continue
127
- organisation, _ = info["model"].split("/")
128
- users_to_submission_dates[organisation].append(info["submitted_time"])
 
 
 
 
 
 
 
 
129
 
130
  return set(file_names), users_to_submission_dates
 
117
  for file in files:
118
  if not file.endswith(".json"):
119
  continue
120
+ try:
121
+ with open(os.path.join(root, file), "r") as f:
122
+ info = json.load(f)
123
+ # Handle missing fields gracefully
124
+ model = info.get('model', '')
125
+ revision = info.get('revision', 'main') # default to main if missing
126
+ precision = info.get('precision', '')
127
+ file_names.append(f"{model}_{revision}_{precision}")
128
+
129
+ # Select organisation
130
+ if model.count("/") == 0 or "submitted_time" not in info:
131
+ continue
132
+ organisation, _ = model.split("/")
133
+ users_to_submission_dates[organisation].append(info["submitted_time"])
134
+ except (json.JSONDecodeError, KeyError, IOError) as e:
135
+ print(f"Warning: Skipping malformed file {file}: {str(e)}")
136
+ continue
137
 
138
  return set(file_names), users_to_submission_dates