squirrels 0.3.3__py3-none-any.whl → 0.4.0__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.
Potentially problematic release.
This version of squirrels might be problematic. Click here for more details.
- squirrels/__init__.py +7 -3
- squirrels/_api_response_models.py +96 -72
- squirrels/_api_server.py +375 -201
- squirrels/_authenticator.py +23 -22
- squirrels/_command_line.py +70 -46
- squirrels/_connection_set.py +23 -25
- squirrels/_constants.py +29 -78
- squirrels/_dashboards_io.py +61 -0
- squirrels/_environcfg.py +53 -50
- squirrels/_initializer.py +184 -141
- squirrels/_manifest.py +168 -195
- squirrels/_models.py +159 -292
- squirrels/_package_loader.py +7 -8
- squirrels/_parameter_configs.py +173 -141
- squirrels/_parameter_sets.py +49 -38
- squirrels/_py_module.py +7 -7
- squirrels/_seeds.py +13 -12
- squirrels/_utils.py +114 -54
- squirrels/_version.py +1 -1
- squirrels/arguments/init_time_args.py +16 -10
- squirrels/arguments/run_time_args.py +89 -24
- squirrels/dashboards.py +82 -0
- squirrels/data_sources.py +212 -232
- squirrels/dateutils.py +29 -26
- squirrels/package_data/assets/index.css +1 -1
- squirrels/package_data/assets/index.js +27 -18
- squirrels/package_data/base_project/.gitignore +2 -2
- squirrels/package_data/base_project/connections.yml +1 -1
- squirrels/package_data/base_project/dashboards/dashboard_example.py +32 -0
- squirrels/package_data/base_project/dashboards.yml +10 -0
- squirrels/package_data/base_project/docker/.dockerignore +9 -4
- squirrels/package_data/base_project/docker/Dockerfile +7 -6
- squirrels/package_data/base_project/docker/compose.yml +1 -1
- squirrels/package_data/base_project/env.yml +2 -2
- squirrels/package_data/base_project/models/dbviews/{database_view1.py → dbview_example.py} +2 -1
- squirrels/package_data/base_project/models/dbviews/{database_view1.sql → dbview_example.sql} +3 -2
- squirrels/package_data/base_project/models/federates/{dataset_example.py → federate_example.py} +6 -6
- squirrels/package_data/base_project/models/federates/{dataset_example.sql → federate_example.sql} +1 -1
- squirrels/package_data/base_project/parameters.yml +6 -4
- squirrels/package_data/base_project/pyconfigs/auth.py +1 -1
- squirrels/package_data/base_project/pyconfigs/connections.py +1 -1
- squirrels/package_data/base_project/pyconfigs/context.py +38 -10
- squirrels/package_data/base_project/pyconfigs/parameters.py +15 -7
- squirrels/package_data/base_project/squirrels.yml.j2 +14 -7
- squirrels/package_data/templates/index.html +3 -3
- squirrels/parameter_options.py +103 -106
- squirrels/parameters.py +347 -195
- squirrels/project.py +378 -0
- squirrels/user_base.py +14 -6
- {squirrels-0.3.3.dist-info → squirrels-0.4.0.dist-info}/METADATA +9 -21
- squirrels-0.4.0.dist-info/RECORD +60 -0
- squirrels/_timer.py +0 -23
- squirrels-0.3.3.dist-info/RECORD +0 -56
- {squirrels-0.3.3.dist-info → squirrels-0.4.0.dist-info}/LICENSE +0 -0
- {squirrels-0.3.3.dist-info → squirrels-0.4.0.dist-info}/WHEEL +0 -0
- {squirrels-0.3.3.dist-info → squirrels-0.4.0.dist-info}/entry_points.txt +0 -0
squirrels/parameter_options.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
from typing import
|
|
2
|
-
from dataclasses import dataclass
|
|
1
|
+
from typing import TypeVar, Iterable, Any
|
|
2
|
+
from dataclasses import dataclass
|
|
3
3
|
from decimal import Decimal, InvalidOperation as InvalidDecimalConversion
|
|
4
4
|
from datetime import datetime, date
|
|
5
5
|
from abc import ABCMeta, abstractmethod
|
|
6
|
-
import re
|
|
7
6
|
|
|
8
7
|
from ._utils import ConfigurationError
|
|
9
8
|
|
|
10
|
-
Number =
|
|
9
|
+
Number = Decimal | int | float | str
|
|
10
|
+
Comparables = TypeVar("Comparables", Decimal, date)
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
@dataclass
|
|
@@ -15,26 +15,25 @@ class ParameterOption(metaclass=ABCMeta):
|
|
|
15
15
|
"""
|
|
16
16
|
Abstract class for parameter options
|
|
17
17
|
"""
|
|
18
|
-
_user_groups:
|
|
19
|
-
_parent_option_ids:
|
|
18
|
+
_user_groups: frozenset[Any]
|
|
19
|
+
_parent_option_ids: frozenset[str]
|
|
20
20
|
|
|
21
21
|
@abstractmethod
|
|
22
22
|
def __init__(
|
|
23
|
-
self, *, user_groups:
|
|
23
|
+
self, *, user_groups: Iterable[Any] | str = frozenset(), parent_option_ids: Iterable[str] | str = frozenset(), **kwargs
|
|
24
24
|
) -> None:
|
|
25
25
|
self._user_groups = frozenset({user_groups} if isinstance(user_groups, str) else user_groups)
|
|
26
26
|
self._parent_option_ids = frozenset({parent_option_ids} if isinstance(parent_option_ids, str) else parent_option_ids)
|
|
27
27
|
|
|
28
|
-
def _validate_lower_upper_values(self, lower_label: str, lower_value:
|
|
29
|
-
upper_label: str, upper_value: Union[Decimal, date]):
|
|
28
|
+
def _validate_lower_upper_values(self, lower_label: str, lower_value: Comparables, upper_label: str, upper_value: Comparables):
|
|
30
29
|
if lower_value > upper_value:
|
|
31
30
|
raise ConfigurationError(f'The {lower_label} "{lower_value}" must be less than or equal to the {upper_label} "{upper_value}"')
|
|
32
31
|
|
|
33
|
-
def _is_valid(self, user_group: Any, selected_parent_option_ids:
|
|
32
|
+
def _is_valid(self, user_group: Any, selected_parent_option_ids: Iterable[str] | None) -> bool:
|
|
34
33
|
"""
|
|
35
34
|
Checks if this option is valid given the selected parent options and user group of user if applicable.
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
Arguments:
|
|
38
37
|
user_group: The value of the user's "user group attribute". Only None when "user_attribute" is not specified
|
|
39
38
|
for the Parameter factory. Note that when user is None but "user_attribute" is specified, an error is thrown
|
|
40
39
|
selected_parent_option_ids: List of selected option ids from the parent parameter. Only None when the Parameter
|
|
@@ -56,29 +55,26 @@ class ParameterOption(metaclass=ABCMeta):
|
|
|
56
55
|
class SelectParameterOption(ParameterOption):
|
|
57
56
|
"""
|
|
58
57
|
Parameter option for a select parameter
|
|
59
|
-
|
|
60
|
-
Attributes:
|
|
61
|
-
identifier: Unique identifier for this option that never changes over time
|
|
62
|
-
label: Human readable label that gets shown as a dropdown option
|
|
63
|
-
is_default: True if this is a default option, False otherwise
|
|
64
|
-
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
65
|
-
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
66
|
-
custom_fields: Dictionary to associate custom attributes to the parameter option
|
|
67
58
|
"""
|
|
68
59
|
_identifier: str
|
|
69
60
|
_label: str
|
|
70
|
-
_is_default: bool
|
|
71
|
-
custom_fields: dict[str, Any]
|
|
61
|
+
_is_default: bool
|
|
62
|
+
custom_fields: dict[str, Any]
|
|
72
63
|
|
|
73
64
|
def __init__(
|
|
74
|
-
self, id: str, label: str, *, is_default: bool = False, user_groups:
|
|
75
|
-
parent_option_ids:
|
|
65
|
+
self, id: str, label: str, *, is_default: bool = False, user_groups: Iterable[Any] | str = frozenset(),
|
|
66
|
+
parent_option_ids: Iterable[str] | str = frozenset(), custom_fields: dict[str, Any] = {}, **kwargs
|
|
76
67
|
) -> None:
|
|
77
68
|
"""
|
|
78
69
|
Constructor for SelectParameterOption
|
|
79
70
|
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
Arguments:
|
|
72
|
+
identifier: Unique identifier for this option that never changes over time
|
|
73
|
+
label: Human readable label that gets shown as a dropdown option
|
|
74
|
+
is_default: True if this is a default option, False otherwise
|
|
75
|
+
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
76
|
+
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
77
|
+
custom_fields: Dictionary to associate custom attributes to the parameter option
|
|
82
78
|
**kwargs: Any additional keyword arguments specified (except the ones above) gets included into custom_fields as well
|
|
83
79
|
"""
|
|
84
80
|
super().__init__(user_groups=user_groups, parent_option_ids=parent_option_ids)
|
|
@@ -89,11 +85,11 @@ class SelectParameterOption(ParameterOption):
|
|
|
89
85
|
**kwargs, **custom_fields, **self._to_json_dict()
|
|
90
86
|
}
|
|
91
87
|
|
|
92
|
-
def get_custom_field(self, field: str, *, default_field:
|
|
88
|
+
def get_custom_field(self, field: str, *, default_field: str | None = None, default: Any = None, **kwargs) -> Any:
|
|
93
89
|
"""
|
|
94
90
|
Get field value from the custom_fields attribute
|
|
95
91
|
|
|
96
|
-
|
|
92
|
+
Arguments:
|
|
97
93
|
field: The key to use to fetch the custom field from "custom_fields"
|
|
98
94
|
default_field: If value at "field" key does not exist in "custom_fields", then this is used instead as the field (if not None)
|
|
99
95
|
default: If value at "field" or "default_field" (if not None) key does not exist in "custom_fields", then this value
|
|
@@ -124,47 +120,62 @@ class _DateTypeParameterOption(ParameterOption):
|
|
|
124
120
|
"""
|
|
125
121
|
Abstract class (or type) for date type parameter options
|
|
126
122
|
"""
|
|
127
|
-
|
|
123
|
+
_min_date: date | None
|
|
124
|
+
_max_date: date | None
|
|
125
|
+
_date_format: str
|
|
128
126
|
|
|
129
127
|
@abstractmethod
|
|
130
128
|
def __init__(
|
|
131
|
-
self, *,
|
|
132
|
-
|
|
129
|
+
self, *, min_date: str | date | None = None, max_date: str | date | None = None, date_format: str = '%Y-%m-%d',
|
|
130
|
+
user_groups: Iterable[Any] | str = frozenset(), parent_option_ids: Iterable[str] | str = frozenset(), **kwargs
|
|
133
131
|
) -> None:
|
|
134
132
|
super().__init__(user_groups=user_groups, parent_option_ids=parent_option_ids)
|
|
135
133
|
self._date_format = date_format
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
self._min_date, self._max_date = None, None # preset for using _validate_date()
|
|
135
|
+
self._min_date = self._validate_date(min_date) if min_date is not None else None
|
|
136
|
+
self._max_date = self._validate_date(max_date) if max_date is not None else None
|
|
137
|
+
if self._min_date is not None and self._max_date is not None:
|
|
138
|
+
self._validate_lower_upper_values("min_date", self._min_date, "max_date", self._max_date)
|
|
139
|
+
|
|
140
|
+
def _validate_date(self, date_str: str | date) -> date:
|
|
138
141
|
try:
|
|
139
|
-
|
|
142
|
+
date_obj = datetime.strptime(date_str, self._date_format).date() if isinstance(date_str, str) else date_str
|
|
140
143
|
except ValueError as e:
|
|
141
144
|
raise ConfigurationError(f'Invalid format for date "{date_str}".') from e
|
|
145
|
+
|
|
146
|
+
if self._min_date is not None and date_obj < self._min_date:
|
|
147
|
+
raise ConfigurationError(f'The provided date "{date_obj}" is less than the min date "{self._min_date}"')
|
|
148
|
+
if self._max_date is not None and date_obj > self._max_date:
|
|
149
|
+
raise ConfigurationError(f'The provided date "{date_obj}" is greater than the max date "{self._max_date}"')
|
|
150
|
+
|
|
151
|
+
return date_obj
|
|
142
152
|
|
|
143
153
|
|
|
144
154
|
@dataclass
|
|
145
155
|
class DateParameterOption(_DateTypeParameterOption):
|
|
146
156
|
"""
|
|
147
157
|
Parameter option for default dates if it varies based on selection of another parameter
|
|
148
|
-
|
|
149
|
-
Attributes:
|
|
150
|
-
default_date: Default date for this option
|
|
151
|
-
date_format: Format of the default date, default is '%Y-%m-%d'
|
|
152
|
-
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
153
|
-
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
154
158
|
"""
|
|
155
159
|
_default_date: date
|
|
156
160
|
|
|
157
161
|
def __init__(
|
|
158
|
-
self, default_date:
|
|
159
|
-
|
|
162
|
+
self, default_date: str | date, *, min_date: str | date | None = None, max_date: str | date | None = None, date_format: str = '%Y-%m-%d',
|
|
163
|
+
user_groups: Iterable[Any] | str = frozenset(), parent_option_ids: Iterable[str] | str = frozenset(), **kwargs
|
|
160
164
|
) -> None:
|
|
161
165
|
"""
|
|
162
166
|
Constructor for DateParameterOption
|
|
163
167
|
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
Arguments:
|
|
169
|
+
default_date: Default date for this option
|
|
170
|
+
min_date: Minimum date for this option
|
|
171
|
+
max_date: Maximum date for this option
|
|
172
|
+
date_format: Format of the default date, default is '%Y-%m-%d'
|
|
173
|
+
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
174
|
+
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
166
175
|
"""
|
|
167
|
-
super().__init__(
|
|
176
|
+
super().__init__(
|
|
177
|
+
date_format=date_format, min_date=min_date, max_date=max_date, user_groups=user_groups, parent_option_ids=parent_option_ids
|
|
178
|
+
)
|
|
168
179
|
self._default_date = self._validate_date(default_date)
|
|
169
180
|
|
|
170
181
|
|
|
@@ -172,28 +183,30 @@ class DateParameterOption(_DateTypeParameterOption):
|
|
|
172
183
|
class DateRangeParameterOption(_DateTypeParameterOption):
|
|
173
184
|
"""
|
|
174
185
|
Parameter option for default dates if it varies based on selection of another parameter
|
|
175
|
-
|
|
176
|
-
Attributes:
|
|
177
|
-
default_start_date: Default start date for this option
|
|
178
|
-
default_end_date: Default end date for this option
|
|
179
|
-
date_format: Format of the default date, default is '%Y-%m-%d'
|
|
180
|
-
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
181
|
-
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
182
186
|
"""
|
|
183
187
|
_default_start_date: date
|
|
184
188
|
_default_end_date: date
|
|
185
189
|
|
|
186
190
|
def __init__(
|
|
187
|
-
self, default_start_date:
|
|
188
|
-
|
|
191
|
+
self, default_start_date: str | date, default_end_date: str | date, *, min_date: str | date | None = None,
|
|
192
|
+
max_date: str | date | None = None, date_format: str = '%Y-%m-%d', user_groups: Iterable[Any] | str = frozenset(),
|
|
193
|
+
parent_option_ids: Iterable[str] | str = frozenset(), **kwargs
|
|
189
194
|
) -> None:
|
|
190
195
|
"""
|
|
191
196
|
Constructor for DateRangeParameterOption
|
|
192
197
|
|
|
193
|
-
|
|
194
|
-
|
|
198
|
+
Arguments:
|
|
199
|
+
default_start_date: Default start date for this option
|
|
200
|
+
default_end_date: Default end date for this option
|
|
201
|
+
min_date: Minimum date for this option
|
|
202
|
+
max_date: Maximum date for this option
|
|
203
|
+
date_format: Format of the default date, default is '%Y-%m-%d'
|
|
204
|
+
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
205
|
+
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
195
206
|
"""
|
|
196
|
-
super().__init__(
|
|
207
|
+
super().__init__(
|
|
208
|
+
date_format=date_format, min_date=min_date, max_date=max_date, user_groups=user_groups, parent_option_ids=parent_option_ids
|
|
209
|
+
)
|
|
197
210
|
self._default_start_date = self._validate_date(default_start_date)
|
|
198
211
|
self._default_end_date = self._validate_date(default_end_date)
|
|
199
212
|
self._validate_lower_upper_values("default_start_date", self._default_start_date, "default_end_date", self._default_end_date)
|
|
@@ -206,12 +219,12 @@ class _NumericParameterOption(ParameterOption):
|
|
|
206
219
|
"""
|
|
207
220
|
_min_value: Decimal
|
|
208
221
|
_max_value: Decimal
|
|
209
|
-
_increment: Decimal
|
|
222
|
+
_increment: Decimal
|
|
210
223
|
|
|
211
224
|
@abstractmethod
|
|
212
225
|
def __init__(
|
|
213
|
-
self, min_value: Number, max_value: Number, *, increment: Number = 1, user_groups:
|
|
214
|
-
parent_option_ids:
|
|
226
|
+
self, min_value: Number, max_value: Number, *, increment: Number = 1, user_groups: Iterable[Any] | str = frozenset(),
|
|
227
|
+
parent_option_ids: Iterable[str] | str = frozenset(), **kwargs
|
|
215
228
|
) -> None:
|
|
216
229
|
super().__init__(user_groups=user_groups, parent_option_ids=parent_option_ids)
|
|
217
230
|
try:
|
|
@@ -247,41 +260,31 @@ class _NumericParameterOption(ParameterOption):
|
|
|
247
260
|
raise ConfigurationError(f'The difference between selected value "{value}" and lower value ' +
|
|
248
261
|
f'"{self._min_value}" must be a multiple of increment "{self._increment}".')
|
|
249
262
|
return value
|
|
250
|
-
|
|
251
|
-
def _to_json_dict(self):
|
|
252
|
-
return {
|
|
253
|
-
"min_value": float(self._min_value),
|
|
254
|
-
"max_value": float(self._max_value),
|
|
255
|
-
"increment": float(self._increment)
|
|
256
|
-
}
|
|
257
263
|
|
|
258
264
|
|
|
259
265
|
@dataclass
|
|
260
266
|
class NumberParameterOption(_NumericParameterOption):
|
|
261
267
|
"""
|
|
262
268
|
Parameter option for default numbers if it varies based on selection of another parameter
|
|
263
|
-
|
|
264
|
-
Attributes:
|
|
265
|
-
min_value: Minimum selectable value
|
|
266
|
-
max_value: Maximum selectable value
|
|
267
|
-
increment: Increment of selectable values, and must fit evenly between min_value and max_value
|
|
268
|
-
default_value: Default value for this option, and must be selectable based on min_value, max_value, and increment
|
|
269
|
-
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
270
|
-
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
271
269
|
"""
|
|
272
|
-
_default_value: Decimal
|
|
270
|
+
_default_value: Decimal
|
|
273
271
|
|
|
274
272
|
def __init__(
|
|
275
|
-
self, min_value: Number, max_value: Number, *, increment: Number = 1, default_value:
|
|
276
|
-
user_groups:
|
|
273
|
+
self, min_value: Number, max_value: Number, *, increment: Number = 1, default_value: Number | None = None,
|
|
274
|
+
user_groups: Iterable[Any] | str = frozenset(), parent_option_ids: Iterable[str] | str = frozenset(), **kwargs
|
|
277
275
|
) -> None:
|
|
278
276
|
"""
|
|
279
277
|
Constructor for NumberParameterOption
|
|
280
278
|
|
|
281
279
|
* Note that the "Number" type denotes an int, a Decimal (from decimal module), or a string that can be parsed to Decimal
|
|
282
280
|
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
Arguments:
|
|
282
|
+
min_value: Minimum selectable value
|
|
283
|
+
max_value: Maximum selectable value
|
|
284
|
+
increment: Increment of selectable values, and must fit evenly between min_value and max_value
|
|
285
|
+
default_value: Default value for this option, and must be selectable based on min_value, max_value, and increment
|
|
286
|
+
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
287
|
+
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
285
288
|
"""
|
|
286
289
|
super().__init__(min_value, max_value, increment=increment, user_groups=user_groups, parent_option_ids=parent_option_ids)
|
|
287
290
|
self._default_value = self._validate_value(default_value) if default_value is not None else self._min_value
|
|
@@ -291,32 +294,29 @@ class NumberParameterOption(_NumericParameterOption):
|
|
|
291
294
|
class NumberRangeParameterOption(_NumericParameterOption):
|
|
292
295
|
"""
|
|
293
296
|
Parameter option for default numeric ranges if it varies based on selection of another parameter
|
|
294
|
-
|
|
295
|
-
Attributes:
|
|
296
|
-
min_value: Minimum selectable value
|
|
297
|
-
max_value: Maximum selectable value
|
|
298
|
-
increment: Increment of selectable values, and must fit evenly between min_value and max_value
|
|
299
|
-
default_lower_value: Default lower value for this option, and must be selectable based on min_value, max_value, and increment
|
|
300
|
-
default_upper_value: Default upper value for this option, and must be selectable based on min_value, max_value, and increment.
|
|
301
|
-
Must also be greater than default_lower_value
|
|
302
|
-
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
303
|
-
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
304
297
|
"""
|
|
305
|
-
_default_lower_value: Decimal
|
|
306
|
-
_default_upper_value: Decimal
|
|
298
|
+
_default_lower_value: Decimal
|
|
299
|
+
_default_upper_value: Decimal
|
|
307
300
|
|
|
308
301
|
def __init__(
|
|
309
|
-
self, min_value: Number, max_value: Number, *, increment: Number = 1, default_lower_value:
|
|
310
|
-
default_upper_value:
|
|
311
|
-
parent_option_ids:
|
|
302
|
+
self, min_value: Number, max_value: Number, *, increment: Number = 1, default_lower_value: Number | None = None,
|
|
303
|
+
default_upper_value: Number | None = None, user_groups: Iterable[Any] | str = frozenset(),
|
|
304
|
+
parent_option_ids: Iterable[str] | str = frozenset(), **kwargs
|
|
312
305
|
) -> None:
|
|
313
306
|
"""
|
|
314
307
|
Constructor for NumberRangeParameterOption
|
|
315
308
|
|
|
316
309
|
* Note that the "Number" type denotes an int, a Decimal (from decimal module), or a string that can be parsed to Decimal
|
|
317
310
|
|
|
318
|
-
|
|
319
|
-
|
|
311
|
+
Arguments:
|
|
312
|
+
min_value: Minimum selectable value
|
|
313
|
+
max_value: Maximum selectable value
|
|
314
|
+
increment: Increment of selectable values, and must fit evenly between min_value and max_value
|
|
315
|
+
default_lower_value: Default lower value for this option, and must be selectable based on min_value, max_value, and increment
|
|
316
|
+
default_upper_value: Default upper value for this option, and must be selectable based on min_value, max_value, and increment.
|
|
317
|
+
Must also be greater than default_lower_value
|
|
318
|
+
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
319
|
+
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
320
320
|
"""
|
|
321
321
|
super().__init__(min_value, max_value, increment=increment, user_groups=user_groups, parent_option_ids=parent_option_ids)
|
|
322
322
|
self._default_lower_value = self._validate_value(default_lower_value) if default_lower_value is not None else self._min_value
|
|
@@ -328,23 +328,20 @@ class NumberRangeParameterOption(_NumericParameterOption):
|
|
|
328
328
|
class TextParameterOption(ParameterOption):
|
|
329
329
|
"""
|
|
330
330
|
Parameter option for default text values if it varies based on selection of another parameter
|
|
331
|
-
|
|
332
|
-
Attributes:
|
|
333
|
-
default_text: Default text for this option
|
|
334
|
-
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
335
|
-
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
336
331
|
"""
|
|
337
|
-
_default_text: str
|
|
332
|
+
_default_text: str
|
|
338
333
|
|
|
339
334
|
def __init__(
|
|
340
|
-
self, *, default_text: str = "", user_groups:
|
|
341
|
-
parent_option_ids:
|
|
335
|
+
self, *, default_text: str = "", user_groups: Iterable[Any] | str = frozenset(),
|
|
336
|
+
parent_option_ids: Iterable[str] | str = frozenset(), **kwargs
|
|
342
337
|
) -> None:
|
|
343
338
|
"""
|
|
344
339
|
Constructor for TextParameterOption
|
|
345
340
|
|
|
346
|
-
|
|
347
|
-
|
|
341
|
+
Arguments:
|
|
342
|
+
default_text: Default text for this option
|
|
343
|
+
user_groups: The user groups this parameter option would show for if "user_attribute" is specified in the Parameter factory
|
|
344
|
+
parent_option_ids: Set of parent option ids this parameter option would show for if "parent" is specified in the Parameter factory
|
|
348
345
|
"""
|
|
349
346
|
super().__init__(user_groups=user_groups, parent_option_ids=parent_option_ids)
|
|
350
347
|
self._default_text = default_text
|