gradio-leaderboard 0.0.5__tar.gz → 0.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/PKG-INFO +3 -4
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/README.md +2 -3
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/backend/gradio_leaderboard/leaderboard.py +36 -7
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/backend/gradio_leaderboard/leaderboard.pyi +29 -4
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/backend/gradio_leaderboard/templates/component/index.js +7423 -7437
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/backend/gradio_leaderboard/templates/component/style.css +1 -1
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/demo/app.py +12 -12
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/demo/docs.md +26 -6
- gradio_leaderboard-0.0.7/demo/space.py +26 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/frontend/Index.svelte +137 -112
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/frontend/package-lock.json +36 -53
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/frontend/package.json +1 -2
- gradio_leaderboard-0.0.7/frontend/shared/RangeSlider.svelte +170 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/frontend/shared/utils.ts +2 -2
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/pyproject.toml +2 -2
- gradio_leaderboard-0.0.5/demo/space.py +0 -42
- gradio_leaderboard-0.0.5/frontend/shared/Slider.svelte +0 -201
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/.gitignore +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/backend/gradio_leaderboard/__init__.py +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/backend/gradio_leaderboard/templates/component/__vite-browser-external-2447137e.js +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/backend/gradio_leaderboard/templates/component/wrapper-6f348d45-19fa94bf.js +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/backend/gradio_leaderboard/templates/example/index.js +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/backend/gradio_leaderboard/templates/example/style.css +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/demo/__init__.py +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/demo/config.py +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/demo/css.css +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/demo/leaderboard_data.json +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/frontend/Example.svelte +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/frontend/shared/Checkboxgroup.svelte +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/frontend/shared/EditableCell.svelte +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/frontend/shared/Example.svelte +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/frontend/shared/SimpleTextbox.svelte +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/frontend/shared/Table.svelte +0 -0
- {gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/frontend/shared/VirtualTable.svelte +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: gradio_leaderboard
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.7
|
4
4
|
Summary: Super fast , batteries included Leaderboard component ⚡️
|
5
5
|
Author-email: YOUR NAME <YOUREMAIL@domain.com>
|
6
6
|
License-Expression: MIT
|
@@ -177,10 +177,9 @@ This will display a series of form elements that users can use to select/deselec
|
|
177
177
|
This parameter must be a `list` but it's elements must be:
|
178
178
|
|
179
179
|
* `a string`: Corresponding to the column name you'd like to add a filter for
|
180
|
-
* `a ColumnFilter`: A special class for full control of the filter's type, e.g. `checkboxgroup`, `slider`, or `dropdown`, as well as it's appearance in the UI.
|
181
|
-
|
182
|
-
If the `type` of the `ColumnFilter` is not specified, a heuristic will be used to choose the most appropriate type. If the data in the column is numeric, a slider will be used. If not, a `checkboxgroup` will be used.
|
180
|
+
* `a ColumnFilter`: A special class for full control of the filter's type, e.g. `checkboxgroup`, `checkbox`, `slider`, or `dropdown`, as well as it's appearance in the UI.
|
183
181
|
|
182
|
+
If the `type` of the `ColumnFilter` is not specified, a heuristic will be used to choose the most appropriate type. If the data in the column is boolean-valued, a `checkbox` will be used. If it is numeric, a slider will be used. For all others, a `checkboxgroup` will be used.
|
184
183
|
|
185
184
|
#### Demo
|
186
185
|
|
@@ -151,10 +151,9 @@ This will display a series of form elements that users can use to select/deselec
|
|
151
151
|
This parameter must be a `list` but it's elements must be:
|
152
152
|
|
153
153
|
* `a string`: Corresponding to the column name you'd like to add a filter for
|
154
|
-
* `a ColumnFilter`: A special class for full control of the filter's type, e.g. `checkboxgroup`, `slider`, or `dropdown`, as well as it's appearance in the UI.
|
155
|
-
|
156
|
-
If the `type` of the `ColumnFilter` is not specified, a heuristic will be used to choose the most appropriate type. If the data in the column is numeric, a slider will be used. If not, a `checkboxgroup` will be used.
|
154
|
+
* `a ColumnFilter`: A special class for full control of the filter's type, e.g. `checkboxgroup`, `checkbox`, `slider`, or `dropdown`, as well as it's appearance in the UI.
|
157
155
|
|
156
|
+
If the `type` of the `ColumnFilter` is not specified, a heuristic will be used to choose the most appropriate type. If the data in the column is boolean-valued, a `checkbox` will be used. If it is numeric, a slider will be used. For all others, a `checkboxgroup` will be used.
|
158
157
|
|
159
158
|
#### Demo
|
160
159
|
|
{gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/backend/gradio_leaderboard/leaderboard.py
RENAMED
@@ -5,7 +5,12 @@ from __future__ import annotations
|
|
5
5
|
import warnings
|
6
6
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, Literal
|
7
7
|
|
8
|
-
from pandas.api.types import
|
8
|
+
from pandas.api.types import (
|
9
|
+
is_numeric_dtype,
|
10
|
+
is_object_dtype,
|
11
|
+
is_string_dtype,
|
12
|
+
is_bool_dtype,
|
13
|
+
)
|
9
14
|
import semantic_version
|
10
15
|
from dataclasses import dataclass, field
|
11
16
|
|
@@ -39,13 +44,12 @@ class SelectColumns:
|
|
39
44
|
@dataclass
|
40
45
|
class ColumnFilter:
|
41
46
|
column: str
|
42
|
-
type: Literal["slider", "dropdown", "checkboxgroup"] = None
|
47
|
+
type: Literal["slider", "dropdown", "checkboxgroup", "boolean"] = None
|
43
48
|
default: Optional[Union[int, float, List[Tuple[str, str]]]] = None
|
44
49
|
choices: Optional[Union[int, float, List[Tuple[str, str]]]] = None
|
45
50
|
label: Optional[str] = None
|
46
51
|
info: Optional[str] = None
|
47
52
|
show_label: bool = True
|
48
|
-
greater_than: bool = True
|
49
53
|
min: Optional[Union[int, float]] = None
|
50
54
|
max: Optional[Union[int, float]] = None
|
51
55
|
|
@@ -74,6 +78,7 @@ class Leaderboard(Component):
|
|
74
78
|
search_columns: list[str] | SearchColumns | None = None,
|
75
79
|
select_columns: list[str] | SelectColumns | None = None,
|
76
80
|
filter_columns: list[str | ColumnFilter] | None = None,
|
81
|
+
bool_checkboxgroup_label: str | None = None,
|
77
82
|
hide_columns: list[str] | None = None,
|
78
83
|
latex_delimiters: list[dict[str, str | bool]] | None = None,
|
79
84
|
label: str | None = None,
|
@@ -98,6 +103,7 @@ class Leaderboard(Component):
|
|
98
103
|
search_columns: See Configuration section of docs for details.
|
99
104
|
select_columns: See Configuration section of docs for details.
|
100
105
|
filter_columns: See Configuration section of docs for details.
|
106
|
+
bool_checkboxgroup_label: Label for the checkboxgroup filter for boolean columns.
|
101
107
|
hide_columns: List of columns to hide by default. They will not be displayed in the table but they can still be used for searching, filtering.
|
102
108
|
label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
|
103
109
|
latex_delimiters: A list of dicts of the form {"left": open delimiter (str), "right": close delimiter (str), "display": whether to display in newline (bool)} that will be used to render LaTeX expressions. If not provided, `latex_delimiters` is set to `[{ "left": "$$", "right": "$$", "display": True }]`, so only expressions enclosed in $$ delimiters will be rendered as LaTeX, and in a new line. Pass in an empty list to disable LaTeX rendering. For more information, see the [KaTeX documentation](https://katex.org/docs/autorender.html). Only applies to columns whose datatype is "markdown".
|
@@ -122,6 +128,7 @@ class Leaderboard(Component):
|
|
122
128
|
self.headers = [str(s) for s in value.columns]
|
123
129
|
self.datatype = datatype
|
124
130
|
self.search_columns = self._get_search_columns(search_columns)
|
131
|
+
self.bool_checkboxgroup_label = bool_checkboxgroup_label
|
125
132
|
self.select_columns_config = self._get_select_columns(select_columns, value)
|
126
133
|
self.filter_columns = self._get_column_filter_configs(filter_columns, value)
|
127
134
|
self.hide_columns = hide_columns or []
|
@@ -153,7 +160,9 @@ class Leaderboard(Component):
|
|
153
160
|
@staticmethod
|
154
161
|
def _get_best_filter_type(
|
155
162
|
column: str, value: pd.DataFrame
|
156
|
-
) -> Literal["slider", "checkboxgroup", "dropdown"]:
|
163
|
+
) -> Literal["slider", "checkboxgroup", "dropdown", "checkbox"]:
|
164
|
+
if is_bool_dtype(value[column]):
|
165
|
+
return "checkbox"
|
157
166
|
if is_numeric_dtype(value[column]):
|
158
167
|
return "slider"
|
159
168
|
if is_string_dtype(value[column]) or is_object_dtype(value[column]):
|
@@ -182,24 +191,44 @@ class Leaderboard(Component):
|
|
182
191
|
def _get_column_filter_config(column: str | ColumnFilter, value: pd.DataFrame):
|
183
192
|
column_name = column if isinstance(column, str) else column.column
|
184
193
|
best_filter_type = Leaderboard._get_best_filter_type(column_name, value)
|
194
|
+
min_val = None
|
195
|
+
max_val = None
|
185
196
|
if best_filter_type == "slider":
|
186
|
-
default =
|
197
|
+
default = [
|
198
|
+
value[column_name].quantile(0.25),
|
199
|
+
value[column_name].quantile(0.70),
|
200
|
+
]
|
201
|
+
min_val = value[column_name].min()
|
202
|
+
max_val = value[column_name].max()
|
203
|
+
choices = None
|
204
|
+
elif best_filter_type == "checkbox":
|
205
|
+
default = False
|
187
206
|
choices = None
|
188
207
|
else:
|
189
208
|
default = value[column_name].unique().tolist()
|
190
209
|
default = [(s, s) for s in default]
|
191
210
|
choices = default
|
192
211
|
if isinstance(column, ColumnFilter):
|
212
|
+
if column.type == "boolean":
|
213
|
+
column.type = "checkbox"
|
193
214
|
if not column.type:
|
194
215
|
column.type = best_filter_type
|
195
|
-
if
|
216
|
+
if column.default is None:
|
196
217
|
column.default = default
|
197
218
|
if not column.choices:
|
198
219
|
column.choices = choices
|
220
|
+
if min_val is not None and max_val is not None:
|
221
|
+
column.min = min_val
|
222
|
+
column.max = max_val
|
199
223
|
return column
|
200
224
|
if isinstance(column, str):
|
201
225
|
return ColumnFilter(
|
202
|
-
column=column,
|
226
|
+
column=column,
|
227
|
+
type=best_filter_type,
|
228
|
+
default=default,
|
229
|
+
choices=choices,
|
230
|
+
min=min_val,
|
231
|
+
max=max_val,
|
203
232
|
)
|
204
233
|
raise ValueError(f"Columns {column} must be a string or a ColumnFilter object")
|
205
234
|
|
{gradio_leaderboard-0.0.5 → gradio_leaderboard-0.0.7}/backend/gradio_leaderboard/leaderboard.pyi
RENAMED
@@ -75,6 +75,7 @@ class Leaderboard(Component):
|
|
75
75
|
search_columns: list[str] | SearchColumns | None = None,
|
76
76
|
select_columns: list[str] | SelectColumns | None = None,
|
77
77
|
filter_columns: list[str | ColumnFilter] | None = None,
|
78
|
+
bool_checkboxgroup_label: str | None = None,
|
78
79
|
hide_columns: list[str] | None = None,
|
79
80
|
latex_delimiters: list[dict[str, str | bool]] | None = None,
|
80
81
|
label: str | None = None,
|
@@ -99,6 +100,7 @@ class Leaderboard(Component):
|
|
99
100
|
search_columns: See Configuration section of docs for details.
|
100
101
|
select_columns: See Configuration section of docs for details.
|
101
102
|
filter_columns: See Configuration section of docs for details.
|
103
|
+
bool_checkboxgroup_label: Label for the checkboxgroup filter for boolean columns.
|
102
104
|
hide_columns: List of columns to hide by default. They will not be displayed in the table but they can still be used for searching, filtering.
|
103
105
|
label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
|
104
106
|
latex_delimiters: A list of dicts of the form {"left": open delimiter (str), "right": close delimiter (str), "display": whether to display in newline (bool)} that will be used to render LaTeX expressions. If not provided, `latex_delimiters` is set to `[{ "left": "$$", "right": "$$", "display": True }]`, so only expressions enclosed in $$ delimiters will be rendered as LaTeX, and in a new line. Pass in an empty list to disable LaTeX rendering. For more information, see the [KaTeX documentation](https://katex.org/docs/autorender.html). Only applies to columns whose datatype is "markdown".
|
@@ -123,6 +125,7 @@ class Leaderboard(Component):
|
|
123
125
|
self.headers = [str(s) for s in value.columns]
|
124
126
|
self.datatype = datatype
|
125
127
|
self.search_columns = self._get_search_columns(search_columns)
|
128
|
+
self.bool_checkboxgroup_label = bool_checkboxgroup_label
|
126
129
|
self.select_columns_config = self._get_select_columns(select_columns, value)
|
127
130
|
self.filter_columns = self._get_column_filter_configs(filter_columns, value)
|
128
131
|
self.hide_columns = hide_columns or []
|
@@ -154,7 +157,9 @@ class Leaderboard(Component):
|
|
154
157
|
@staticmethod
|
155
158
|
def _get_best_filter_type(
|
156
159
|
column: str, value: pd.DataFrame
|
157
|
-
) -> Literal["slider", "checkboxgroup", "dropdown"]:
|
160
|
+
) -> Literal["slider", "checkboxgroup", "dropdown", "checkbox"]:
|
161
|
+
if is_bool_dtype(value[column]):
|
162
|
+
return "checkbox"
|
158
163
|
if is_numeric_dtype(value[column]):
|
159
164
|
return "slider"
|
160
165
|
if is_string_dtype(value[column]) or is_object_dtype(value[column]):
|
@@ -183,24 +188,44 @@ class Leaderboard(Component):
|
|
183
188
|
def _get_column_filter_config(column: str | ColumnFilter, value: pd.DataFrame):
|
184
189
|
column_name = column if isinstance(column, str) else column.column
|
185
190
|
best_filter_type = Leaderboard._get_best_filter_type(column_name, value)
|
191
|
+
min_val = None
|
192
|
+
max_val = None
|
186
193
|
if best_filter_type == "slider":
|
187
|
-
default =
|
194
|
+
default = [
|
195
|
+
value[column_name].quantile(0.25),
|
196
|
+
value[column_name].quantile(0.70),
|
197
|
+
]
|
198
|
+
min_val = value[column_name].min()
|
199
|
+
max_val = value[column_name].max()
|
200
|
+
choices = None
|
201
|
+
elif best_filter_type == "checkbox":
|
202
|
+
default = False
|
188
203
|
choices = None
|
189
204
|
else:
|
190
205
|
default = value[column_name].unique().tolist()
|
191
206
|
default = [(s, s) for s in default]
|
192
207
|
choices = default
|
193
208
|
if isinstance(column, ColumnFilter):
|
209
|
+
if column.type == "boolean":
|
210
|
+
column.type = "checkbox"
|
194
211
|
if not column.type:
|
195
212
|
column.type = best_filter_type
|
196
|
-
if
|
213
|
+
if column.default is None:
|
197
214
|
column.default = default
|
198
215
|
if not column.choices:
|
199
216
|
column.choices = choices
|
217
|
+
if min_val is not None and max_val is not None:
|
218
|
+
column.min = min_val
|
219
|
+
column.max = max_val
|
200
220
|
return column
|
201
221
|
if isinstance(column, str):
|
202
222
|
return ColumnFilter(
|
203
|
-
column=column,
|
223
|
+
column=column,
|
224
|
+
type=best_filter_type,
|
225
|
+
default=default,
|
226
|
+
choices=choices,
|
227
|
+
min=min_val,
|
228
|
+
max=max_val,
|
204
229
|
)
|
205
230
|
raise ValueError(f"Columns {column} must be a string or a ColumnFilter object")
|
206
231
|
|