squirrels 0.5.0b3__py3-none-any.whl → 0.6.0.post0__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.
Files changed (93) hide show
  1. squirrels/__init__.py +4 -0
  2. squirrels/_api_routes/__init__.py +5 -0
  3. squirrels/_api_routes/auth.py +337 -0
  4. squirrels/_api_routes/base.py +196 -0
  5. squirrels/_api_routes/dashboards.py +156 -0
  6. squirrels/_api_routes/data_management.py +148 -0
  7. squirrels/_api_routes/datasets.py +220 -0
  8. squirrels/_api_routes/project.py +289 -0
  9. squirrels/_api_server.py +440 -792
  10. squirrels/_arguments/__init__.py +0 -0
  11. squirrels/_arguments/{_init_time_args.py → init_time_args.py} +23 -43
  12. squirrels/_arguments/{_run_time_args.py → run_time_args.py} +32 -68
  13. squirrels/_auth.py +590 -264
  14. squirrels/_command_line.py +130 -58
  15. squirrels/_compile_prompts.py +147 -0
  16. squirrels/_connection_set.py +16 -15
  17. squirrels/_constants.py +36 -11
  18. squirrels/_dashboards.py +179 -0
  19. squirrels/_data_sources.py +40 -34
  20. squirrels/_dataset_types.py +16 -11
  21. squirrels/_env_vars.py +209 -0
  22. squirrels/_exceptions.py +9 -37
  23. squirrels/_http_error_responses.py +52 -0
  24. squirrels/_initializer.py +7 -6
  25. squirrels/_logging.py +121 -0
  26. squirrels/_manifest.py +155 -77
  27. squirrels/_mcp_server.py +578 -0
  28. squirrels/_model_builder.py +11 -55
  29. squirrels/_model_configs.py +5 -5
  30. squirrels/_model_queries.py +1 -1
  31. squirrels/_models.py +276 -143
  32. squirrels/_package_data/base_project/.env +1 -24
  33. squirrels/_package_data/base_project/.env.example +31 -17
  34. squirrels/_package_data/base_project/connections.yml +4 -3
  35. squirrels/_package_data/base_project/dashboards/dashboard_example.py +13 -7
  36. squirrels/_package_data/base_project/dashboards/dashboard_example.yml +6 -6
  37. squirrels/_package_data/base_project/docker/Dockerfile +2 -2
  38. squirrels/_package_data/base_project/docker/compose.yml +1 -1
  39. squirrels/_package_data/base_project/duckdb_init.sql +1 -0
  40. squirrels/_package_data/base_project/models/builds/build_example.py +2 -2
  41. squirrels/_package_data/base_project/models/dbviews/dbview_example.sql +7 -2
  42. squirrels/_package_data/base_project/models/dbviews/dbview_example.yml +16 -10
  43. squirrels/_package_data/base_project/models/federates/federate_example.py +27 -17
  44. squirrels/_package_data/base_project/models/federates/federate_example.sql +3 -7
  45. squirrels/_package_data/base_project/models/federates/federate_example.yml +7 -7
  46. squirrels/_package_data/base_project/models/sources.yml +5 -6
  47. squirrels/_package_data/base_project/parameters.yml +24 -38
  48. squirrels/_package_data/base_project/pyconfigs/connections.py +8 -3
  49. squirrels/_package_data/base_project/pyconfigs/context.py +26 -14
  50. squirrels/_package_data/base_project/pyconfigs/parameters.py +124 -81
  51. squirrels/_package_data/base_project/pyconfigs/user.py +48 -15
  52. squirrels/_package_data/base_project/resources/public/.gitkeep +0 -0
  53. squirrels/_package_data/base_project/seeds/seed_categories.yml +1 -1
  54. squirrels/_package_data/base_project/seeds/seed_subcategories.yml +1 -1
  55. squirrels/_package_data/base_project/squirrels.yml.j2 +21 -31
  56. squirrels/_package_data/templates/login_successful.html +53 -0
  57. squirrels/_package_data/templates/squirrels_studio.html +22 -0
  58. squirrels/_parameter_configs.py +43 -22
  59. squirrels/_parameter_options.py +1 -1
  60. squirrels/_parameter_sets.py +41 -30
  61. squirrels/_parameters.py +560 -123
  62. squirrels/_project.py +487 -277
  63. squirrels/_py_module.py +71 -10
  64. squirrels/_request_context.py +33 -0
  65. squirrels/_schemas/__init__.py +0 -0
  66. squirrels/_schemas/auth_models.py +83 -0
  67. squirrels/_schemas/query_param_models.py +70 -0
  68. squirrels/_schemas/request_models.py +26 -0
  69. squirrels/_schemas/response_models.py +286 -0
  70. squirrels/_seeds.py +52 -13
  71. squirrels/_sources.py +29 -23
  72. squirrels/_utils.py +221 -42
  73. squirrels/_version.py +1 -3
  74. squirrels/arguments.py +7 -2
  75. squirrels/auth.py +4 -0
  76. squirrels/connections.py +2 -0
  77. squirrels/dashboards.py +3 -1
  78. squirrels/data_sources.py +6 -0
  79. squirrels/parameter_options.py +5 -0
  80. squirrels/parameters.py +5 -0
  81. squirrels/types.py +10 -3
  82. squirrels-0.6.0.post0.dist-info/METADATA +148 -0
  83. squirrels-0.6.0.post0.dist-info/RECORD +101 -0
  84. {squirrels-0.5.0b3.dist-info → squirrels-0.6.0.post0.dist-info}/WHEEL +1 -1
  85. squirrels/_api_response_models.py +0 -190
  86. squirrels/_dashboard_types.py +0 -82
  87. squirrels/_dashboards_io.py +0 -79
  88. squirrels-0.5.0b3.dist-info/METADATA +0 -110
  89. squirrels-0.5.0b3.dist-info/RECORD +0 -80
  90. /squirrels/_package_data/base_project/{assets → resources}/expenses.db +0 -0
  91. /squirrels/_package_data/base_project/{assets → resources}/weather.db +0 -0
  92. {squirrels-0.5.0b3.dist-info → squirrels-0.6.0.post0.dist-info}/entry_points.txt +0 -0
  93. {squirrels-0.5.0b3.dist-info → squirrels-0.6.0.post0.dist-info}/licenses/LICENSE +0 -0
squirrels/_parameters.py CHANGED
@@ -1,22 +1,27 @@
1
1
  from __future__ import annotations
2
- from typing import Callable, Type, TypeVar, Sequence, Any
2
+ from typing import Callable, Type, TypeVar, Sequence, Generic, Any
3
3
  from dataclasses import dataclass
4
4
  from datetime import datetime, date
5
5
  from decimal import Decimal
6
6
  from abc import ABCMeta, abstractmethod
7
7
 
8
+ from ._arguments.init_time_args import ParametersArgs
9
+ from ._schemas import response_models as rm
8
10
  from . import _data_sources as d, _parameter_configs as pc, _parameter_options as po, _parameter_sets as ps
9
- from . import _api_response_models as arm, _utils as u
11
+ from . import _utils as u
10
12
 
11
13
  IntOrFloat = TypeVar("IntOrFloat", int, float)
12
14
 
15
+ PC = TypeVar("PC", bound=pc.ParameterConfig)
16
+ PO = TypeVar("PO", bound=po.ParameterOption)
17
+ DS = TypeVar("DS", bound=d.DataSource)
13
18
 
14
19
  @dataclass
15
- class Parameter(metaclass=ABCMeta):
20
+ class Parameter(Generic[PC, PO, DS], metaclass=ABCMeta):
16
21
  """
17
22
  Abstract class for all parameter widgets
18
23
  """
19
- _config: pc.ParameterConfig
24
+ _config: PC
20
25
 
21
26
  @abstractmethod
22
27
  def is_enabled(self) -> bool:
@@ -24,72 +29,111 @@ class Parameter(metaclass=ABCMeta):
24
29
 
25
30
  @staticmethod
26
31
  @abstractmethod
27
- def _ParameterConfigType() -> Type[pc.ParameterConfig]:
32
+ def _ParameterConfigType() -> Type[PC]: # Gets the actual type of the ParameterConfig TypeVar at runtime
33
+ pass
34
+
35
+ @staticmethod
36
+ @abstractmethod
37
+ def _ParameterOptionType() -> Type[PO]: # Gets the actual type of the ParameterOption TypeVar at runtime
38
+ pass
39
+
40
+ @staticmethod
41
+ @abstractmethod
42
+ def _DataSourceType() -> Type[DS]: # Gets the actual type of the DataSource TypeVar at runtime
28
43
  pass
29
44
 
30
45
  @classmethod
31
- def _CreateWithOptionsHelper(
32
- cls, name: str, label: str, all_options: Sequence[po.ParameterOption | dict], *, description: str = "",
46
+ def CreateWithOptions(
47
+ cls, name: str, label: str, all_options: Sequence[PO | dict], *, description: str = "",
33
48
  user_attribute: str | None = None, parent_name: str | None = None, **kwargs
34
- ) -> None:
49
+ ) -> PC:
50
+ """
51
+ Method for creating the configurations for a Parameter that may include user attribute or parent
52
+
53
+ .. deprecated::
54
+ Use the lowercase decorator form `create_with_options` instead.
55
+
56
+ Arguments:
57
+ name: The name of the parameter
58
+ label: The display label for the parameter
59
+ all_options: All options associated to this parameter regardless of the user group or parent parameter option they depend on
60
+ description: Explains the meaning of the parameter
61
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
62
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
63
+ """
64
+ param_option_type = cls._ParameterOptionType()
65
+ if not isinstance(all_options, Sequence) or not all(isinstance(x, (param_option_type, dict)) for x in all_options):
66
+ raise u.ConfigurationError(f"The parameter must take a sequence of {param_option_type.__name__} objects")
67
+
35
68
  param_config_type = cls._ParameterConfigType()
36
69
  param_config = param_config_type(
37
70
  name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name, **kwargs
38
71
  )
39
- ps.ParameterConfigsSetIO.obj.add(param_config)
72
+ return param_config
40
73
 
41
74
  @classmethod
42
- def Create(
43
- cls, name: str, label: str, all_options: Sequence[po.ParameterOption | dict], *, description: str = "",
44
- user_attribute: str | None = None, parent_name: str | None = None, **kwargs
45
- ) -> None:
46
- """
47
- DEPRECATED. Use CreateWithOptions instead
75
+ def create_with_options(
76
+ cls, name: str, label: str, *, description: str = "", user_attribute: str | None = None, parent_name: str | None = None
77
+ ):
48
78
  """
49
- cls._CreateWithOptionsHelper(name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name)
50
-
51
- @classmethod
52
- def CreateWithOptions(
53
- cls, name: str, label: str, all_options: Sequence[po.ParameterOption | dict], *, description: str = "",
54
- user_attribute: str | None = None, parent_name: str | None = None, **kwargs
55
- ) -> None:
56
- """
57
- Method for creating the configurations for a Parameter that may include user attribute or parent
79
+ Python decorator for creating the configurations for a Parameter that may include user attribute or parent.
80
+
81
+ The decorated function must return a list of ParameterOption objects.
58
82
 
59
83
  Arguments:
60
84
  name: The name of the parameter
61
85
  label: The display label for the parameter
62
- all_options: All options associated to this parameter regardless of the user group or parent parameter option they depend on
63
86
  description: Explains the meaning of the parameter
64
87
  user_attribute: The user attribute that may cascade the options for this parameter. Default is None
65
88
  parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
66
89
  """
67
- cls._CreateWithOptionsHelper(name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name)
90
+ def decorator(func: Callable[..., Sequence[PO]]):
91
+ def wrapper(sqrl: ParametersArgs):
92
+ options = u.call_func(func, sqrl=sqrl)
93
+ return cls.CreateWithOptions(
94
+ name, label, options, description=description,
95
+ user_attribute=user_attribute, parent_name=parent_name
96
+ )
97
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
98
+ return wrapper
99
+ return decorator
68
100
 
69
101
  @classmethod
70
102
  @abstractmethod
71
103
  def CreateSimple(cls, name: str, label: str, *args, description: str = "", **kwargs) -> None:
72
104
  pass
73
105
 
106
+ @classmethod
107
+ @abstractmethod
108
+ def create_simple(cls, name: str, label: str, *args, description: str = "", **kwargs) -> None:
109
+ pass
110
+
74
111
  @classmethod
75
112
  def _CreateFromSourceHelper(
76
- cls, name: str, label: str, data_source: d.DataSource | dict, *, extra_args: dict = {}, description: str = "",
113
+ cls, name: str, label: str, data_source: DS | dict, *, extra_args: dict = {}, description: str = "",
77
114
  user_attribute: str | None = None, parent_name: str | None = None
78
- ) -> None:
115
+ ):
116
+ data_source_type = cls._DataSourceType()
117
+ if not isinstance(data_source, (data_source_type, dict)):
118
+ raise u.ConfigurationError(f"The data source must be a {data_source_type.__name__} object")
119
+
79
120
  param_config = pc.DataSourceParameterConfig(
80
121
  cls._ParameterConfigType(), name, label, data_source, description=description, user_attribute=user_attribute,
81
122
  parent_name=parent_name, extra_args=extra_args
82
123
  )
83
- ps.ParameterConfigsSetIO.obj.add(param_config)
124
+ return param_config
84
125
 
85
126
  @classmethod
86
127
  def CreateFromSource(
87
- cls, name: str, label: str, data_source: d.DataSource | dict, *, description: str = "",
128
+ cls, name: str, label: str, data_source: DS | dict, *, description: str = "",
88
129
  user_attribute: str | None = None, parent_name: str | None = None, **kwargs
89
- ) -> None:
130
+ ):
90
131
  """
91
132
  Method for creating the configurations for any Parameter that uses a DataSource to receive the options
92
133
 
134
+ .. deprecated::
135
+ Use the lowercase decorator form `create_from_source` instead.
136
+
93
137
  Arguments:
94
138
  name: The name of the parameter
95
139
  label: The display label for the parameter
@@ -98,7 +142,34 @@ class Parameter(metaclass=ABCMeta):
98
142
  user_attribute: The user attribute that may cascade the options for this parameter. Default is None
99
143
  parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
100
144
  """
101
- cls._CreateFromSourceHelper(name, label, data_source, description=description, user_attribute=user_attribute, parent_name=parent_name)
145
+ return cls._CreateFromSourceHelper(name, label, data_source, description=description, user_attribute=user_attribute, parent_name=parent_name)
146
+
147
+ @classmethod
148
+ def create_from_source(
149
+ cls, name: str, label: str, *, description: str = "", user_attribute: str | None = None, parent_name: str | None = None
150
+ ):
151
+ """
152
+ Python decorator for creating the configurations for a Parameter that uses a DataSource to receive the options from a lookup table
153
+
154
+ The decorated function must return a DataSource object.
155
+
156
+ Arguments:
157
+ name: The name of the parameter
158
+ label: The display label for the parameter
159
+ description: Explains the meaning of the parameter
160
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
161
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
162
+ """
163
+ def decorator(func: Callable[..., DS]):
164
+ def wrapper(sqrl: ParametersArgs):
165
+ data_source = u.call_func(func, sqrl=sqrl)
166
+ return cls.CreateFromSource(
167
+ name, label, data_source, description=description,
168
+ user_attribute=user_attribute, parent_name=parent_name
169
+ )
170
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
171
+ return wrapper
172
+ return decorator
102
173
 
103
174
  def _enquote(self, value: str) -> str:
104
175
  return "'" + value.replace("'", "''") + "'"
@@ -135,16 +206,17 @@ class Parameter(metaclass=ABCMeta):
135
206
  return output
136
207
 
137
208
  @abstractmethod
138
- def _get_response_model0(self) -> type[arm.ParameterModelBase]:
209
+ def _get_response_model0(self) -> type[rm.ParameterModelBase]:
139
210
  pass
140
211
 
141
- def _to_api_response_model0(self) -> arm.ParameterModelBase:
212
+ def _to_api_response_model0(self) -> rm.ParameterModelBase:
142
213
  return self._get_response_model0().model_validate(self._to_json_dict0())
143
214
 
144
215
 
216
+ SelectionPC = TypeVar("SelectionPC", bound=pc.SelectionParameterConfig)
217
+
145
218
  @dataclass
146
- class _SelectionParameter(Parameter):
147
- _config: pc.SelectionParameterConfig
219
+ class _SelectionParameter(Parameter[SelectionPC, po.SelectParameterOption, d.SelectDataSource], Generic[SelectionPC]):
148
220
  _options: Sequence[po.SelectParameterOption]
149
221
 
150
222
  def __post_init__(self):
@@ -173,7 +245,7 @@ class _SelectionParameter(Parameter):
173
245
 
174
246
 
175
247
  @dataclass
176
- class SingleSelectParameter(_SelectionParameter):
248
+ class SingleSelectParameter(_SelectionParameter[pc.SingleSelectParameterConfig]):
177
249
  """
178
250
  Class for single-select parameter widgets.
179
251
 
@@ -182,7 +254,6 @@ class SingleSelectParameter(_SelectionParameter):
182
254
  options: The parameter options that are currently selectable
183
255
  selected_id: The ID of the selected option
184
256
  """
185
- _config: pc.SingleSelectParameterConfig
186
257
  _selected_id: str | None
187
258
 
188
259
  def __post_init__(self):
@@ -197,12 +268,23 @@ class SingleSelectParameter(_SelectionParameter):
197
268
  def _ParameterConfigType():
198
269
  return pc.SingleSelectParameterConfig
199
270
 
271
+ @staticmethod
272
+ def _ParameterOptionType():
273
+ return po.SelectParameterOption
274
+
275
+ @staticmethod
276
+ def _DataSourceType():
277
+ return d.SelectDataSource
278
+
200
279
  @classmethod
201
280
  def CreateSimple(
202
- cls, name: str, label: str, all_options: Sequence[po.SelectParameterOption], *, description: str = "", **kwargs
203
- ) -> None:
281
+ cls, name: str, label: str, all_options: Sequence[po.SelectParameterOption | dict], *, description: str = "", **kwargs
282
+ ):
204
283
  """
205
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
284
+ Method for creating the configurations for a SingleSelectParameter that doesn't involve user attributes or parent parameters
285
+
286
+ .. deprecated::
287
+ Use the lowercase decorator form `create_simple` instead.
206
288
 
207
289
  Arguments:
208
290
  name: The name of the parameter
@@ -210,7 +292,27 @@ class SingleSelectParameter(_SelectionParameter):
210
292
  all_options: All options associated to this parameter regardless of the user group or parent parameter option they depend on
211
293
  description: Explains the meaning of the parameter
212
294
  """
213
- cls.CreateWithOptions(name, label, all_options, description=description)
295
+ return cls.CreateWithOptions(name, label, all_options, description=description)
296
+
297
+ @classmethod
298
+ def create_simple(cls, name: str, label: str, *, description: str = ""):
299
+ """
300
+ Python decorator for creating the configurations for a SingleSelectParameter that doesn't involve user attributes or parent parameters
301
+
302
+ The decorated function must return a list of SelectParameterOption objects.
303
+
304
+ Arguments:
305
+ name: The name of the parameter
306
+ label: The display label for the parameter
307
+ description: Explains the meaning of the parameter
308
+ """
309
+ def decorator(func: Callable[..., Sequence[po.SelectParameterOption]]):
310
+ def wrapper(sqrl: ParametersArgs):
311
+ options = u.call_func(func, sqrl=sqrl)
312
+ return cls.CreateSimple(name, label, options, description=description)
313
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
314
+ return wrapper
315
+ return decorator
214
316
 
215
317
  def get_selected(
216
318
  self, field: str | None = None, *, default_field: str | None = None, default: Any = None, **kwargs
@@ -319,11 +421,11 @@ class SingleSelectParameter(_SelectionParameter):
319
421
  return output
320
422
 
321
423
  def _get_response_model0(self):
322
- return arm.SingleSelectParameterModel if self.is_enabled() else arm.NoneParameterModel
424
+ return rm.SingleSelectParameterModel if self.is_enabled() else rm.NoneParameterModel
323
425
 
324
426
 
325
427
  @dataclass
326
- class MultiSelectParameter(_SelectionParameter):
428
+ class MultiSelectParameter(_SelectionParameter[pc.MultiSelectParameterConfig]):
327
429
  """
328
430
  Class for multi-select parameter widgets.
329
431
 
@@ -332,7 +434,6 @@ class MultiSelectParameter(_SelectionParameter):
332
434
  options: The parameter options that are currently selectable
333
435
  selected_ids: A sequence of IDs of the selected options
334
436
  """
335
- _config: pc.MultiSelectParameterConfig
336
437
  _selected_ids: Sequence[str]
337
438
 
338
439
  def __post_init__(self):
@@ -345,15 +446,26 @@ class MultiSelectParameter(_SelectionParameter):
345
446
  def _ParameterConfigType():
346
447
  return pc.MultiSelectParameterConfig
347
448
 
449
+ @staticmethod
450
+ def _ParameterOptionType():
451
+ return po.SelectParameterOption
452
+
453
+ @staticmethod
454
+ def _DataSourceType():
455
+ return d.SelectDataSource
456
+
348
457
  @classmethod
349
458
  def CreateWithOptions(
350
459
  cls, name: str, label: str, all_options: Sequence[po.SelectParameterOption | dict], *, description: str = "",
351
460
  show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True,
352
461
  user_attribute: str | None = None, parent_name: str | None = None, **kwargs
353
- ) -> None:
462
+ ):
354
463
  """
355
464
  Method for creating the configurations for a MultiSelectParameter that may include user attribute or parent
356
465
 
466
+ .. deprecated::
467
+ Use the lowercase decorator form `create_with_options` instead.
468
+
357
469
  Arguments:
358
470
  name: The name of the parameter
359
471
  label: The display label for the parameter
@@ -365,33 +477,53 @@ class MultiSelectParameter(_SelectionParameter):
365
477
  user_attribute: The user attribute that may cascade the options for this parameter. Default is None
366
478
  parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
367
479
  """
368
- cls._CreateWithOptionsHelper(
480
+ return super().CreateWithOptions(
369
481
  name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name,
370
482
  show_select_all=show_select_all, order_matters=order_matters, none_is_all=none_is_all
371
483
  )
372
-
484
+
373
485
  @classmethod
374
- def Create(
375
- cls, name: str, label: str, all_options: Sequence[po.SelectParameterOption | dict], *, description: str = "",
376
- show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True,
377
- user_attribute: str | None = None, parent_name: str | None = None, **kwargs
378
- ) -> None:
486
+ def create_with_options(
487
+ cls, name: str, label: str, *, description: str = "", show_select_all: bool = True, order_matters: bool = False,
488
+ none_is_all: bool = True, user_attribute: str | None = None, parent_name: str | None = None
489
+ ):
379
490
  """
380
- DEPRECATED. Use CreateWithOptions instead
381
- """
382
- cls._CreateWithOptionsHelper(
383
- name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name,
384
- show_select_all=show_select_all, order_matters=order_matters, none_is_all=none_is_all
385
- )
491
+ Python decorator for creating the configurations for a MultiSelectParameter that may include user attribute or parent
492
+
493
+ The decorated function must return a list of SelectParameterOption objects.
386
494
 
495
+ Arguments:
496
+ name: The name of the parameter
497
+ label: The display label for the parameter
498
+ description: Explains the meaning of the parameter
499
+ show_select_all: Communicate to front-end whether to include a "select all" option
500
+ order_matters: Communicate to front-end whether the order of the selections made matter
501
+ none_is_all: Whether having no options selected is equivalent to all selectable options selected
502
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
503
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
504
+ """
505
+ def decorator(func: Callable[..., Sequence[po.SelectParameterOption]]):
506
+ def wrapper(sqrl: ParametersArgs):
507
+ options = u.call_func(func, sqrl=sqrl)
508
+ return cls.CreateWithOptions(
509
+ name, label, options, description=description, user_attribute=user_attribute, parent_name=parent_name,
510
+ show_select_all=show_select_all, order_matters=order_matters, none_is_all=none_is_all
511
+ )
512
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
513
+ return wrapper
514
+ return decorator
515
+
387
516
  @classmethod
388
517
  def CreateSimple(
389
518
  cls, name: str, label: str, all_options: Sequence[po.SelectParameterOption], *, description: str = "",
390
519
  show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True, **kwargs
391
- ) -> None:
520
+ ):
392
521
  """
393
522
  Method for creating the configurations for a MultiSelectParameter that doesn't involve user attributes or parent parameters
394
523
 
524
+ .. deprecated::
525
+ Use the lowercase decorator form `create_simple` instead.
526
+
395
527
  Arguments:
396
528
  name: The name of the parameter
397
529
  label: The display label for the parameter
@@ -401,20 +533,52 @@ class MultiSelectParameter(_SelectionParameter):
401
533
  order_matters: Communicate to front-end whether the order of the selections made matter
402
534
  none_is_all: Whether having no options selected is equivalent to all selectable options selected
403
535
  """
404
- cls.CreateWithOptions(
536
+ return cls.CreateWithOptions(
405
537
  name, label, all_options, description=description,
406
538
  show_select_all=show_select_all, order_matters=order_matters, none_is_all=none_is_all
407
539
  )
408
540
 
541
+ @classmethod
542
+ def create_simple(
543
+ cls, name: str, label: str, *, description: str = "",
544
+ show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True
545
+ ):
546
+ """
547
+ Python decorator for creating the configurations for a MultiSelectParameter that doesn't involve user attributes or parent parameters
548
+
549
+ The decorated function must return a list of SelectParameterOption objects.
550
+
551
+ Arguments:
552
+ name: The name of the parameter
553
+ label: The display label for the parameter
554
+ description: Explains the meaning of the parameter
555
+ show_select_all: Communicate to front-end whether to include a "select all" option
556
+ order_matters: Communicate to front-end whether the order of the selections made matter
557
+ none_is_all: Whether having no options selected is equivalent to all selectable options selected
558
+ """
559
+ def decorator(func: Callable[..., Sequence[po.SelectParameterOption]]):
560
+ def wrapper(sqrl: ParametersArgs):
561
+ options = u.call_func(func, sqrl=sqrl)
562
+ return cls.CreateSimple(
563
+ name, label, options, description=description,
564
+ show_select_all=show_select_all, order_matters=order_matters, none_is_all=none_is_all
565
+ )
566
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
567
+ return wrapper
568
+ return decorator
569
+
409
570
  @classmethod
410
571
  def CreateFromSource(
411
572
  cls, name: str, label: str, data_source: d.SelectDataSource | dict, *, description: str = "",
412
573
  show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True,
413
574
  user_attribute: str | None = None, parent_name: str | None = None, **kwargs
414
- ) -> None:
575
+ ):
415
576
  """
416
577
  Method for creating the configurations for a MultiSelectParameter that uses a SelectDataSource to receive the options
417
578
 
579
+ .. deprecated::
580
+ Use the lowercase decorator form `create_from_source` instead.
581
+
418
582
  Arguments:
419
583
  name: The name of the parameter
420
584
  label: The display label for the parameter
@@ -429,10 +593,44 @@ class MultiSelectParameter(_SelectionParameter):
429
593
  extra_args = {
430
594
  "show_select_all": show_select_all, "order_matters": order_matters, "none_is_all": none_is_all
431
595
  }
432
- cls._CreateFromSourceHelper(
596
+ return cls._CreateFromSourceHelper(
433
597
  name, label, data_source, extra_args=extra_args, description=description,
434
598
  user_attribute=user_attribute, parent_name=parent_name
435
599
  )
600
+
601
+ @classmethod
602
+ def create_from_source(
603
+ cls, name: str, label: str, *, description: str = "",
604
+ show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True,
605
+ user_attribute: str | None = None, parent_name: str | None = None
606
+ ):
607
+ """
608
+ Python decorator for creating the configurations for a MultiSelectParameter that uses a SelectDataSource to receive the options from a lookup table
609
+
610
+ The decorated function must return a SelectDataSource object.
611
+
612
+ Arguments:
613
+ name: The name of the parameter
614
+ label: The display label for the parameter
615
+ data_source: The lookup table to use for this parameter
616
+ description: Explains the meaning of the parameter
617
+ show_select_all: Communicate to front-end whether to include a "select all" option
618
+ order_matters: Communicate to front-end whether the order of the selections made matter
619
+ none_is_all: Whether having no options selected is equivalent to all selectable options selected
620
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
621
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
622
+ """
623
+ def decorator(func: Callable[..., d.SelectDataSource]):
624
+ def wrapper(sqrl: ParametersArgs):
625
+ data_source = u.call_func(func, sqrl=sqrl)
626
+ return cls.CreateFromSource(
627
+ name, label, data_source, description=description,
628
+ show_select_all=show_select_all, order_matters=order_matters, none_is_all=none_is_all,
629
+ user_attribute=user_attribute, parent_name=parent_name
630
+ )
631
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
632
+ return wrapper
633
+ return decorator
436
634
 
437
635
  def has_non_empty_selection(self) -> bool:
438
636
  """
@@ -626,12 +824,14 @@ class MultiSelectParameter(_SelectionParameter):
626
824
  return output
627
825
 
628
826
  def _get_response_model0(self):
629
- return arm.MultiSelectParameterModel if self.is_enabled() else arm.NoneParameterModel
827
+ return rm.MultiSelectParameterModel if self.is_enabled() else rm.NoneParameterModel
630
828
 
631
829
 
830
+ DatePO = TypeVar("DatePO", bound=po._DateTypeParameterOption)
831
+
632
832
  @dataclass
633
- class _DateTypeParameter(Parameter):
634
- _curr_option: po._DateTypeParameterOption | None
833
+ class _DateTypeParameter(Parameter[PC, DatePO, DS], Generic[PC, DatePO, DS]):
834
+ _curr_option: DatePO | None
635
835
 
636
836
  def is_enabled(self) -> bool:
637
837
  return self._curr_option is not None
@@ -648,7 +848,7 @@ class _DateTypeParameter(Parameter):
648
848
 
649
849
 
650
850
  @dataclass
651
- class DateParameter(_DateTypeParameter):
851
+ class DateParameter(_DateTypeParameter[pc.DateParameterConfig, po.DateParameterOption, d.DateDataSource]):
652
852
  """
653
853
  Class for date parameter widgets.
654
854
 
@@ -657,8 +857,6 @@ class DateParameter(_DateTypeParameter):
657
857
  curr_option: The current option showing for defaults based on user attribute and selection of parent
658
858
  selected_date: The selected date
659
859
  """
660
- _config: pc.DateParameterConfig
661
- _curr_option: po.DateParameterOption | None
662
860
  _selected_date: date | str | None
663
861
 
664
862
  def __post_init__(self):
@@ -672,23 +870,63 @@ class DateParameter(_DateTypeParameter):
672
870
  def _ParameterConfigType():
673
871
  return pc.DateParameterConfig
674
872
 
873
+ @staticmethod
874
+ def _ParameterOptionType():
875
+ return po.DateParameterOption
876
+
877
+ @staticmethod
878
+ def _DataSourceType():
879
+ return d.DateDataSource
880
+
675
881
  @classmethod
676
882
  def CreateSimple(
677
883
  cls, name: str, label: str, default_date: str | date, *, description: str = "",
678
884
  min_date: str | date | None = None, max_date: str | date | None = None, date_format: str = '%Y-%m-%d', **kwargs
679
- ) -> None:
885
+ ):
680
886
  """
681
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
887
+ Method for creating the configurations for a DateParameter that doesn't involve user attributes or parent parameters
888
+
889
+ .. deprecated::
890
+ Use the lowercase decorator form `create_simple` instead.
682
891
 
683
892
  Arguments:
684
893
  name: The name of the parameter
685
894
  label: The display label for the parameter
686
895
  default_date: Default date for this option
687
896
  description: Explains the meaning of the parameter
897
+ min_date: Minimum selectable date
898
+ max_date: Maximum selectable date
688
899
  date_format: Format of the default date, default is '%Y-%m-%d'
689
900
  """
690
901
  single_param_option = po.DateParameterOption(default_date, min_date=min_date, max_date=max_date, date_format=date_format)
691
- cls.CreateWithOptions(name, label, (single_param_option,), description=description)
902
+ return cls.CreateWithOptions(name, label, (single_param_option,), description=description)
903
+
904
+ @classmethod
905
+ def create_simple(
906
+ cls, name: str, label: str, default_date: str | date, *, description: str = "",
907
+ min_date: str | date | None = None, max_date: str | date | None = None, date_format: str = '%Y-%m-%d'
908
+ ):
909
+ """
910
+ Python decorator for creating the configurations for a DateParameter that doesn't involve user attributes or parent parameters
911
+
912
+ Arguments:
913
+ name: The name of the parameter
914
+ label: The display label for the parameter
915
+ default_date: Default date for this option
916
+ description: Explains the meaning of the parameter
917
+ min_date: Minimum selectable date
918
+ max_date: Maximum selectable date
919
+ date_format: Format of the default date, default is '%Y-%m-%d'
920
+ """
921
+ def decorator(func: Callable[..., Any]):
922
+ def wrapper(sqrl: ParametersArgs):
923
+ return cls.CreateSimple(
924
+ name, label, default_date, description=description,
925
+ min_date=min_date, max_date=max_date, date_format=date_format
926
+ )
927
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
928
+ return wrapper
929
+ return decorator
692
930
 
693
931
  def get_selected_date(self, *, date_format: str | None = None, **kwargs) -> str:
694
932
  """
@@ -733,11 +971,11 @@ class DateParameter(_DateTypeParameter):
733
971
  return output
734
972
 
735
973
  def _get_response_model0(self):
736
- return arm.DateParameterModel if self.is_enabled() else arm.NoneParameterModel
974
+ return rm.DateParameterModel if self.is_enabled() else rm.NoneParameterModel
737
975
 
738
976
 
739
977
  @dataclass
740
- class DateRangeParameter(_DateTypeParameter):
978
+ class DateRangeParameter(_DateTypeParameter[pc.DateRangeParameterConfig, po.DateRangeParameterOption, d.DateRangeDataSource]):
741
979
  """
742
980
  Class for date range parameter widgets.
743
981
 
@@ -747,8 +985,6 @@ class DateRangeParameter(_DateTypeParameter):
747
985
  selected_start_date: The selected start date
748
986
  selected_end_date: The selected end date
749
987
  """
750
- _config: pc.DateRangeParameterConfig
751
- _curr_option: po.DateRangeParameterOption | None
752
988
  _selected_start_date: date | str | None
753
989
  _selected_end_date: date | str | None
754
990
 
@@ -765,15 +1001,25 @@ class DateRangeParameter(_DateTypeParameter):
765
1001
  @staticmethod
766
1002
  def _ParameterConfigType():
767
1003
  return pc.DateRangeParameterConfig
1004
+
1005
+ @staticmethod
1006
+ def _ParameterOptionType():
1007
+ return po.DateRangeParameterOption
1008
+
1009
+ @staticmethod
1010
+ def _DataSourceType():
1011
+ return d.DateRangeDataSource
768
1012
 
769
1013
  @classmethod
770
1014
  def CreateSimple(
771
- cls, name: str, label: str, default_start_date: str | date, default_end_date: str | date, *,
772
- description: str = "", min_date: str | date | None = None, max_date: str | date | None = None,
773
- date_format: str = '%Y-%m-%d', **kwargs
774
- ) -> None:
1015
+ cls, name: str, label: str, default_start_date: str | date, default_end_date: str | date, *, description: str = "",
1016
+ min_date: str | date | None = None, max_date: str | date | None = None, date_format: str = '%Y-%m-%d', **kwargs
1017
+ ):
775
1018
  """
776
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
1019
+ Method for creating the configurations for a DateRangeParameter that doesn't involve user attributes or parent parameters
1020
+
1021
+ .. deprecated::
1022
+ Use the lowercase decorator form `create_simple` instead.
777
1023
 
778
1024
  Arguments:
779
1025
  name: The name of the parameter
@@ -781,12 +1027,42 @@ class DateRangeParameter(_DateTypeParameter):
781
1027
  default_start_date: Default start date for this option
782
1028
  default_end_date: Default end date for this option
783
1029
  description: Explains the meaning of the parameter
1030
+ min_date: Minimum selectable date
1031
+ max_date: Maximum selectable date
784
1032
  date_format: Format of the default date, default is '%Y-%m-%d'
785
1033
  """
786
1034
  single_param_option = po.DateRangeParameterOption(
787
1035
  default_start_date, default_end_date, min_date=min_date, max_date=max_date, date_format=date_format
788
1036
  )
789
- cls.CreateWithOptions(name, label, (single_param_option,), description=description)
1037
+ return cls.CreateWithOptions(name, label, (single_param_option,), description=description)
1038
+
1039
+ @classmethod
1040
+ def create_simple(
1041
+ cls, name: str, label: str, default_start_date: str | date, default_end_date: str | date, *, description: str = "",
1042
+ min_date: str | date | None = None, max_date: str | date | None = None, date_format: str = '%Y-%m-%d'
1043
+ ):
1044
+ """
1045
+ Python decorator for creating the configurations for a DateRangeParameter that doesn't involve user attributes or parent parameters
1046
+
1047
+ Arguments:
1048
+ name: The name of the parameter
1049
+ label: The display label for the parameter
1050
+ default_start_date: Default start date for this option
1051
+ default_end_date: Default end date for this option
1052
+ description: Explains the meaning of the parameter
1053
+ min_date: Minimum selectable date
1054
+ max_date: Maximum selectable date
1055
+ date_format: Format of the default date, default is '%Y-%m-%d'
1056
+ """
1057
+ def decorator(func: Callable[..., Any]):
1058
+ def wrapper(sqrl: ParametersArgs):
1059
+ return cls.CreateSimple(
1060
+ name, label, default_start_date, default_end_date, description=description,
1061
+ min_date=min_date, max_date=max_date, date_format=date_format
1062
+ )
1063
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1064
+ return wrapper
1065
+ return decorator
790
1066
 
791
1067
  def get_selected_start_date(self, *, date_format: str | None = None, **kwargs) -> str:
792
1068
  """
@@ -856,12 +1132,14 @@ class DateRangeParameter(_DateTypeParameter):
856
1132
  return output
857
1133
 
858
1134
  def _get_response_model0(self):
859
- return arm.DateRangeParameterModel if self.is_enabled() else arm.NoneParameterModel
1135
+ return rm.DateRangeParameterModel if self.is_enabled() else rm.NoneParameterModel
1136
+
860
1137
 
1138
+ NumericPO = TypeVar("NumericPO", bound=po._NumericParameterOption)
861
1139
 
862
1140
  @dataclass
863
- class _NumberTypeParameter(Parameter):
864
- _curr_option: po._NumericParameterOption | None
1141
+ class _NumberTypeParameter(Parameter[PC, NumericPO, DS], Generic[PC, NumericPO, DS]):
1142
+ _curr_option: NumericPO | None
865
1143
 
866
1144
  def is_enabled(self) -> bool:
867
1145
  return self._curr_option is not None
@@ -876,7 +1154,7 @@ class _NumberTypeParameter(Parameter):
876
1154
 
877
1155
 
878
1156
  @dataclass
879
- class NumberParameter(_NumberTypeParameter):
1157
+ class NumberParameter(_NumberTypeParameter[pc.NumberParameterConfig, po.NumberParameterOption, d.NumberDataSource]):
880
1158
  """
881
1159
  Class for number parameter widgets.
882
1160
 
@@ -885,8 +1163,6 @@ class NumberParameter(_NumberTypeParameter):
885
1163
  curr_option: The current option showing for defaults based on user attribute and selection of parent
886
1164
  selected_value: The selected integer or decimal number
887
1165
  """
888
- _config: pc.NumberParameterConfig
889
- _curr_option: po.NumberParameterOption | None
890
1166
  _selected_value: po.Number | None
891
1167
 
892
1168
  def __post_init__(self):
@@ -896,14 +1172,25 @@ class NumberParameter(_NumberTypeParameter):
896
1172
  @staticmethod
897
1173
  def _ParameterConfigType():
898
1174
  return pc.NumberParameterConfig
1175
+
1176
+ @staticmethod
1177
+ def _ParameterOptionType():
1178
+ return po.NumberParameterOption
1179
+
1180
+ @staticmethod
1181
+ def _DataSourceType():
1182
+ return d.NumberDataSource
899
1183
 
900
1184
  @classmethod
901
1185
  def CreateSimple(
902
1186
  cls, name: str, label: str, min_value: po.Number, max_value: po.Number, *, description: str = "",
903
1187
  increment: po.Number = 1, default_value: po.Number | None = None, **kwargs
904
- ) -> None:
1188
+ ):
905
1189
  """
906
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
1190
+ Method for creating the configurations for a NumberParameter that doesn't involve user attributes or parent parameters
1191
+
1192
+ .. deprecated::
1193
+ Use the lowercase decorator form `create_simple` instead.
907
1194
 
908
1195
  * Note that the "Number" type denotes an int, a Decimal (from decimal module), or a string that can be parsed to Decimal
909
1196
 
@@ -917,7 +1204,35 @@ class NumberParameter(_NumberTypeParameter):
917
1204
  default_value: Default value for this option, and must be selectable based on min_value, max_value, and increment
918
1205
  """
919
1206
  single_param_option = po.NumberParameterOption(min_value, max_value, increment=increment, default_value=default_value)
920
- cls.CreateWithOptions(name, label, (single_param_option,), description=description)
1207
+ return cls.CreateWithOptions(name, label, (single_param_option,), description=description)
1208
+
1209
+ @classmethod
1210
+ def create_simple(
1211
+ cls, name: str, label: str, min_value: po.Number, max_value: po.Number, *, description: str = "",
1212
+ increment: po.Number = 1, default_value: po.Number | None = None
1213
+ ):
1214
+ """
1215
+ Python decorator for creating the configurations for a NumberParameter that doesn't involve user attributes or parent parameters
1216
+
1217
+ * Note that the "Number" type denotes an int, a Decimal (from decimal module), or a string that can be parsed to Decimal
1218
+
1219
+ Arguments:
1220
+ name: The name of the parameter
1221
+ label: The display label for the parameter
1222
+ min_value: Minimum selectable value
1223
+ max_value: Maximum selectable value
1224
+ description: Explains the meaning of the parameter
1225
+ increment: Increment of selectable values, and must fit evenly between min_value and max_value
1226
+ default_value: Default value for the parameter
1227
+ """
1228
+ def decorator(func: Callable[..., Any]):
1229
+ def wrapper(sqrl: ParametersArgs):
1230
+ return cls.CreateSimple(
1231
+ name, label, min_value, max_value, description=description, increment=increment, default_value=default_value
1232
+ )
1233
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1234
+ return wrapper
1235
+ return decorator
921
1236
 
922
1237
  def get_selected_value(self, **kwargs) -> float:
923
1238
  """
@@ -942,11 +1257,11 @@ class NumberParameter(_NumberTypeParameter):
942
1257
  return output
943
1258
 
944
1259
  def _get_response_model0(self):
945
- return arm.NumberParameterModel if self.is_enabled() else arm.NoneParameterModel
1260
+ return rm.NumberParameterModel if self.is_enabled() else rm.NoneParameterModel
946
1261
 
947
1262
 
948
1263
  @dataclass
949
- class NumberRangeParameter(_NumberTypeParameter):
1264
+ class NumberRangeParameter(_NumberTypeParameter[pc.NumberRangeParameterConfig, po.NumberRangeParameterOption, d.NumberRangeDataSource]):
950
1265
  """
951
1266
  Class for number range parameter widgets.
952
1267
 
@@ -956,8 +1271,6 @@ class NumberRangeParameter(_NumberTypeParameter):
956
1271
  selected_lower_value: The selected lower integer or decimal number
957
1272
  selected_upper_value: The selected upper integer or decimal number
958
1273
  """
959
- _config: pc.NumberRangeParameterConfig
960
- _curr_option: po.NumberRangeParameterOption | None
961
1274
  _selected_lower_value: po.Number | None
962
1275
  _selected_upper_value: po.Number | None
963
1276
 
@@ -971,15 +1284,25 @@ class NumberRangeParameter(_NumberTypeParameter):
971
1284
  @staticmethod
972
1285
  def _ParameterConfigType():
973
1286
  return pc.NumberRangeParameterConfig
1287
+
1288
+ @staticmethod
1289
+ def _ParameterOptionType():
1290
+ return po.NumberRangeParameterOption
1291
+
1292
+ @staticmethod
1293
+ def _DataSourceType():
1294
+ return d.NumberRangeDataSource
974
1295
 
975
1296
  @classmethod
976
1297
  def CreateSimple(
977
1298
  cls, name: str, label: str, min_value: po.Number, max_value: po.Number, *, description: str = "",
978
- increment: po.Number = 1, default_lower_value: po.Number | None = None, default_upper_value: po.Number | None = None,
979
- **kwargs
980
- ) -> None:
1299
+ increment: po.Number = 1, default_lower_value: po.Number | None = None, default_upper_value: po.Number | None = None,**kwargs
1300
+ ):
981
1301
  """
982
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
1302
+ Method for creating the configurations for a NumberRangeParameter that doesn't involve user attributes or parent parameters
1303
+
1304
+ .. deprecated::
1305
+ Use the lowercase decorator form `create_simple` instead.
983
1306
 
984
1307
  * Note that the "Number" type denotes an int, a Decimal (from decimal module), or a string that can be parsed to Decimal
985
1308
 
@@ -997,7 +1320,38 @@ class NumberRangeParameter(_NumberTypeParameter):
997
1320
  single_param_option = po.NumberRangeParameterOption(
998
1321
  min_value, max_value, increment=increment, default_lower_value=default_lower_value, default_upper_value=default_upper_value
999
1322
  )
1000
- cls.CreateWithOptions(name, label, (single_param_option,), description=description)
1323
+ return cls.CreateWithOptions(name, label, (single_param_option,), description=description)
1324
+
1325
+ @classmethod
1326
+ def create_simple(
1327
+ cls, name: str, label: str, min_value: po.Number, max_value: po.Number, *, description: str = "",
1328
+ increment: po.Number = 1, default_lower_value: po.Number | None = None, default_upper_value: po.Number | None = None
1329
+ ):
1330
+ """
1331
+ Python decorator for creating the configurations for a NumberRangeParameter that doesn't involve user attributes or parent parameters
1332
+
1333
+ * Note that the "Number" type denotes an int, a Decimal (from decimal module), or a string that can be parsed to Decimal
1334
+
1335
+ Arguments:
1336
+ name: The name of the parameter
1337
+ label: The display label for the parameter
1338
+ min_value: Minimum selectable value
1339
+ max_value: Maximum selectable value
1340
+ description: Explains the meaning of the parameter
1341
+ increment: Increment of selectable values, and must fit evenly between min_value and max_value
1342
+ default_lower_value: Default lower value for this option, and must be selectable based on min_value, max_value, and increment
1343
+ default_upper_value: Default upper value for this option, and must be selectable based on min_value, max_value, and increment.
1344
+ Must also be greater than default_lower_value
1345
+ """
1346
+ def decorator(func: Callable[..., Any]):
1347
+ def wrapper(sqrl: ParametersArgs):
1348
+ return cls.CreateSimple(
1349
+ name, label, min_value, max_value, description=description, increment=increment,
1350
+ default_lower_value=default_lower_value, default_upper_value=default_upper_value
1351
+ )
1352
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1353
+ return wrapper
1354
+ return decorator
1001
1355
 
1002
1356
  def get_selected_lower_value(self, **kwargs) -> float:
1003
1357
  """
@@ -1033,7 +1387,7 @@ class NumberRangeParameter(_NumberTypeParameter):
1033
1387
  return output
1034
1388
 
1035
1389
  def _get_response_model0(self):
1036
- return arm.NumberRangeParameterModel if self.is_enabled() else arm.NoneParameterModel
1390
+ return rm.NumberRangeParameterModel if self.is_enabled() else rm.NoneParameterModel
1037
1391
 
1038
1392
 
1039
1393
  @dataclass
@@ -1118,11 +1472,10 @@ class TextValue:
1118
1472
 
1119
1473
 
1120
1474
  @dataclass
1121
- class TextParameter(Parameter):
1475
+ class TextParameter(Parameter[pc.TextParameterConfig, po.TextParameterOption, d.TextDataSource]):
1122
1476
  """
1123
1477
  Class for text parameter widgets.
1124
1478
  """
1125
- _config: pc.TextParameterConfig
1126
1479
  _curr_option: po.TextParameterOption | None
1127
1480
  _entered_text: str | None
1128
1481
 
@@ -1140,13 +1493,24 @@ class TextParameter(Parameter):
1140
1493
  def _ParameterConfigType():
1141
1494
  return pc.TextParameterConfig
1142
1495
 
1496
+ @staticmethod
1497
+ def _ParameterOptionType():
1498
+ return po.TextParameterOption
1499
+
1500
+ @staticmethod
1501
+ def _DataSourceType():
1502
+ return d.TextDataSource
1503
+
1143
1504
  @classmethod
1144
1505
  def CreateWithOptions(
1145
1506
  cls, name: str, label: str, all_options: Sequence[po.TextParameterOption | dict], *, description: str = "",
1146
1507
  input_type: str = "text", user_attribute: str | None = None, parent_name: str | None = None, **kwargs
1147
- ) -> None:
1508
+ ):
1148
1509
  """
1149
- Method for creating the configurations for a MultiSelectParameter that may include user attribute or parent
1510
+ Method for creating the configurations for a TextParameter that doesn't involve user attribute or parent
1511
+
1512
+ .. deprecated::
1513
+ Use the lowercase decorator form `create_with_options` instead.
1150
1514
 
1151
1515
  Arguments:
1152
1516
  name: The name of the parameter
@@ -1157,28 +1521,49 @@ class TextParameter(Parameter):
1157
1521
  user_attribute: The user attribute that may cascade the options for this parameter. Default is None
1158
1522
  parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
1159
1523
  """
1160
- cls._CreateWithOptionsHelper(
1161
- name, label, all_options, description=description, input_type=input_type, user_attribute=user_attribute, parent_name=parent_name
1524
+ return super().CreateWithOptions(
1525
+ name, label, all_options, description=description, input_type=input_type,
1526
+ user_attribute=user_attribute, parent_name=parent_name
1162
1527
  )
1163
1528
 
1164
1529
  @classmethod
1165
- def Create(
1166
- cls, name: str, label: str, all_options: Sequence[po.TextParameterOption | dict], *, description: str = "",
1167
- input_type: str = "text", user_attribute: str | None = None, parent_name: str | None = None, **kwargs
1168
- ) -> None:
1530
+ def create_with_options(
1531
+ cls, name: str, label: str, *, description: str = "",
1532
+ input_type: str = "text", user_attribute: str | None = None, parent_name: str | None = None
1533
+ ):
1169
1534
  """
1170
- DEPRECATED. Use CreateWithOptions instead
1171
- """
1172
- cls._CreateWithOptionsHelper(
1173
- name, label, all_options, description=description, input_type=input_type, user_attribute=user_attribute, parent_name=parent_name
1174
- )
1535
+ Python decorator for creating the configurations for a TextParameter that may include user attribute or parent
1175
1536
 
1537
+ The decorated function must return a list of TextParameterOption objects.
1538
+
1539
+ Arguments:
1540
+ name: The name of the parameter
1541
+ label: The display label for the parameter
1542
+ description: Explains the meaning of the parameter
1543
+ input_type: The type of input field to use. Must be one of "text", "textarea", "number", "color", "date", "datetime-local", "month", "time", and "password". Optional, default is "text". More information on input types other than "textarea" can be found at https://www.w3schools.com/html/html_form_input_types.asp. More information on "textarea" can be found at https://www.w3schools.com/tags/tag_textarea.asp
1544
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
1545
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
1546
+ """
1547
+ def decorator(func: Callable[..., Sequence[po.TextParameterOption]]):
1548
+ def wrapper(sqrl: ParametersArgs):
1549
+ options = u.call_func(func, sqrl=sqrl)
1550
+ return cls.CreateWithOptions(
1551
+ name, label, options, description=description, input_type=input_type,
1552
+ user_attribute=user_attribute, parent_name=parent_name
1553
+ )
1554
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1555
+ return wrapper
1556
+ return decorator
1557
+
1176
1558
  @classmethod
1177
1559
  def CreateSimple(
1178
1560
  cls, name: str, label: str, *, description: str = "", default_text: str = "", input_type: str = "text", **kwargs
1179
- ) -> None:
1561
+ ):
1180
1562
  """
1181
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
1563
+ Method for creating the configurations for a TextParameter that doesn't involve user attributes or parent parameters
1564
+
1565
+ .. deprecated::
1566
+ Use the lowercase decorator form `create_simple` instead.
1182
1567
 
1183
1568
  Arguments:
1184
1569
  name: The name of the parameter
@@ -1188,15 +1573,37 @@ class TextParameter(Parameter):
1188
1573
  input_type: The type of input field to use. Must be one of "text", "textarea", "number", "color", "date", "datetime-local", "month", "time", and "password". Optional, default is "text". More information on input types other than "textarea" can be found at https://www.w3schools.com/html/html_form_input_types.asp. More information on "textarea" can be found at https://www.w3schools.com/tags/tag_textarea.asp
1189
1574
  """
1190
1575
  single_param_option = po.TextParameterOption(default_text=default_text)
1191
- cls.CreateWithOptions(name, label, (single_param_option,), description=description, input_type=input_type)
1576
+ return cls.CreateWithOptions(name, label, (single_param_option,), description=description, input_type=input_type)
1577
+
1578
+ @classmethod
1579
+ def create_simple(cls, name: str, label: str, *, description: str = "", default_text: str = "", input_type: str = "text"):
1580
+ """
1581
+ Python decorator for creating the configurations for a TextParameter that doesn't involve user attributes or parent parameters
1582
+
1583
+ Arguments:
1584
+ name: The name of the parameter
1585
+ label: The display label for the parameter
1586
+ description: Explains the meaning of the parameter
1587
+ default_text: Default input text for this option. Optional, default is empty string.
1588
+ input_type: The type of input field to use. Must be one of "text", "textarea", "number", "color", "date", "datetime-local", "month", "time", and "password". Optional, default is "text". More information on input types other than "textarea" can be found at https://www.w3schools.com/html/html_form_input_types.asp. More information on "textarea" can be found at https://www.w3schools.com/tags/tag_textarea.asp
1589
+ """
1590
+ def decorator(func: Callable[..., Any]):
1591
+ def wrapper(sqrl: ParametersArgs):
1592
+ return cls.CreateSimple(name, label, description=description, default_text=default_text, input_type=input_type)
1593
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1594
+ return wrapper
1595
+ return decorator
1192
1596
 
1193
1597
  @classmethod
1194
1598
  def CreateFromSource(
1195
1599
  cls, name: str, label: str, data_source: d.TextDataSource | dict, *, description: str = "",
1196
1600
  input_type: str = "text", user_attribute: str | None = None, parent_name: str | None = None, **kwargs
1197
- ) -> None:
1601
+ ):
1198
1602
  """
1199
- Method for creating the configurations for a MultiSelectParameter that uses a SelectDataSource to receive the options
1603
+ Method for creating the configurations for a TextParameter that uses a TextDataSource to receive the options
1604
+
1605
+ .. deprecated::
1606
+ Use the lowercase decorator form `create_from_source` instead.
1200
1607
 
1201
1608
  Arguments:
1202
1609
  name: The name of the parameter
@@ -1210,10 +1617,40 @@ class TextParameter(Parameter):
1210
1617
  extra_args = {
1211
1618
  "input_type": input_type
1212
1619
  }
1213
- cls._CreateFromSourceHelper(
1620
+ return cls._CreateFromSourceHelper(
1214
1621
  name, label, data_source, extra_args=extra_args, description=description, user_attribute=user_attribute, parent_name=parent_name
1215
1622
  )
1216
1623
 
1624
+ @classmethod
1625
+ def create_from_source(
1626
+ cls, name: str, label: str, data_source: d.TextDataSource | dict, *, description: str = "",
1627
+ input_type: str = "text", user_attribute: str | None = None, parent_name: str | None = None
1628
+ ):
1629
+ """
1630
+ Python decorator for creating the configurations for a TextParameter that uses a TextDataSource to receive the options from a lookup table
1631
+
1632
+ The decorated function must return a TextDataSource object.
1633
+
1634
+ Arguments:
1635
+ name: The name of the parameter
1636
+ label: The display label for the parameter
1637
+ data_source: The lookup table to use for this parameter
1638
+ description: Explains the meaning of the parameter
1639
+ input_type: The type of input field to use. Options are one of "text", "textarea", "number", "color", "date", "datetime-local", "month", "time", and "password". Optional, default is "text". More information on input types other than "textarea" can be found at https://www.w3schools.com/html/html_form_input_types.asp. More information on "textarea" can be found at https://www.w3schools.com/tags/tag_textarea.asp
1640
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
1641
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
1642
+ """
1643
+ def decorator(func: Callable[..., d.TextDataSource]):
1644
+ def wrapper(sqrl: ParametersArgs):
1645
+ data_source = u.call_func(func, sqrl=sqrl)
1646
+ return cls.CreateFromSource(
1647
+ name, label, data_source, description=description,
1648
+ input_type=input_type, user_attribute=user_attribute, parent_name=parent_name
1649
+ )
1650
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1651
+ return wrapper
1652
+ return decorator
1653
+
1217
1654
  def get_entered_text(self, **kwargs) -> TextValue:
1218
1655
  """
1219
1656
  Get the entered text. Returns a TextValue object that cannot be converted to string except through placeholders.
@@ -1263,4 +1700,4 @@ class TextParameter(Parameter):
1263
1700
  return output
1264
1701
 
1265
1702
  def _get_response_model0(self):
1266
- return arm.TextParameterModel if self.is_enabled() else arm.NoneParameterModel
1703
+ return rm.TextParameterModel if self.is_enabled() else rm.NoneParameterModel