squirrels 0.5.0b2__py3-none-any.whl → 0.5.0b3__py3-none-any.whl
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.
- dateutils/__init__.py +6 -460
- dateutils/_enums.py +25 -0
- dateutils/_implementation.py +409 -0
- dateutils/types.py +6 -0
- squirrels/__init__.py +7 -13
- squirrels/_api_server.py +5 -5
- squirrels/{arguments/init_time_args.py → _arguments/_init_time_args.py} +2 -2
- squirrels/{arguments/run_time_args.py → _arguments/_run_time_args.py} +4 -26
- squirrels/_auth.py +2 -2
- squirrels/_connection_set.py +5 -5
- squirrels/_constants.py +1 -1
- squirrels/_dashboard_types.py +82 -0
- squirrels/_dashboards_io.py +2 -2
- squirrels/_data_sources.py +564 -0
- squirrels/_exceptions.py +1 -1
- squirrels/_initializer.py +31 -26
- squirrels/_manifest.py +5 -5
- squirrels/_model_configs.py +2 -2
- squirrels/_model_queries.py +1 -1
- squirrels/_models.py +28 -16
- squirrels/{package_data → _package_data}/base_project/dashboards/dashboard_example.py +4 -4
- squirrels/{package_data → _package_data}/base_project/dashboards/dashboard_example.yml +2 -2
- squirrels/_package_data/base_project/macros/macros_example.sql +17 -0
- squirrels/{package_data → _package_data}/base_project/models/builds/build_example.py +2 -2
- squirrels/{package_data → _package_data}/base_project/models/builds/build_example.sql +1 -1
- squirrels/{package_data → _package_data}/base_project/models/dbviews/dbview_example.sql +1 -1
- squirrels/_package_data/base_project/models/federates/federate_example.py +41 -0
- squirrels/_package_data/base_project/models/federates/federate_example.sql +25 -0
- squirrels/{package_data → _package_data}/base_project/models/federates/federate_example.yml +6 -6
- squirrels/{package_data → _package_data}/base_project/parameters.yml +9 -8
- squirrels/_package_data/base_project/pyconfigs/connections.py +14 -0
- squirrels/{package_data → _package_data}/base_project/pyconfigs/context.py +14 -16
- squirrels/{package_data → _package_data}/base_project/pyconfigs/parameters.py +13 -8
- squirrels/{package_data → _package_data}/base_project/pyconfigs/user.py +2 -2
- squirrels/_parameter_configs.py +34 -34
- squirrels/_parameter_options.py +348 -0
- squirrels/_parameter_sets.py +18 -18
- squirrels/_parameters.py +1266 -0
- squirrels/_project.py +37 -12
- squirrels/_utils.py +4 -2
- squirrels/arguments.py +2 -0
- squirrels/connections.py +1 -0
- squirrels/dashboards.py +1 -82
- squirrels/data_sources.py +8 -563
- squirrels/parameter_options.py +8 -348
- squirrels/parameters.py +9 -1266
- squirrels/types.py +11 -0
- {squirrels-0.5.0b2.dist-info → squirrels-0.5.0b3.dist-info}/METADATA +1 -1
- squirrels-0.5.0b3.dist-info/RECORD +80 -0
- squirrels/package_data/base_project/macros/macros_example.sql +0 -15
- squirrels/package_data/base_project/models/federates/federate_example.py +0 -44
- squirrels/package_data/base_project/models/federates/federate_example.sql +0 -17
- squirrels/package_data/base_project/pyconfigs/connections.py +0 -14
- squirrels-0.5.0b2.dist-info/RECORD +0 -70
- /squirrels/{dataset_result.py → _dataset_types.py} +0 -0
- /squirrels/{package_data → _package_data}/base_project/.env +0 -0
- /squirrels/{package_data → _package_data}/base_project/.env.example +0 -0
- /squirrels/{package_data → _package_data}/base_project/assets/expenses.db +0 -0
- /squirrels/{package_data → _package_data}/base_project/assets/weather.db +0 -0
- /squirrels/{package_data → _package_data}/base_project/connections.yml +0 -0
- /squirrels/{package_data → _package_data}/base_project/docker/.dockerignore +0 -0
- /squirrels/{package_data → _package_data}/base_project/docker/Dockerfile +0 -0
- /squirrels/{package_data → _package_data}/base_project/docker/compose.yml +0 -0
- /squirrels/{package_data → _package_data}/base_project/duckdb_init.sql +0 -0
- /squirrels/{package_data/base_project/.gitignore → _package_data/base_project/gitignore} +0 -0
- /squirrels/{package_data → _package_data}/base_project/models/builds/build_example.yml +0 -0
- /squirrels/{package_data → _package_data}/base_project/models/dbviews/dbview_example.yml +0 -0
- /squirrels/{package_data → _package_data}/base_project/models/sources.yml +0 -0
- /squirrels/{package_data → _package_data}/base_project/seeds/seed_categories.csv +0 -0
- /squirrels/{package_data → _package_data}/base_project/seeds/seed_categories.yml +0 -0
- /squirrels/{package_data → _package_data}/base_project/seeds/seed_subcategories.csv +0 -0
- /squirrels/{package_data → _package_data}/base_project/seeds/seed_subcategories.yml +0 -0
- /squirrels/{package_data → _package_data}/base_project/squirrels.yml.j2 +0 -0
- /squirrels/{package_data → _package_data}/base_project/tmp/.gitignore +0 -0
- {squirrels-0.5.0b2.dist-info → squirrels-0.5.0b3.dist-info}/WHEEL +0 -0
- {squirrels-0.5.0b2.dist-info → squirrels-0.5.0b3.dist-info}/entry_points.txt +0 -0
- {squirrels-0.5.0b2.dist-info → squirrels-0.5.0b3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
-
from squirrels import
|
|
2
|
+
from squirrels import arguments as args, parameters as p
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
def main(ctx: dict[str, Any], sqrl: ContextArgs) -> None:
|
|
5
|
+
def main(ctx: dict[str, Any], sqrl: args.ContextArgs) -> None:
|
|
6
6
|
"""
|
|
7
7
|
Define context variables AFTER parameter selections are made by adding entries to the dictionary "ctx".
|
|
8
8
|
These context variables can then be used in the models.
|
|
@@ -18,52 +18,50 @@ def main(ctx: dict[str, Any], sqrl: ContextArgs) -> None:
|
|
|
18
18
|
aliases = group_by_param.get_selected("aliases", default_field="columns")
|
|
19
19
|
assert isinstance(columns, list) and isinstance(aliases, list) and len(columns) == len(aliases)
|
|
20
20
|
|
|
21
|
-
ctx["
|
|
22
|
-
ctx["
|
|
23
|
-
ctx["
|
|
24
|
-
ctx["
|
|
25
|
-
ctx["
|
|
21
|
+
ctx["group_by_cols"] = columns
|
|
22
|
+
ctx["rename_dict"] = {x: y for x, y in zip(columns, aliases) if not y.startswith("_")}
|
|
23
|
+
ctx["select_dim_cols"] = list(x+" as "+y for x, y in ctx["rename_dict"].items())
|
|
24
|
+
ctx["order_by_cols"] = list(ctx["rename_dict"].values())
|
|
25
|
+
ctx["order_by_cols_desc"] = list(x+" DESC" for x in ctx["order_by_cols"])
|
|
26
26
|
|
|
27
27
|
if sqrl.param_exists("limit"):
|
|
28
28
|
limit_param = sqrl.prms["limit"]
|
|
29
29
|
assert isinstance(limit_param, p.NumberParameter)
|
|
30
30
|
|
|
31
|
-
ctx["
|
|
32
|
-
else:
|
|
33
|
-
ctx["limit_clause"] = ""
|
|
31
|
+
ctx["limit"] = int(limit_param.get_selected_value())
|
|
34
32
|
|
|
35
33
|
if sqrl.param_exists("start_date"):
|
|
36
34
|
start_date_param = sqrl.prms["start_date"]
|
|
37
35
|
assert isinstance(start_date_param, p.DateParameter)
|
|
38
36
|
|
|
39
|
-
ctx["start_date"] = start_date_param.
|
|
37
|
+
ctx["start_date"] = start_date_param.get_selected_date()
|
|
40
38
|
|
|
41
39
|
if sqrl.param_exists("end_date"):
|
|
42
40
|
end_date_param = sqrl.prms["end_date"]
|
|
43
41
|
assert isinstance(end_date_param, p.DateParameter)
|
|
44
42
|
|
|
45
|
-
ctx["end_date"] = end_date_param.
|
|
43
|
+
ctx["end_date"] = end_date_param.get_selected_date()
|
|
46
44
|
|
|
47
45
|
if sqrl.param_exists("date_range"):
|
|
48
46
|
date_range_param = sqrl.prms["date_range"]
|
|
49
47
|
assert isinstance(date_range_param, p.DateRangeParameter)
|
|
50
48
|
|
|
51
|
-
ctx["start_date_from_range"] = date_range_param.
|
|
52
|
-
ctx["end_date_from_range"] = date_range_param.
|
|
49
|
+
ctx["start_date_from_range"] = date_range_param.get_selected_start_date()
|
|
50
|
+
ctx["end_date_from_range"] = date_range_param.get_selected_end_date()
|
|
53
51
|
|
|
54
52
|
if sqrl.param_exists("category"):
|
|
55
53
|
category_param = sqrl.prms["category"]
|
|
56
54
|
assert isinstance(category_param, p.MultiSelectParameter)
|
|
57
55
|
|
|
58
56
|
ctx["has_categories"] = category_param.has_non_empty_selection()
|
|
59
|
-
ctx["categories"] = category_param.
|
|
57
|
+
ctx["categories"] = category_param.get_selected_ids_as_list()
|
|
60
58
|
|
|
61
59
|
if sqrl.param_exists("subcategory"):
|
|
62
60
|
subcategory_param = sqrl.prms["subcategory"]
|
|
63
61
|
assert isinstance(subcategory_param, p.MultiSelectParameter)
|
|
64
62
|
|
|
65
63
|
ctx["has_subcategories"] = subcategory_param.has_non_empty_selection()
|
|
66
|
-
ctx["subcategories"] = subcategory_param.
|
|
64
|
+
ctx["subcategories"] = subcategory_param.get_selected_ids_as_list()
|
|
67
65
|
|
|
68
66
|
if sqrl.param_exists("min_filter"):
|
|
69
67
|
min_amount_filter = sqrl.prms["min_filter"]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
from squirrels import
|
|
1
|
+
from squirrels import arguments as args, data_sources as ds, parameter_options as po, parameters as p
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
def main(sqrl: ParametersArgs) -> None:
|
|
4
|
+
def main(sqrl: args.ParametersArgs) -> None:
|
|
5
5
|
"""
|
|
6
6
|
Create all widget parameters in this file. If two or more datasets use a different set of parameters, define them all
|
|
7
7
|
here, and specify the subset of parameters used for each dataset in the "squirrels.yml" file.
|
|
@@ -19,11 +19,16 @@ def main(sqrl: ParametersArgs) -> None:
|
|
|
19
19
|
## Example of creating SingleSelectParameter and specifying each option by code
|
|
20
20
|
user_attribute = "role"
|
|
21
21
|
group_by_options = [
|
|
22
|
-
po.SelectParameterOption(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
po.SelectParameterOption(
|
|
23
|
+
"trans", "Transaction",
|
|
24
|
+
columns=["id", "date", "category", "subcategory", "description"],
|
|
25
|
+
aliases=["_id", "date", "category", "subcategory", "description"], # any alias starting with "_" will not be selected - see context.py for implementation
|
|
26
|
+
user_groups=["manager"]
|
|
27
|
+
),
|
|
28
|
+
po.SelectParameterOption("day", "Day", columns=["date"], aliases=["day"], user_groups=["manager", "employee"]),
|
|
29
|
+
po.SelectParameterOption("month", "Month", columns=["month"], user_groups=["manager", "employee"]),
|
|
30
|
+
po.SelectParameterOption("cat", "Category", columns=["category"], user_groups=["manager", "employee"]),
|
|
31
|
+
po.SelectParameterOption("subcat", "Subcategory", columns=["category", "subcategory"], user_groups=["manager", "employee"]),
|
|
27
32
|
]
|
|
28
33
|
p.SingleSelectParameter.CreateWithOptions(
|
|
29
34
|
"group_by", "Group By", group_by_options, description="Dimension(s) to aggregate by", user_attribute=user_attribute
|
|
@@ -31,7 +36,7 @@ def main(sqrl: ParametersArgs) -> None:
|
|
|
31
36
|
|
|
32
37
|
## Example of creating NumberParameter with options
|
|
33
38
|
parent = "group_by"
|
|
34
|
-
limit_options = [po.NumberParameterOption(0, 1000, increment=10, default_value=1000, parent_option_ids="
|
|
39
|
+
limit_options = [po.NumberParameterOption(0, 1000, increment=10, default_value=1000, parent_option_ids="trans")]
|
|
35
40
|
p.NumberParameter.CreateWithOptions(
|
|
36
41
|
"limit", "Max Number of Rows", limit_options, parent_name=parent, description="Maximum number of rows to return"
|
|
37
42
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from typing import Literal
|
|
2
|
-
from squirrels import
|
|
2
|
+
from squirrels import types as t
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class User(BaseUser):
|
|
5
|
+
class User(t.BaseUser):
|
|
6
6
|
"""
|
|
7
7
|
Extend the BaseUser class with custom attributes. The attributes defined here will be added as columns to the users table.
|
|
8
8
|
- Only the following types are supported: [str, int, float, bool, typing.Literal]
|
squirrels/_parameter_configs.py
CHANGED
|
@@ -9,13 +9,13 @@ from fastapi import Query
|
|
|
9
9
|
from pydantic.fields import Field
|
|
10
10
|
import polars as pl, re
|
|
11
11
|
|
|
12
|
-
from . import
|
|
12
|
+
from . import _data_sources as d, _parameter_options as po, _parameters as p, _utils as u, _constants as c
|
|
13
13
|
from ._exceptions import InvalidInputError
|
|
14
14
|
from ._auth import BaseUser
|
|
15
15
|
from ._connection_set import ConnectionSet
|
|
16
16
|
from ._seeds import Seeds
|
|
17
17
|
|
|
18
|
-
ParamOptionType = TypeVar("ParamOptionType", bound=
|
|
18
|
+
ParamOptionType = TypeVar("ParamOptionType", bound=po.ParameterOption)
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
@dataclass
|
|
@@ -129,7 +129,7 @@ class ParameterConfig(Generic[ParamOptionType], ParameterConfigBase):
|
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
@dataclass
|
|
132
|
-
class SelectionParameterConfig(ParameterConfig[
|
|
132
|
+
class SelectionParameterConfig(ParameterConfig[po.SelectParameterOption]):
|
|
133
133
|
"""
|
|
134
134
|
Abstract class for select parameter classes (single-select, multi-select, etc)
|
|
135
135
|
"""
|
|
@@ -138,7 +138,7 @@ class SelectionParameterConfig(ParameterConfig[_po.SelectParameterOption]):
|
|
|
138
138
|
|
|
139
139
|
@abstractmethod
|
|
140
140
|
def __init__(
|
|
141
|
-
self, name: str, label: str, all_options: Sequence[
|
|
141
|
+
self, name: str, label: str, all_options: Sequence[po.SelectParameterOption | dict], *,
|
|
142
142
|
description: str = "", user_attribute: str | None = None, parent_name: str | None = None
|
|
143
143
|
) -> None:
|
|
144
144
|
super().__init__(name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name)
|
|
@@ -147,16 +147,16 @@ class SelectionParameterConfig(ParameterConfig[_po.SelectParameterOption]):
|
|
|
147
147
|
|
|
148
148
|
@staticmethod
|
|
149
149
|
def ParameterOption(*args, **kwargs):
|
|
150
|
-
return
|
|
150
|
+
return po.SelectParameterOption(*args, **kwargs)
|
|
151
151
|
|
|
152
152
|
def _add_child_mutate(self, child: ParameterConfigBase):
|
|
153
153
|
self.children[child.name] = child
|
|
154
154
|
self.trigger_refresh = True
|
|
155
155
|
|
|
156
|
-
def _get_options(self, user: BaseUser | None, parent_param: p._SelectionParameter | None) -> Sequence[
|
|
156
|
+
def _get_options(self, user: BaseUser | None, parent_param: p._SelectionParameter | None) -> Sequence[po.SelectParameterOption]:
|
|
157
157
|
return tuple(self._get_options_iterator(self.all_options, user, parent_param))
|
|
158
158
|
|
|
159
|
-
def _get_default_ids_iterator(self, options: Sequence[
|
|
159
|
+
def _get_default_ids_iterator(self, options: Sequence[po.SelectParameterOption]) -> Iterator[str]:
|
|
160
160
|
return (x._identifier for x in options if x._is_default)
|
|
161
161
|
|
|
162
162
|
def copy(self) -> Self:
|
|
@@ -175,7 +175,7 @@ class SingleSelectParameterConfig(SelectionParameterConfig):
|
|
|
175
175
|
"""
|
|
176
176
|
|
|
177
177
|
def __init__(
|
|
178
|
-
self, name: str, label: str, all_options: Sequence[
|
|
178
|
+
self, name: str, label: str, all_options: Sequence[po.SelectParameterOption | dict], *, description: str = "",
|
|
179
179
|
user_attribute: str | None = None, parent_name: str | None = None
|
|
180
180
|
) -> None:
|
|
181
181
|
super().__init__(name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name)
|
|
@@ -217,7 +217,7 @@ class MultiSelectParameterConfig(SelectionParameterConfig):
|
|
|
217
217
|
none_is_all: bool = field(default=True, kw_only=True)
|
|
218
218
|
|
|
219
219
|
def __init__(
|
|
220
|
-
self, name: str, label: str, all_options: Sequence[
|
|
220
|
+
self, name: str, label: str, all_options: Sequence[po.SelectParameterOption | dict], *, description: str = "",
|
|
221
221
|
show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True,
|
|
222
222
|
user_attribute: str | None = None, parent_name: str | None = None
|
|
223
223
|
) -> None:
|
|
@@ -268,14 +268,14 @@ class _DateTypeParameterConfig(ParameterConfig[ParamOptionType]):
|
|
|
268
268
|
|
|
269
269
|
|
|
270
270
|
@dataclass
|
|
271
|
-
class DateParameterConfig(_DateTypeParameterConfig[
|
|
271
|
+
class DateParameterConfig(_DateTypeParameterConfig[po.DateParameterOption]):
|
|
272
272
|
"""
|
|
273
273
|
Class to define configurations for date parameter widgets.
|
|
274
274
|
"""
|
|
275
|
-
_all_options: Sequence[
|
|
275
|
+
_all_options: Sequence[po.DateParameterOption] = field(repr=False)
|
|
276
276
|
|
|
277
277
|
def __init__(
|
|
278
|
-
self, name: str, label: str, all_options: Sequence[
|
|
278
|
+
self, name: str, label: str, all_options: Sequence[po.DateParameterOption | dict], *,
|
|
279
279
|
description: str = "", user_attribute: str | None = None, parent_name: str | None = None
|
|
280
280
|
) -> None:
|
|
281
281
|
super().__init__(name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name)
|
|
@@ -286,7 +286,7 @@ class DateParameterConfig(_DateTypeParameterConfig[_po.DateParameterOption]):
|
|
|
286
286
|
|
|
287
287
|
@staticmethod
|
|
288
288
|
def ParameterOption(*args, **kwargs):
|
|
289
|
-
return
|
|
289
|
+
return po.DateParameterOption(*args, **kwargs)
|
|
290
290
|
|
|
291
291
|
@staticmethod
|
|
292
292
|
def DataSource(*args, **kwargs):
|
|
@@ -295,7 +295,7 @@ class DateParameterConfig(_DateTypeParameterConfig[_po.DateParameterOption]):
|
|
|
295
295
|
def with_selection(
|
|
296
296
|
self, selection: str | None, user: BaseUser | None, parent_param: p._SelectionParameter | None
|
|
297
297
|
) -> p.DateParameter:
|
|
298
|
-
curr_option:
|
|
298
|
+
curr_option: po.DateParameterOption | None = next(self._get_options_iterator(self.all_options, user, parent_param), None)
|
|
299
299
|
selected_date = curr_option._default_date if selection is None and curr_option is not None else selection
|
|
300
300
|
return p.DateParameter(self, curr_option, selected_date)
|
|
301
301
|
|
|
@@ -307,14 +307,14 @@ class DateParameterConfig(_DateTypeParameterConfig[_po.DateParameterOption]):
|
|
|
307
307
|
|
|
308
308
|
|
|
309
309
|
@dataclass
|
|
310
|
-
class DateRangeParameterConfig(_DateTypeParameterConfig[
|
|
310
|
+
class DateRangeParameterConfig(_DateTypeParameterConfig[po.DateRangeParameterOption]):
|
|
311
311
|
"""
|
|
312
312
|
Class to define configurations for date range parameter widgets.
|
|
313
313
|
"""
|
|
314
|
-
_all_options: Sequence[
|
|
314
|
+
_all_options: Sequence[po.DateRangeParameterOption] = field(repr=False)
|
|
315
315
|
|
|
316
316
|
def __init__(
|
|
317
|
-
self, name: str, label: str, all_options: Sequence[
|
|
317
|
+
self, name: str, label: str, all_options: Sequence[po.DateRangeParameterOption | dict], *,
|
|
318
318
|
description: str = "", user_attribute: str | None = None, parent_name: str | None = None
|
|
319
319
|
) -> None:
|
|
320
320
|
super().__init__(name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name)
|
|
@@ -325,7 +325,7 @@ class DateRangeParameterConfig(_DateTypeParameterConfig[_po.DateRangeParameterOp
|
|
|
325
325
|
|
|
326
326
|
@staticmethod
|
|
327
327
|
def ParameterOption(*args, **kwargs):
|
|
328
|
-
return
|
|
328
|
+
return po.DateRangeParameterOption(*args, **kwargs)
|
|
329
329
|
|
|
330
330
|
@staticmethod
|
|
331
331
|
def DataSource(*args, **kwargs):
|
|
@@ -334,7 +334,7 @@ class DateRangeParameterConfig(_DateTypeParameterConfig[_po.DateRangeParameterOp
|
|
|
334
334
|
def with_selection(
|
|
335
335
|
self, selection: str | None, user: BaseUser | None, parent_param: p._SelectionParameter | None
|
|
336
336
|
) -> p.DateRangeParameter:
|
|
337
|
-
curr_option:
|
|
337
|
+
curr_option: po.DateRangeParameterOption | None = next(self._get_options_iterator(self.all_options, user, parent_param), None)
|
|
338
338
|
if selection is None:
|
|
339
339
|
if curr_option is not None:
|
|
340
340
|
selected_start_date = curr_option._default_start_date
|
|
@@ -370,14 +370,14 @@ class _NumericParameterConfig(ParameterConfig[ParamOptionType]):
|
|
|
370
370
|
|
|
371
371
|
|
|
372
372
|
@dataclass
|
|
373
|
-
class NumberParameterConfig(_NumericParameterConfig[
|
|
373
|
+
class NumberParameterConfig(_NumericParameterConfig[po.NumberParameterOption]):
|
|
374
374
|
"""
|
|
375
375
|
Class to define configurations for number parameter widgets.
|
|
376
376
|
"""
|
|
377
|
-
_all_options: Sequence[
|
|
377
|
+
_all_options: Sequence[po.NumberParameterOption] = field(repr=False)
|
|
378
378
|
|
|
379
379
|
def __init__(
|
|
380
|
-
self, name: str, label: str, all_options: Sequence[
|
|
380
|
+
self, name: str, label: str, all_options: Sequence[po.NumberParameterOption | dict], *,
|
|
381
381
|
description: str = "", user_attribute: str | None = None, parent_name: str | None = None
|
|
382
382
|
) -> None:
|
|
383
383
|
super().__init__(name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name)
|
|
@@ -388,7 +388,7 @@ class NumberParameterConfig(_NumericParameterConfig[_po.NumberParameterOption]):
|
|
|
388
388
|
|
|
389
389
|
@staticmethod
|
|
390
390
|
def ParameterOption(*args, **kwargs):
|
|
391
|
-
return
|
|
391
|
+
return po.NumberParameterOption(*args, **kwargs)
|
|
392
392
|
|
|
393
393
|
@staticmethod
|
|
394
394
|
def DataSource(*args, **kwargs):
|
|
@@ -397,7 +397,7 @@ class NumberParameterConfig(_NumericParameterConfig[_po.NumberParameterOption]):
|
|
|
397
397
|
def with_selection(
|
|
398
398
|
self, selection: str | None, user: BaseUser | None, parent_param: p._SelectionParameter | None
|
|
399
399
|
) -> p.NumberParameter:
|
|
400
|
-
curr_option:
|
|
400
|
+
curr_option: po.NumberParameterOption | None = next(self._get_options_iterator(self.all_options, user, parent_param), None)
|
|
401
401
|
selected_value = curr_option._default_value if selection is None and curr_option is not None else selection
|
|
402
402
|
return p.NumberParameter(self, curr_option, selected_value)
|
|
403
403
|
|
|
@@ -409,14 +409,14 @@ class NumberParameterConfig(_NumericParameterConfig[_po.NumberParameterOption]):
|
|
|
409
409
|
|
|
410
410
|
|
|
411
411
|
@dataclass
|
|
412
|
-
class NumberRangeParameterConfig(_NumericParameterConfig[
|
|
412
|
+
class NumberRangeParameterConfig(_NumericParameterConfig[po.NumberRangeParameterOption]):
|
|
413
413
|
"""
|
|
414
414
|
Class to define configurations for number range parameter widgets.
|
|
415
415
|
"""
|
|
416
|
-
_all_options: Sequence[
|
|
416
|
+
_all_options: Sequence[po.NumberRangeParameterOption] = field(repr=False)
|
|
417
417
|
|
|
418
418
|
def __init__(
|
|
419
|
-
self, name: str, label: str, all_options: Sequence[
|
|
419
|
+
self, name: str, label: str, all_options: Sequence[po.NumberRangeParameterOption | dict], *,
|
|
420
420
|
description: str = "", user_attribute: str | None = None, parent_name: str | None = None
|
|
421
421
|
) -> None:
|
|
422
422
|
super().__init__(name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name)
|
|
@@ -427,7 +427,7 @@ class NumberRangeParameterConfig(_NumericParameterConfig[_po.NumberRangeParamete
|
|
|
427
427
|
|
|
428
428
|
@staticmethod
|
|
429
429
|
def ParameterOption(*args, **kwargs):
|
|
430
|
-
return
|
|
430
|
+
return po.NumberRangeParameterOption(*args, **kwargs)
|
|
431
431
|
|
|
432
432
|
@staticmethod
|
|
433
433
|
def DataSource(*args, **kwargs):
|
|
@@ -436,7 +436,7 @@ class NumberRangeParameterConfig(_NumericParameterConfig[_po.NumberRangeParamete
|
|
|
436
436
|
def with_selection(
|
|
437
437
|
self, selection: str | None, user: BaseUser | None, parent_param: p._SelectionParameter | None
|
|
438
438
|
) -> p.NumberRangeParameter:
|
|
439
|
-
curr_option:
|
|
439
|
+
curr_option: po.NumberRangeParameterOption | None = next(self._get_options_iterator(self.all_options, user, parent_param), None)
|
|
440
440
|
if selection is None:
|
|
441
441
|
if curr_option is not None:
|
|
442
442
|
selected_lower_value = curr_option._default_lower_value
|
|
@@ -458,15 +458,15 @@ class NumberRangeParameterConfig(_NumericParameterConfig[_po.NumberRangeParamete
|
|
|
458
458
|
|
|
459
459
|
|
|
460
460
|
@dataclass
|
|
461
|
-
class TextParameterConfig(ParameterConfig[
|
|
461
|
+
class TextParameterConfig(ParameterConfig[po.TextParameterOption]):
|
|
462
462
|
"""
|
|
463
463
|
Class to define configurations for text parameter widgets.
|
|
464
464
|
"""
|
|
465
|
-
_all_options: Sequence[
|
|
465
|
+
_all_options: Sequence[po.TextParameterOption] = field(repr=False)
|
|
466
466
|
input_type: str
|
|
467
467
|
|
|
468
468
|
def __init__(
|
|
469
|
-
self, name: str, label: str, all_options: Sequence[
|
|
469
|
+
self, name: str, label: str, all_options: Sequence[po.TextParameterOption | dict], *, description: str = "",
|
|
470
470
|
input_type: str = "text", user_attribute: str | None = None, parent_name: str | None = None
|
|
471
471
|
) -> None:
|
|
472
472
|
super().__init__(name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name)
|
|
@@ -517,7 +517,7 @@ class TextParameterConfig(ParameterConfig[_po.TextParameterOption]):
|
|
|
517
517
|
|
|
518
518
|
@staticmethod
|
|
519
519
|
def ParameterOption(*args, **kwargs):
|
|
520
|
-
return
|
|
520
|
+
return po.TextParameterOption(*args, **kwargs)
|
|
521
521
|
|
|
522
522
|
@staticmethod
|
|
523
523
|
def DataSource(*args, **kwargs):
|
|
@@ -526,7 +526,7 @@ class TextParameterConfig(ParameterConfig[_po.TextParameterOption]):
|
|
|
526
526
|
def with_selection(
|
|
527
527
|
self, selection: str | None, user: BaseUser | None, parent_param: p._SelectionParameter | None
|
|
528
528
|
) -> p.TextParameter:
|
|
529
|
-
curr_option:
|
|
529
|
+
curr_option: po.TextParameterOption | None = next(self._get_options_iterator(self.all_options, user, parent_param), None)
|
|
530
530
|
entered_text = curr_option._default_text if selection is None and curr_option is not None else selection
|
|
531
531
|
return p.TextParameter(self, curr_option, entered_text)
|
|
532
532
|
|