squirrels 0.5.0b3__py3-none-any.whl → 0.5.0b4__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.

Files changed (47) hide show
  1. squirrels/__init__.py +2 -0
  2. squirrels/_api_routes/__init__.py +5 -0
  3. squirrels/_api_routes/auth.py +262 -0
  4. squirrels/_api_routes/base.py +154 -0
  5. squirrels/_api_routes/dashboards.py +142 -0
  6. squirrels/_api_routes/data_management.py +103 -0
  7. squirrels/_api_routes/datasets.py +242 -0
  8. squirrels/_api_routes/oauth2.py +300 -0
  9. squirrels/_api_routes/project.py +214 -0
  10. squirrels/_api_server.py +142 -745
  11. squirrels/_arguments/__init__.py +0 -0
  12. squirrels/_arguments/{_init_time_args.py → init_time_args.py} +5 -0
  13. squirrels/_arguments/{_run_time_args.py → run_time_args.py} +1 -1
  14. squirrels/_auth.py +645 -92
  15. squirrels/_connection_set.py +1 -1
  16. squirrels/_constants.py +6 -0
  17. squirrels/{_dashboards_io.py → _dashboards.py} +87 -6
  18. squirrels/_exceptions.py +9 -37
  19. squirrels/_model_builder.py +1 -1
  20. squirrels/_model_queries.py +1 -1
  21. squirrels/_models.py +13 -12
  22. squirrels/_package_data/base_project/.env +1 -0
  23. squirrels/_package_data/base_project/.env.example +1 -0
  24. squirrels/_package_data/base_project/pyconfigs/parameters.py +84 -76
  25. squirrels/_package_data/base_project/pyconfigs/user.py +30 -2
  26. squirrels/_package_data/templates/dataset_results.html +112 -0
  27. squirrels/_package_data/templates/oauth_login.html +271 -0
  28. squirrels/_parameter_configs.py +1 -1
  29. squirrels/_parameter_sets.py +31 -21
  30. squirrels/_parameters.py +521 -123
  31. squirrels/_project.py +43 -24
  32. squirrels/_py_module.py +3 -2
  33. squirrels/_schemas/__init__.py +0 -0
  34. squirrels/_schemas/auth_models.py +144 -0
  35. squirrels/_schemas/query_param_models.py +67 -0
  36. squirrels/{_api_response_models.py → _schemas/response_models.py} +12 -8
  37. squirrels/_utils.py +34 -2
  38. squirrels/arguments.py +2 -2
  39. squirrels/auth.py +1 -0
  40. squirrels/dashboards.py +1 -1
  41. squirrels/types.py +3 -3
  42. {squirrels-0.5.0b3.dist-info → squirrels-0.5.0b4.dist-info}/METADATA +4 -1
  43. {squirrels-0.5.0b3.dist-info → squirrels-0.5.0b4.dist-info}/RECORD +46 -32
  44. squirrels/_dashboard_types.py +0 -82
  45. {squirrels-0.5.0b3.dist-info → squirrels-0.5.0b4.dist-info}/WHEEL +0 -0
  46. {squirrels-0.5.0b3.dist-info → squirrels-0.5.0b4.dist-info}/entry_points.txt +0 -0
  47. {squirrels-0.5.0b3.dist-info → squirrels-0.5.0b4.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,69 +29,102 @@ 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
+ Arguments:
54
+ name: The name of the parameter
55
+ label: The display label for the parameter
56
+ all_options: All options associated to this parameter regardless of the user group or parent parameter option they depend on
57
+ description: Explains the meaning of the parameter
58
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
59
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
60
+ """
61
+ param_option_type = cls._ParameterOptionType()
62
+ if not isinstance(all_options, Sequence) or not all(isinstance(x, (param_option_type, dict)) for x in all_options):
63
+ raise u.ConfigurationError(f"The parameter must take a sequence of {param_option_type.__name__} objects")
64
+
35
65
  param_config_type = cls._ParameterConfigType()
36
66
  param_config = param_config_type(
37
67
  name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name, **kwargs
38
68
  )
39
- ps.ParameterConfigsSetIO.obj.add(param_config)
40
-
41
- @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
48
- """
49
- cls._CreateWithOptionsHelper(name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name)
69
+ return param_config
50
70
 
51
71
  @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:
72
+ def create_with_options(
73
+ cls, name: str, label: str, *, description: str = "", user_attribute: str | None = None, parent_name: str | None = None
74
+ ):
56
75
  """
57
- Method for creating the configurations for a Parameter that may include user attribute or parent
76
+ Python decorator for creating the configurations for a Parameter that may include user attribute or parent.
77
+
78
+ The decorated function must return a list of ParameterOption objects.
58
79
 
59
80
  Arguments:
60
81
  name: The name of the parameter
61
82
  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
83
  description: Explains the meaning of the parameter
64
84
  user_attribute: The user attribute that may cascade the options for this parameter. Default is None
65
85
  parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
66
86
  """
67
- cls._CreateWithOptionsHelper(name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name)
87
+ def decorator(func: Callable[..., Sequence[PO]]):
88
+ def wrapper(sqrl: ParametersArgs):
89
+ options = u.call_func(func, sqrl=sqrl)
90
+ return cls.CreateWithOptions(
91
+ name, label, options, description=description,
92
+ user_attribute=user_attribute, parent_name=parent_name
93
+ )
94
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
95
+ return wrapper
96
+ return decorator
68
97
 
69
98
  @classmethod
70
99
  @abstractmethod
71
100
  def CreateSimple(cls, name: str, label: str, *args, description: str = "", **kwargs) -> None:
72
101
  pass
73
102
 
103
+ @classmethod
104
+ @abstractmethod
105
+ def create_simple(cls, name: str, label: str, *args, description: str = "", **kwargs) -> None:
106
+ pass
107
+
74
108
  @classmethod
75
109
  def _CreateFromSourceHelper(
76
- cls, name: str, label: str, data_source: d.DataSource | dict, *, extra_args: dict = {}, description: str = "",
110
+ cls, name: str, label: str, data_source: DS | dict, *, extra_args: dict = {}, description: str = "",
77
111
  user_attribute: str | None = None, parent_name: str | None = None
78
- ) -> None:
112
+ ):
113
+ data_source_type = cls._DataSourceType()
114
+ if not isinstance(data_source, (data_source_type, dict)):
115
+ raise u.ConfigurationError(f"The data source must be a {data_source_type.__name__} object")
116
+
79
117
  param_config = pc.DataSourceParameterConfig(
80
118
  cls._ParameterConfigType(), name, label, data_source, description=description, user_attribute=user_attribute,
81
119
  parent_name=parent_name, extra_args=extra_args
82
120
  )
83
- ps.ParameterConfigsSetIO.obj.add(param_config)
121
+ return param_config
84
122
 
85
123
  @classmethod
86
124
  def CreateFromSource(
87
- cls, name: str, label: str, data_source: d.DataSource | dict, *, description: str = "",
125
+ cls, name: str, label: str, data_source: DS | dict, *, description: str = "",
88
126
  user_attribute: str | None = None, parent_name: str | None = None, **kwargs
89
- ) -> None:
127
+ ):
90
128
  """
91
129
  Method for creating the configurations for any Parameter that uses a DataSource to receive the options
92
130
 
@@ -98,7 +136,34 @@ class Parameter(metaclass=ABCMeta):
98
136
  user_attribute: The user attribute that may cascade the options for this parameter. Default is None
99
137
  parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
100
138
  """
101
- cls._CreateFromSourceHelper(name, label, data_source, description=description, user_attribute=user_attribute, parent_name=parent_name)
139
+ return cls._CreateFromSourceHelper(name, label, data_source, description=description, user_attribute=user_attribute, parent_name=parent_name)
140
+
141
+ @classmethod
142
+ def create_from_source(
143
+ cls, name: str, label: str, *, description: str = "", user_attribute: str | None = None, parent_name: str | None = None
144
+ ):
145
+ """
146
+ Python decorator for creating the configurations for a Parameter that uses a DataSource to receive the options from a lookup table
147
+
148
+ The decorated function must return a DataSource object.
149
+
150
+ Arguments:
151
+ name: The name of the parameter
152
+ label: The display label for the parameter
153
+ description: Explains the meaning of the parameter
154
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
155
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
156
+ """
157
+ def decorator(func: Callable[..., DS]):
158
+ def wrapper(sqrl: ParametersArgs):
159
+ data_source = u.call_func(func, sqrl=sqrl)
160
+ return cls.CreateFromSource(
161
+ name, label, data_source, description=description,
162
+ user_attribute=user_attribute, parent_name=parent_name
163
+ )
164
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
165
+ return wrapper
166
+ return decorator
102
167
 
103
168
  def _enquote(self, value: str) -> str:
104
169
  return "'" + value.replace("'", "''") + "'"
@@ -135,16 +200,17 @@ class Parameter(metaclass=ABCMeta):
135
200
  return output
136
201
 
137
202
  @abstractmethod
138
- def _get_response_model0(self) -> type[arm.ParameterModelBase]:
203
+ def _get_response_model0(self) -> type[rm.ParameterModelBase]:
139
204
  pass
140
205
 
141
- def _to_api_response_model0(self) -> arm.ParameterModelBase:
206
+ def _to_api_response_model0(self) -> rm.ParameterModelBase:
142
207
  return self._get_response_model0().model_validate(self._to_json_dict0())
143
208
 
144
209
 
210
+ SelectionPC = TypeVar("SelectionPC", bound=pc.SelectionParameterConfig)
211
+
145
212
  @dataclass
146
- class _SelectionParameter(Parameter):
147
- _config: pc.SelectionParameterConfig
213
+ class _SelectionParameter(Parameter[SelectionPC, po.SelectParameterOption, d.SelectDataSource], Generic[SelectionPC]):
148
214
  _options: Sequence[po.SelectParameterOption]
149
215
 
150
216
  def __post_init__(self):
@@ -173,7 +239,7 @@ class _SelectionParameter(Parameter):
173
239
 
174
240
 
175
241
  @dataclass
176
- class SingleSelectParameter(_SelectionParameter):
242
+ class SingleSelectParameter(_SelectionParameter[pc.SingleSelectParameterConfig]):
177
243
  """
178
244
  Class for single-select parameter widgets.
179
245
 
@@ -182,7 +248,6 @@ class SingleSelectParameter(_SelectionParameter):
182
248
  options: The parameter options that are currently selectable
183
249
  selected_id: The ID of the selected option
184
250
  """
185
- _config: pc.SingleSelectParameterConfig
186
251
  _selected_id: str | None
187
252
 
188
253
  def __post_init__(self):
@@ -197,12 +262,20 @@ class SingleSelectParameter(_SelectionParameter):
197
262
  def _ParameterConfigType():
198
263
  return pc.SingleSelectParameterConfig
199
264
 
265
+ @staticmethod
266
+ def _ParameterOptionType():
267
+ return po.SelectParameterOption
268
+
269
+ @staticmethod
270
+ def _DataSourceType():
271
+ return d.SelectDataSource
272
+
200
273
  @classmethod
201
274
  def CreateSimple(
202
- cls, name: str, label: str, all_options: Sequence[po.SelectParameterOption], *, description: str = "", **kwargs
203
- ) -> None:
275
+ cls, name: str, label: str, all_options: Sequence[po.SelectParameterOption | dict], *, description: str = "", **kwargs
276
+ ):
204
277
  """
205
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
278
+ Method for creating the configurations for a SingleSelectParameter that doesn't involve user attributes or parent parameters
206
279
 
207
280
  Arguments:
208
281
  name: The name of the parameter
@@ -210,7 +283,27 @@ class SingleSelectParameter(_SelectionParameter):
210
283
  all_options: All options associated to this parameter regardless of the user group or parent parameter option they depend on
211
284
  description: Explains the meaning of the parameter
212
285
  """
213
- cls.CreateWithOptions(name, label, all_options, description=description)
286
+ return cls.CreateWithOptions(name, label, all_options, description=description)
287
+
288
+ @classmethod
289
+ def create_simple(cls, name: str, label: str, *, description: str = ""):
290
+ """
291
+ Python decorator for creating the configurations for a SingleSelectParameter that doesn't involve user attributes or parent parameters
292
+
293
+ The decorated function must return a list of SelectParameterOption objects.
294
+
295
+ Arguments:
296
+ name: The name of the parameter
297
+ label: The display label for the parameter
298
+ description: Explains the meaning of the parameter
299
+ """
300
+ def decorator(func: Callable[..., Sequence[po.SelectParameterOption]]):
301
+ def wrapper(sqrl: ParametersArgs):
302
+ options = u.call_func(func, sqrl=sqrl)
303
+ return cls.CreateSimple(name, label, options, description=description)
304
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
305
+ return wrapper
306
+ return decorator
214
307
 
215
308
  def get_selected(
216
309
  self, field: str | None = None, *, default_field: str | None = None, default: Any = None, **kwargs
@@ -319,11 +412,11 @@ class SingleSelectParameter(_SelectionParameter):
319
412
  return output
320
413
 
321
414
  def _get_response_model0(self):
322
- return arm.SingleSelectParameterModel if self.is_enabled() else arm.NoneParameterModel
415
+ return rm.SingleSelectParameterModel if self.is_enabled() else rm.NoneParameterModel
323
416
 
324
417
 
325
418
  @dataclass
326
- class MultiSelectParameter(_SelectionParameter):
419
+ class MultiSelectParameter(_SelectionParameter[pc.MultiSelectParameterConfig]):
327
420
  """
328
421
  Class for multi-select parameter widgets.
329
422
 
@@ -332,7 +425,6 @@ class MultiSelectParameter(_SelectionParameter):
332
425
  options: The parameter options that are currently selectable
333
426
  selected_ids: A sequence of IDs of the selected options
334
427
  """
335
- _config: pc.MultiSelectParameterConfig
336
428
  _selected_ids: Sequence[str]
337
429
 
338
430
  def __post_init__(self):
@@ -345,12 +437,20 @@ class MultiSelectParameter(_SelectionParameter):
345
437
  def _ParameterConfigType():
346
438
  return pc.MultiSelectParameterConfig
347
439
 
440
+ @staticmethod
441
+ def _ParameterOptionType():
442
+ return po.SelectParameterOption
443
+
444
+ @staticmethod
445
+ def _DataSourceType():
446
+ return d.SelectDataSource
447
+
348
448
  @classmethod
349
449
  def CreateWithOptions(
350
450
  cls, name: str, label: str, all_options: Sequence[po.SelectParameterOption | dict], *, description: str = "",
351
451
  show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True,
352
452
  user_attribute: str | None = None, parent_name: str | None = None, **kwargs
353
- ) -> None:
453
+ ):
354
454
  """
355
455
  Method for creating the configurations for a MultiSelectParameter that may include user attribute or parent
356
456
 
@@ -365,30 +465,47 @@ class MultiSelectParameter(_SelectionParameter):
365
465
  user_attribute: The user attribute that may cascade the options for this parameter. Default is None
366
466
  parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
367
467
  """
368
- cls._CreateWithOptionsHelper(
468
+ return super().CreateWithOptions(
369
469
  name, label, all_options, description=description, user_attribute=user_attribute, parent_name=parent_name,
370
470
  show_select_all=show_select_all, order_matters=order_matters, none_is_all=none_is_all
371
471
  )
372
-
472
+
373
473
  @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:
379
- """
380
- DEPRECATED. Use CreateWithOptions instead
474
+ def create_with_options(
475
+ cls, name: str, label: str, *, description: str = "", show_select_all: bool = True, order_matters: bool = False,
476
+ none_is_all: bool = True, user_attribute: str | None = None, parent_name: str | None = None
477
+ ):
381
478
  """
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
- )
479
+ Python decorator for creating the configurations for a MultiSelectParameter that may include user attribute or parent
386
480
 
481
+ The decorated function must return a list of SelectParameterOption objects.
482
+
483
+ Arguments:
484
+ name: The name of the parameter
485
+ label: The display label for the parameter
486
+ description: Explains the meaning of the parameter
487
+ show_select_all: Communicate to front-end whether to include a "select all" option
488
+ order_matters: Communicate to front-end whether the order of the selections made matter
489
+ none_is_all: Whether having no options selected is equivalent to all selectable options selected
490
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
491
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
492
+ """
493
+ def decorator(func: Callable[..., Sequence[po.SelectParameterOption]]):
494
+ def wrapper(sqrl: ParametersArgs):
495
+ options = u.call_func(func, sqrl=sqrl)
496
+ return cls.CreateWithOptions(
497
+ name, label, options, description=description, user_attribute=user_attribute, parent_name=parent_name,
498
+ show_select_all=show_select_all, order_matters=order_matters, none_is_all=none_is_all
499
+ )
500
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
501
+ return wrapper
502
+ return decorator
503
+
387
504
  @classmethod
388
505
  def CreateSimple(
389
506
  cls, name: str, label: str, all_options: Sequence[po.SelectParameterOption], *, description: str = "",
390
507
  show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True, **kwargs
391
- ) -> None:
508
+ ):
392
509
  """
393
510
  Method for creating the configurations for a MultiSelectParameter that doesn't involve user attributes or parent parameters
394
511
 
@@ -401,17 +518,46 @@ class MultiSelectParameter(_SelectionParameter):
401
518
  order_matters: Communicate to front-end whether the order of the selections made matter
402
519
  none_is_all: Whether having no options selected is equivalent to all selectable options selected
403
520
  """
404
- cls.CreateWithOptions(
521
+ return cls.CreateWithOptions(
405
522
  name, label, all_options, description=description,
406
523
  show_select_all=show_select_all, order_matters=order_matters, none_is_all=none_is_all
407
524
  )
408
525
 
526
+ @classmethod
527
+ def create_simple(
528
+ cls, name: str, label: str, *, description: str = "",
529
+ show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True
530
+ ):
531
+ """
532
+ Python decorator for creating the configurations for a MultiSelectParameter that doesn't involve user attributes or parent parameters
533
+
534
+ The decorated function must return a list of SelectParameterOption objects.
535
+
536
+ Arguments:
537
+ name: The name of the parameter
538
+ label: The display label for the parameter
539
+ description: Explains the meaning of the parameter
540
+ show_select_all: Communicate to front-end whether to include a "select all" option
541
+ order_matters: Communicate to front-end whether the order of the selections made matter
542
+ none_is_all: Whether having no options selected is equivalent to all selectable options selected
543
+ """
544
+ def decorator(func: Callable[..., Sequence[po.SelectParameterOption]]):
545
+ def wrapper(sqrl: ParametersArgs):
546
+ options = u.call_func(func, sqrl=sqrl)
547
+ return cls.CreateSimple(
548
+ name, label, options, description=description,
549
+ show_select_all=show_select_all, order_matters=order_matters, none_is_all=none_is_all
550
+ )
551
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
552
+ return wrapper
553
+ return decorator
554
+
409
555
  @classmethod
410
556
  def CreateFromSource(
411
557
  cls, name: str, label: str, data_source: d.SelectDataSource | dict, *, description: str = "",
412
558
  show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True,
413
559
  user_attribute: str | None = None, parent_name: str | None = None, **kwargs
414
- ) -> None:
560
+ ):
415
561
  """
416
562
  Method for creating the configurations for a MultiSelectParameter that uses a SelectDataSource to receive the options
417
563
 
@@ -429,10 +575,44 @@ class MultiSelectParameter(_SelectionParameter):
429
575
  extra_args = {
430
576
  "show_select_all": show_select_all, "order_matters": order_matters, "none_is_all": none_is_all
431
577
  }
432
- cls._CreateFromSourceHelper(
578
+ return cls._CreateFromSourceHelper(
433
579
  name, label, data_source, extra_args=extra_args, description=description,
434
580
  user_attribute=user_attribute, parent_name=parent_name
435
581
  )
582
+
583
+ @classmethod
584
+ def create_from_source(
585
+ cls, name: str, label: str, *, description: str = "",
586
+ show_select_all: bool = True, order_matters: bool = False, none_is_all: bool = True,
587
+ user_attribute: str | None = None, parent_name: str | None = None
588
+ ):
589
+ """
590
+ Python decorator for creating the configurations for a MultiSelectParameter that uses a SelectDataSource to receive the options from a lookup table
591
+
592
+ The decorated function must return a SelectDataSource object.
593
+
594
+ Arguments:
595
+ name: The name of the parameter
596
+ label: The display label for the parameter
597
+ data_source: The lookup table to use for this parameter
598
+ description: Explains the meaning of the parameter
599
+ show_select_all: Communicate to front-end whether to include a "select all" option
600
+ order_matters: Communicate to front-end whether the order of the selections made matter
601
+ none_is_all: Whether having no options selected is equivalent to all selectable options selected
602
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
603
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
604
+ """
605
+ def decorator(func: Callable[..., d.SelectDataSource]):
606
+ def wrapper(sqrl: ParametersArgs):
607
+ data_source = u.call_func(func, sqrl=sqrl)
608
+ return cls.CreateFromSource(
609
+ name, label, data_source, description=description,
610
+ show_select_all=show_select_all, order_matters=order_matters, none_is_all=none_is_all,
611
+ user_attribute=user_attribute, parent_name=parent_name
612
+ )
613
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
614
+ return wrapper
615
+ return decorator
436
616
 
437
617
  def has_non_empty_selection(self) -> bool:
438
618
  """
@@ -626,12 +806,14 @@ class MultiSelectParameter(_SelectionParameter):
626
806
  return output
627
807
 
628
808
  def _get_response_model0(self):
629
- return arm.MultiSelectParameterModel if self.is_enabled() else arm.NoneParameterModel
809
+ return rm.MultiSelectParameterModel if self.is_enabled() else rm.NoneParameterModel
630
810
 
631
811
 
812
+ DatePO = TypeVar("DatePO", bound=po._DateTypeParameterOption)
813
+
632
814
  @dataclass
633
- class _DateTypeParameter(Parameter):
634
- _curr_option: po._DateTypeParameterOption | None
815
+ class _DateTypeParameter(Parameter[PC, DatePO, DS], Generic[PC, DatePO, DS]):
816
+ _curr_option: DatePO | None
635
817
 
636
818
  def is_enabled(self) -> bool:
637
819
  return self._curr_option is not None
@@ -648,7 +830,7 @@ class _DateTypeParameter(Parameter):
648
830
 
649
831
 
650
832
  @dataclass
651
- class DateParameter(_DateTypeParameter):
833
+ class DateParameter(_DateTypeParameter[pc.DateParameterConfig, po.DateParameterOption, d.DateDataSource]):
652
834
  """
653
835
  Class for date parameter widgets.
654
836
 
@@ -657,8 +839,6 @@ class DateParameter(_DateTypeParameter):
657
839
  curr_option: The current option showing for defaults based on user attribute and selection of parent
658
840
  selected_date: The selected date
659
841
  """
660
- _config: pc.DateParameterConfig
661
- _curr_option: po.DateParameterOption | None
662
842
  _selected_date: date | str | None
663
843
 
664
844
  def __post_init__(self):
@@ -672,23 +852,60 @@ class DateParameter(_DateTypeParameter):
672
852
  def _ParameterConfigType():
673
853
  return pc.DateParameterConfig
674
854
 
855
+ @staticmethod
856
+ def _ParameterOptionType():
857
+ return po.DateParameterOption
858
+
859
+ @staticmethod
860
+ def _DataSourceType():
861
+ return d.DateDataSource
862
+
675
863
  @classmethod
676
864
  def CreateSimple(
677
865
  cls, name: str, label: str, default_date: str | date, *, description: str = "",
678
866
  min_date: str | date | None = None, max_date: str | date | None = None, date_format: str = '%Y-%m-%d', **kwargs
679
- ) -> None:
867
+ ):
680
868
  """
681
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
869
+ Method for creating the configurations for a DateParameter that doesn't involve user attributes or parent parameters
682
870
 
683
871
  Arguments:
684
872
  name: The name of the parameter
685
873
  label: The display label for the parameter
686
874
  default_date: Default date for this option
687
875
  description: Explains the meaning of the parameter
876
+ min_date: Minimum selectable date
877
+ max_date: Maximum selectable date
688
878
  date_format: Format of the default date, default is '%Y-%m-%d'
689
879
  """
690
880
  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)
881
+ return cls.CreateWithOptions(name, label, (single_param_option,), description=description)
882
+
883
+ @classmethod
884
+ def create_simple(
885
+ cls, name: str, label: str, default_date: str | date, *, description: str = "",
886
+ min_date: str | date | None = None, max_date: str | date | None = None, date_format: str = '%Y-%m-%d'
887
+ ):
888
+ """
889
+ Python decorator for creating the configurations for a DateParameter that doesn't involve user attributes or parent parameters
890
+
891
+ Arguments:
892
+ name: The name of the parameter
893
+ label: The display label for the parameter
894
+ default_date: Default date for this option
895
+ description: Explains the meaning of the parameter
896
+ min_date: Minimum selectable date
897
+ max_date: Maximum selectable date
898
+ date_format: Format of the default date, default is '%Y-%m-%d'
899
+ """
900
+ def decorator(func: Callable[..., Any]):
901
+ def wrapper(sqrl: ParametersArgs):
902
+ return cls.CreateSimple(
903
+ name, label, default_date, description=description,
904
+ min_date=min_date, max_date=max_date, date_format=date_format
905
+ )
906
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
907
+ return wrapper
908
+ return decorator
692
909
 
693
910
  def get_selected_date(self, *, date_format: str | None = None, **kwargs) -> str:
694
911
  """
@@ -733,11 +950,11 @@ class DateParameter(_DateTypeParameter):
733
950
  return output
734
951
 
735
952
  def _get_response_model0(self):
736
- return arm.DateParameterModel if self.is_enabled() else arm.NoneParameterModel
953
+ return rm.DateParameterModel if self.is_enabled() else rm.NoneParameterModel
737
954
 
738
955
 
739
956
  @dataclass
740
- class DateRangeParameter(_DateTypeParameter):
957
+ class DateRangeParameter(_DateTypeParameter[pc.DateRangeParameterConfig, po.DateRangeParameterOption, d.DateRangeDataSource]):
741
958
  """
742
959
  Class for date range parameter widgets.
743
960
 
@@ -747,8 +964,6 @@ class DateRangeParameter(_DateTypeParameter):
747
964
  selected_start_date: The selected start date
748
965
  selected_end_date: The selected end date
749
966
  """
750
- _config: pc.DateRangeParameterConfig
751
- _curr_option: po.DateRangeParameterOption | None
752
967
  _selected_start_date: date | str | None
753
968
  _selected_end_date: date | str | None
754
969
 
@@ -765,15 +980,22 @@ class DateRangeParameter(_DateTypeParameter):
765
980
  @staticmethod
766
981
  def _ParameterConfigType():
767
982
  return pc.DateRangeParameterConfig
983
+
984
+ @staticmethod
985
+ def _ParameterOptionType():
986
+ return po.DateRangeParameterOption
987
+
988
+ @staticmethod
989
+ def _DataSourceType():
990
+ return d.DateRangeDataSource
768
991
 
769
992
  @classmethod
770
993
  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:
994
+ cls, name: str, label: str, default_start_date: str | date, default_end_date: str | date, *, description: str = "",
995
+ min_date: str | date | None = None, max_date: str | date | None = None, date_format: str = '%Y-%m-%d', **kwargs
996
+ ):
775
997
  """
776
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
998
+ Method for creating the configurations for a DateRangeParameter that doesn't involve user attributes or parent parameters
777
999
 
778
1000
  Arguments:
779
1001
  name: The name of the parameter
@@ -781,12 +1003,42 @@ class DateRangeParameter(_DateTypeParameter):
781
1003
  default_start_date: Default start date for this option
782
1004
  default_end_date: Default end date for this option
783
1005
  description: Explains the meaning of the parameter
1006
+ min_date: Minimum selectable date
1007
+ max_date: Maximum selectable date
784
1008
  date_format: Format of the default date, default is '%Y-%m-%d'
785
1009
  """
786
1010
  single_param_option = po.DateRangeParameterOption(
787
1011
  default_start_date, default_end_date, min_date=min_date, max_date=max_date, date_format=date_format
788
1012
  )
789
- cls.CreateWithOptions(name, label, (single_param_option,), description=description)
1013
+ return cls.CreateWithOptions(name, label, (single_param_option,), description=description)
1014
+
1015
+ @classmethod
1016
+ def create_simple(
1017
+ cls, name: str, label: str, default_start_date: str | date, default_end_date: str | date, *, description: str = "",
1018
+ min_date: str | date | None = None, max_date: str | date | None = None, date_format: str = '%Y-%m-%d'
1019
+ ):
1020
+ """
1021
+ Python decorator for creating the configurations for a DateRangeParameter that doesn't involve user attributes or parent parameters
1022
+
1023
+ Arguments:
1024
+ name: The name of the parameter
1025
+ label: The display label for the parameter
1026
+ default_start_date: Default start date for this option
1027
+ default_end_date: Default end date for this option
1028
+ description: Explains the meaning of the parameter
1029
+ min_date: Minimum selectable date
1030
+ max_date: Maximum selectable date
1031
+ date_format: Format of the default date, default is '%Y-%m-%d'
1032
+ """
1033
+ def decorator(func: Callable[..., Any]):
1034
+ def wrapper(sqrl: ParametersArgs):
1035
+ return cls.CreateSimple(
1036
+ name, label, default_start_date, default_end_date, description=description,
1037
+ min_date=min_date, max_date=max_date, date_format=date_format
1038
+ )
1039
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1040
+ return wrapper
1041
+ return decorator
790
1042
 
791
1043
  def get_selected_start_date(self, *, date_format: str | None = None, **kwargs) -> str:
792
1044
  """
@@ -856,12 +1108,14 @@ class DateRangeParameter(_DateTypeParameter):
856
1108
  return output
857
1109
 
858
1110
  def _get_response_model0(self):
859
- return arm.DateRangeParameterModel if self.is_enabled() else arm.NoneParameterModel
1111
+ return rm.DateRangeParameterModel if self.is_enabled() else rm.NoneParameterModel
1112
+
860
1113
 
1114
+ NumericPO = TypeVar("NumericPO", bound=po._NumericParameterOption)
861
1115
 
862
1116
  @dataclass
863
- class _NumberTypeParameter(Parameter):
864
- _curr_option: po._NumericParameterOption | None
1117
+ class _NumberTypeParameter(Parameter[PC, NumericPO, DS], Generic[PC, NumericPO, DS]):
1118
+ _curr_option: NumericPO | None
865
1119
 
866
1120
  def is_enabled(self) -> bool:
867
1121
  return self._curr_option is not None
@@ -876,7 +1130,7 @@ class _NumberTypeParameter(Parameter):
876
1130
 
877
1131
 
878
1132
  @dataclass
879
- class NumberParameter(_NumberTypeParameter):
1133
+ class NumberParameter(_NumberTypeParameter[pc.NumberParameterConfig, po.NumberParameterOption, d.NumberDataSource]):
880
1134
  """
881
1135
  Class for number parameter widgets.
882
1136
 
@@ -885,8 +1139,6 @@ class NumberParameter(_NumberTypeParameter):
885
1139
  curr_option: The current option showing for defaults based on user attribute and selection of parent
886
1140
  selected_value: The selected integer or decimal number
887
1141
  """
888
- _config: pc.NumberParameterConfig
889
- _curr_option: po.NumberParameterOption | None
890
1142
  _selected_value: po.Number | None
891
1143
 
892
1144
  def __post_init__(self):
@@ -896,14 +1148,22 @@ class NumberParameter(_NumberTypeParameter):
896
1148
  @staticmethod
897
1149
  def _ParameterConfigType():
898
1150
  return pc.NumberParameterConfig
1151
+
1152
+ @staticmethod
1153
+ def _ParameterOptionType():
1154
+ return po.NumberParameterOption
1155
+
1156
+ @staticmethod
1157
+ def _DataSourceType():
1158
+ return d.NumberDataSource
899
1159
 
900
1160
  @classmethod
901
1161
  def CreateSimple(
902
1162
  cls, name: str, label: str, min_value: po.Number, max_value: po.Number, *, description: str = "",
903
1163
  increment: po.Number = 1, default_value: po.Number | None = None, **kwargs
904
- ) -> None:
1164
+ ):
905
1165
  """
906
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
1166
+ Method for creating the configurations for a NumberParameter that doesn't involve user attributes or parent parameters
907
1167
 
908
1168
  * Note that the "Number" type denotes an int, a Decimal (from decimal module), or a string that can be parsed to Decimal
909
1169
 
@@ -917,7 +1177,35 @@ class NumberParameter(_NumberTypeParameter):
917
1177
  default_value: Default value for this option, and must be selectable based on min_value, max_value, and increment
918
1178
  """
919
1179
  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)
1180
+ return cls.CreateWithOptions(name, label, (single_param_option,), description=description)
1181
+
1182
+ @classmethod
1183
+ def create_simple(
1184
+ cls, name: str, label: str, min_value: po.Number, max_value: po.Number, *, description: str = "",
1185
+ increment: po.Number = 1, default_value: po.Number | None = None
1186
+ ):
1187
+ """
1188
+ Python decorator for creating the configurations for a NumberParameter that doesn't involve user attributes or parent parameters
1189
+
1190
+ * Note that the "Number" type denotes an int, a Decimal (from decimal module), or a string that can be parsed to Decimal
1191
+
1192
+ Arguments:
1193
+ name: The name of the parameter
1194
+ label: The display label for the parameter
1195
+ min_value: Minimum selectable value
1196
+ max_value: Maximum selectable value
1197
+ description: Explains the meaning of the parameter
1198
+ increment: Increment of selectable values, and must fit evenly between min_value and max_value
1199
+ default_value: Default value for the parameter
1200
+ """
1201
+ def decorator(func: Callable[..., Any]):
1202
+ def wrapper(sqrl: ParametersArgs):
1203
+ return cls.CreateSimple(
1204
+ name, label, min_value, max_value, description=description, increment=increment, default_value=default_value
1205
+ )
1206
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1207
+ return wrapper
1208
+ return decorator
921
1209
 
922
1210
  def get_selected_value(self, **kwargs) -> float:
923
1211
  """
@@ -942,11 +1230,11 @@ class NumberParameter(_NumberTypeParameter):
942
1230
  return output
943
1231
 
944
1232
  def _get_response_model0(self):
945
- return arm.NumberParameterModel if self.is_enabled() else arm.NoneParameterModel
1233
+ return rm.NumberParameterModel if self.is_enabled() else rm.NoneParameterModel
946
1234
 
947
1235
 
948
1236
  @dataclass
949
- class NumberRangeParameter(_NumberTypeParameter):
1237
+ class NumberRangeParameter(_NumberTypeParameter[pc.NumberRangeParameterConfig, po.NumberRangeParameterOption, d.NumberRangeDataSource]):
950
1238
  """
951
1239
  Class for number range parameter widgets.
952
1240
 
@@ -956,8 +1244,6 @@ class NumberRangeParameter(_NumberTypeParameter):
956
1244
  selected_lower_value: The selected lower integer or decimal number
957
1245
  selected_upper_value: The selected upper integer or decimal number
958
1246
  """
959
- _config: pc.NumberRangeParameterConfig
960
- _curr_option: po.NumberRangeParameterOption | None
961
1247
  _selected_lower_value: po.Number | None
962
1248
  _selected_upper_value: po.Number | None
963
1249
 
@@ -971,15 +1257,22 @@ class NumberRangeParameter(_NumberTypeParameter):
971
1257
  @staticmethod
972
1258
  def _ParameterConfigType():
973
1259
  return pc.NumberRangeParameterConfig
1260
+
1261
+ @staticmethod
1262
+ def _ParameterOptionType():
1263
+ return po.NumberRangeParameterOption
1264
+
1265
+ @staticmethod
1266
+ def _DataSourceType():
1267
+ return d.NumberRangeDataSource
974
1268
 
975
1269
  @classmethod
976
1270
  def CreateSimple(
977
1271
  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:
1272
+ increment: po.Number = 1, default_lower_value: po.Number | None = None, default_upper_value: po.Number | None = None,**kwargs
1273
+ ):
981
1274
  """
982
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
1275
+ Method for creating the configurations for a NumberRangeParameter that doesn't involve user attributes or parent parameters
983
1276
 
984
1277
  * Note that the "Number" type denotes an int, a Decimal (from decimal module), or a string that can be parsed to Decimal
985
1278
 
@@ -997,7 +1290,38 @@ class NumberRangeParameter(_NumberTypeParameter):
997
1290
  single_param_option = po.NumberRangeParameterOption(
998
1291
  min_value, max_value, increment=increment, default_lower_value=default_lower_value, default_upper_value=default_upper_value
999
1292
  )
1000
- cls.CreateWithOptions(name, label, (single_param_option,), description=description)
1293
+ return cls.CreateWithOptions(name, label, (single_param_option,), description=description)
1294
+
1295
+ @classmethod
1296
+ def create_simple(
1297
+ cls, name: str, label: str, min_value: po.Number, max_value: po.Number, *, description: str = "",
1298
+ increment: po.Number = 1, default_lower_value: po.Number | None = None, default_upper_value: po.Number | None = None
1299
+ ):
1300
+ """
1301
+ Python decorator for creating the configurations for a NumberRangeParameter that doesn't involve user attributes or parent parameters
1302
+
1303
+ * Note that the "Number" type denotes an int, a Decimal (from decimal module), or a string that can be parsed to Decimal
1304
+
1305
+ Arguments:
1306
+ name: The name of the parameter
1307
+ label: The display label for the parameter
1308
+ min_value: Minimum selectable value
1309
+ max_value: Maximum selectable value
1310
+ description: Explains the meaning of the parameter
1311
+ increment: Increment of selectable values, and must fit evenly between min_value and max_value
1312
+ default_lower_value: Default lower value for this option, and must be selectable based on min_value, max_value, and increment
1313
+ default_upper_value: Default upper value for this option, and must be selectable based on min_value, max_value, and increment.
1314
+ Must also be greater than default_lower_value
1315
+ """
1316
+ def decorator(func: Callable[..., Any]):
1317
+ def wrapper(sqrl: ParametersArgs):
1318
+ return cls.CreateSimple(
1319
+ name, label, min_value, max_value, description=description, increment=increment,
1320
+ default_lower_value=default_lower_value, default_upper_value=default_upper_value
1321
+ )
1322
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1323
+ return wrapper
1324
+ return decorator
1001
1325
 
1002
1326
  def get_selected_lower_value(self, **kwargs) -> float:
1003
1327
  """
@@ -1033,7 +1357,7 @@ class NumberRangeParameter(_NumberTypeParameter):
1033
1357
  return output
1034
1358
 
1035
1359
  def _get_response_model0(self):
1036
- return arm.NumberRangeParameterModel if self.is_enabled() else arm.NoneParameterModel
1360
+ return rm.NumberRangeParameterModel if self.is_enabled() else rm.NoneParameterModel
1037
1361
 
1038
1362
 
1039
1363
  @dataclass
@@ -1118,11 +1442,10 @@ class TextValue:
1118
1442
 
1119
1443
 
1120
1444
  @dataclass
1121
- class TextParameter(Parameter):
1445
+ class TextParameter(Parameter[pc.TextParameterConfig, po.TextParameterOption, d.TextDataSource]):
1122
1446
  """
1123
1447
  Class for text parameter widgets.
1124
1448
  """
1125
- _config: pc.TextParameterConfig
1126
1449
  _curr_option: po.TextParameterOption | None
1127
1450
  _entered_text: str | None
1128
1451
 
@@ -1140,13 +1463,21 @@ class TextParameter(Parameter):
1140
1463
  def _ParameterConfigType():
1141
1464
  return pc.TextParameterConfig
1142
1465
 
1466
+ @staticmethod
1467
+ def _ParameterOptionType():
1468
+ return po.TextParameterOption
1469
+
1470
+ @staticmethod
1471
+ def _DataSourceType():
1472
+ return d.TextDataSource
1473
+
1143
1474
  @classmethod
1144
1475
  def CreateWithOptions(
1145
1476
  cls, name: str, label: str, all_options: Sequence[po.TextParameterOption | dict], *, description: str = "",
1146
1477
  input_type: str = "text", user_attribute: str | None = None, parent_name: str | None = None, **kwargs
1147
- ) -> None:
1478
+ ):
1148
1479
  """
1149
- Method for creating the configurations for a MultiSelectParameter that may include user attribute or parent
1480
+ Method for creating the configurations for a TextParameter that doesn't involve user attribute or parent
1150
1481
 
1151
1482
  Arguments:
1152
1483
  name: The name of the parameter
@@ -1157,28 +1488,46 @@ class TextParameter(Parameter):
1157
1488
  user_attribute: The user attribute that may cascade the options for this parameter. Default is None
1158
1489
  parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
1159
1490
  """
1160
- cls._CreateWithOptionsHelper(
1161
- name, label, all_options, description=description, input_type=input_type, user_attribute=user_attribute, parent_name=parent_name
1491
+ return super().CreateWithOptions(
1492
+ name, label, all_options, description=description, input_type=input_type,
1493
+ user_attribute=user_attribute, parent_name=parent_name
1162
1494
  )
1163
1495
 
1164
1496
  @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:
1497
+ def create_with_options(
1498
+ cls, name: str, label: str, *, description: str = "",
1499
+ input_type: str = "text", user_attribute: str | None = None, parent_name: str | None = None
1500
+ ):
1169
1501
  """
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
- )
1502
+ Python decorator for creating the configurations for a TextParameter that may include user attribute or parent
1175
1503
 
1504
+ The decorated function must return a list of TextParameterOption objects.
1505
+
1506
+ Arguments:
1507
+ name: The name of the parameter
1508
+ label: The display label for the parameter
1509
+ description: Explains the meaning of the parameter
1510
+ 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
1511
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
1512
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
1513
+ """
1514
+ def decorator(func: Callable[..., Sequence[po.TextParameterOption]]):
1515
+ def wrapper(sqrl: ParametersArgs):
1516
+ options = u.call_func(func, sqrl=sqrl)
1517
+ return cls.CreateWithOptions(
1518
+ name, label, options, description=description, input_type=input_type,
1519
+ user_attribute=user_attribute, parent_name=parent_name
1520
+ )
1521
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1522
+ return wrapper
1523
+ return decorator
1524
+
1176
1525
  @classmethod
1177
1526
  def CreateSimple(
1178
1527
  cls, name: str, label: str, *, description: str = "", default_text: str = "", input_type: str = "text", **kwargs
1179
- ) -> None:
1528
+ ):
1180
1529
  """
1181
- Method for creating the configurations for a Parameter that doesn't involve user attributes or parent parameters
1530
+ Method for creating the configurations for a TextParameter that doesn't involve user attributes or parent parameters
1182
1531
 
1183
1532
  Arguments:
1184
1533
  name: The name of the parameter
@@ -1188,15 +1537,34 @@ class TextParameter(Parameter):
1188
1537
  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
1538
  """
1190
1539
  single_param_option = po.TextParameterOption(default_text=default_text)
1191
- cls.CreateWithOptions(name, label, (single_param_option,), description=description, input_type=input_type)
1540
+ return cls.CreateWithOptions(name, label, (single_param_option,), description=description, input_type=input_type)
1541
+
1542
+ @classmethod
1543
+ def create_simple(cls, name: str, label: str, *, description: str = "", default_text: str = "", input_type: str = "text"):
1544
+ """
1545
+ Python decorator for creating the configurations for a TextParameter that doesn't involve user attributes or parent parameters
1546
+
1547
+ Arguments:
1548
+ name: The name of the parameter
1549
+ label: The display label for the parameter
1550
+ description: Explains the meaning of the parameter
1551
+ default_text: Default input text for this option. Optional, default is empty string.
1552
+ 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
1553
+ """
1554
+ def decorator(func: Callable[..., Any]):
1555
+ def wrapper(sqrl: ParametersArgs):
1556
+ return cls.CreateSimple(name, label, description=description, default_text=default_text, input_type=input_type)
1557
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1558
+ return wrapper
1559
+ return decorator
1192
1560
 
1193
1561
  @classmethod
1194
1562
  def CreateFromSource(
1195
1563
  cls, name: str, label: str, data_source: d.TextDataSource | dict, *, description: str = "",
1196
1564
  input_type: str = "text", user_attribute: str | None = None, parent_name: str | None = None, **kwargs
1197
- ) -> None:
1565
+ ):
1198
1566
  """
1199
- Method for creating the configurations for a MultiSelectParameter that uses a SelectDataSource to receive the options
1567
+ Method for creating the configurations for a TextParameter that uses a TextDataSource to receive the options
1200
1568
 
1201
1569
  Arguments:
1202
1570
  name: The name of the parameter
@@ -1210,10 +1578,40 @@ class TextParameter(Parameter):
1210
1578
  extra_args = {
1211
1579
  "input_type": input_type
1212
1580
  }
1213
- cls._CreateFromSourceHelper(
1581
+ return cls._CreateFromSourceHelper(
1214
1582
  name, label, data_source, extra_args=extra_args, description=description, user_attribute=user_attribute, parent_name=parent_name
1215
1583
  )
1216
1584
 
1585
+ @classmethod
1586
+ def create_from_source(
1587
+ cls, name: str, label: str, data_source: d.TextDataSource | dict, *, description: str = "",
1588
+ input_type: str = "text", user_attribute: str | None = None, parent_name: str | None = None
1589
+ ):
1590
+ """
1591
+ Python decorator for creating the configurations for a TextParameter that uses a TextDataSource to receive the options from a lookup table
1592
+
1593
+ The decorated function must return a TextDataSource object.
1594
+
1595
+ Arguments:
1596
+ name: The name of the parameter
1597
+ label: The display label for the parameter
1598
+ data_source: The lookup table to use for this parameter
1599
+ description: Explains the meaning of the parameter
1600
+ 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
1601
+ user_attribute: The user attribute that may cascade the options for this parameter. Default is None
1602
+ parent_name: Name of parent parameter that may cascade the options for this parameter. Default is None (no parent)
1603
+ """
1604
+ def decorator(func: Callable[..., d.TextDataSource]):
1605
+ def wrapper(sqrl: ParametersArgs):
1606
+ data_source = u.call_func(func, sqrl=sqrl)
1607
+ return cls.CreateFromSource(
1608
+ name, label, data_source, description=description,
1609
+ input_type=input_type, user_attribute=user_attribute, parent_name=parent_name
1610
+ )
1611
+ ps.ParameterConfigsSetIO.param_factories.append(wrapper)
1612
+ return wrapper
1613
+ return decorator
1614
+
1217
1615
  def get_entered_text(self, **kwargs) -> TextValue:
1218
1616
  """
1219
1617
  Get the entered text. Returns a TextValue object that cannot be converted to string except through placeholders.
@@ -1263,4 +1661,4 @@ class TextParameter(Parameter):
1263
1661
  return output
1264
1662
 
1265
1663
  def _get_response_model0(self):
1266
- return arm.TextParameterModel if self.is_enabled() else arm.NoneParameterModel
1664
+ return rm.TextParameterModel if self.is_enabled() else rm.NoneParameterModel