brunneis commited on
Commit
f8e2509
1 Parent(s): e9f2fe4

Fix Python compatibility

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. src/display/utils.py +37 -29
app.py CHANGED
@@ -94,7 +94,6 @@ def init_leaderboard(dataframe):
94
  type="slider",
95
  min=1,
96
  max=500,
97
- step=1,
98
  label="Number of parameters (billions)",
99
  ),
100
  ],
@@ -223,5 +222,6 @@ scheduler = BackgroundScheduler()
223
  scheduler.add_job(restart_space, "interval", seconds=1800)
224
  scheduler.start()
225
  demo.queue(default_concurrency_limit=40).launch(
 
226
  allowed_paths=["images/solbench.svg"],
227
  )
 
94
  type="slider",
95
  min=1,
96
  max=500,
 
97
  label="Number of parameters (billions)",
98
  ),
99
  ],
 
222
  scheduler.add_job(restart_space, "interval", seconds=1800)
223
  scheduler.start()
224
  demo.queue(default_concurrency_limit=40).launch(
225
+ server_name="0.0.0.0",
226
  allowed_paths=["images/solbench.svg"],
227
  )
src/display/utils.py CHANGED
@@ -2,8 +2,9 @@
2
  # -*- coding: utf-8 -*-
3
  # flake8: noqa E501
4
 
5
- from dataclasses import dataclass, make_dataclass
6
  from enum import Enum
 
7
 
8
  import pandas as pd
9
 
@@ -13,44 +14,51 @@ from src.about import Tasks
13
  def fields(raw_class):
14
  return [v for k, v in raw_class.__dict__.items() if not k.startswith("__") and not k.endswith("__")]
15
 
16
-
17
  # These classes are for user facing column names,
18
  # to avoid having to change them all around the code
19
  # when a modif is needed
20
  @dataclass
21
  class ColumnContent:
22
  name: str
23
- type: str
24
- displayed_by_default: bool
25
- hidden: bool = False
26
- never_hidden: bool = False
27
 
28
- ## Leaderboard columns
29
- auto_eval_column_dict = []
30
 
31
- # Init
32
- auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
33
- auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
34
 
35
- # Scores
36
- auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average ⬆️", "number", True)])
37
- for task in Tasks:
38
- auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
39
-
40
- # Model information
41
- auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
42
- auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
43
- auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, True)])
44
- auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False)])
45
- auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("License", "str", False)])
46
- auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("Parameters ⚙️", "number", False)])
47
- auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Likes ❤️", "number", False)])
48
- auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
49
- auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
50
-
51
- # We use make dataclass to dynamically fill the scores from Tasks
52
- AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  # For the queue columns in the submission tab
56
  @dataclass(frozen=True)
 
2
  # -*- coding: utf-8 -*-
3
  # flake8: noqa E501
4
 
5
+ from dataclasses import dataclass, field, make_dataclass
6
  from enum import Enum
7
+ from functools import partial
8
 
9
  import pandas as pd
10
 
 
14
  def fields(raw_class):
15
  return [v for k, v in raw_class.__dict__.items() if not k.startswith("__") and not k.endswith("__")]
16
 
 
17
  # These classes are for user facing column names,
18
  # to avoid having to change them all around the code
19
  # when a modif is needed
20
  @dataclass
21
  class ColumnContent:
22
  name: str
23
+ type: str = field(default='str')
24
+ displayed_by_default: bool = field(default=False)
25
+ hidden: bool = field(default=False)
26
+ never_hidden: bool = field(default=False)
27
 
 
 
28
 
29
+ # Helper function to create a ColumnContent with default_factory
30
+ def create_column_content(name, type='str', displayed_by_default=False, hidden=False, never_hidden=False):
31
+ return field(default_factory=lambda: ColumnContent(name, type, displayed_by_default, hidden, never_hidden))
32
 
33
+ auto_eval_column_dict = [
34
+ ("model_type_symbol", ColumnContent, create_column_content("", "str", True, never_hidden=True)),
35
+ ("model", ColumnContent, create_column_content("Model", "markdown", True, never_hidden=True)),
36
+ ("average", ColumnContent, create_column_content("Average", "number", True)),
37
+ ]
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
+ # Add task-specific columns
40
+ for task in Tasks:
41
+ auto_eval_column_dict.append((task.name, ColumnContent, create_column_content(task.value.col_name, "number", True)))
42
+
43
+ # Add model information columns
44
+ model_info_columns = [
45
+ ("model_type", "Type", "str", False),
46
+ ("architecture", "Architecture", "str", False),
47
+ ("weight_type", "Weight type", "str", False, True),
48
+ ("precision", "Precision", "str", False),
49
+ ("license", "License", "str", False),
50
+ ("params", "Parameters ⚙️", "number", False),
51
+ ("likes", "Likes ❤️", "number", False),
52
+ ("still_on_hub", "Available on the hub", "bool", False),
53
+ ("revision", "Model sha", "str", False, False),
54
+ ]
55
+
56
+ for col_name, display_name, col_type, displayed_by_default, *args in model_info_columns:
57
+ hidden = args[0] if args else False
58
+ auto_eval_column_dict.append((col_name, ColumnContent, create_column_content(display_name, col_type, displayed_by_default, hidden)))
59
+
60
+ # Create the AutoEvalColumn dataclass
61
+ AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)()
62
 
63
  # For the queue columns in the submission tab
64
  @dataclass(frozen=True)