tracdap-runtime 0.6.1.dev3__py3-none-any.whl → 0.6.3__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 (102) hide show
  1. tracdap/rt/_exec/actors.py +87 -10
  2. tracdap/rt/_exec/context.py +25 -1
  3. tracdap/rt/_exec/dev_mode.py +277 -221
  4. tracdap/rt/_exec/engine.py +79 -14
  5. tracdap/rt/_exec/functions.py +37 -8
  6. tracdap/rt/_exec/graph.py +2 -0
  7. tracdap/rt/_exec/graph_builder.py +118 -56
  8. tracdap/rt/_exec/runtime.py +108 -37
  9. tracdap/rt/_exec/server.py +345 -0
  10. tracdap/rt/_impl/config_parser.py +219 -49
  11. tracdap/rt/_impl/data.py +14 -0
  12. tracdap/rt/_impl/grpc/__init__.py +13 -0
  13. tracdap/rt/_impl/grpc/codec.py +99 -0
  14. tracdap/rt/_impl/grpc/tracdap/api/internal/runtime_pb2.py +51 -0
  15. tracdap/rt/_impl/grpc/tracdap/api/internal/runtime_pb2.pyi +61 -0
  16. tracdap/rt/_impl/grpc/tracdap/api/internal/runtime_pb2_grpc.py +183 -0
  17. tracdap/rt/_impl/grpc/tracdap/metadata/common_pb2.py +33 -0
  18. tracdap/rt/_impl/grpc/tracdap/metadata/common_pb2.pyi +34 -0
  19. tracdap/rt/{metadata → _impl/grpc/tracdap/metadata}/custom_pb2.py +5 -5
  20. tracdap/rt/_impl/grpc/tracdap/metadata/custom_pb2.pyi +15 -0
  21. tracdap/rt/_impl/grpc/tracdap/metadata/data_pb2.py +51 -0
  22. tracdap/rt/_impl/grpc/tracdap/metadata/data_pb2.pyi +115 -0
  23. tracdap/rt/_impl/grpc/tracdap/metadata/file_pb2.py +28 -0
  24. tracdap/rt/_impl/grpc/tracdap/metadata/file_pb2.pyi +22 -0
  25. tracdap/rt/_impl/grpc/tracdap/metadata/flow_pb2.py +59 -0
  26. tracdap/rt/_impl/grpc/tracdap/metadata/flow_pb2.pyi +109 -0
  27. tracdap/rt/_impl/grpc/tracdap/metadata/job_pb2.py +76 -0
  28. tracdap/rt/_impl/grpc/tracdap/metadata/job_pb2.pyi +177 -0
  29. tracdap/rt/_impl/grpc/tracdap/metadata/model_pb2.py +63 -0
  30. tracdap/rt/_impl/grpc/tracdap/metadata/model_pb2.pyi +119 -0
  31. tracdap/rt/_impl/grpc/tracdap/metadata/object_id_pb2.py +32 -0
  32. tracdap/rt/_impl/grpc/tracdap/metadata/object_id_pb2.pyi +68 -0
  33. tracdap/rt/_impl/grpc/tracdap/metadata/object_pb2.py +40 -0
  34. tracdap/rt/_impl/grpc/tracdap/metadata/object_pb2.pyi +46 -0
  35. tracdap/rt/_impl/grpc/tracdap/metadata/search_pb2.py +39 -0
  36. tracdap/rt/_impl/grpc/tracdap/metadata/search_pb2.pyi +83 -0
  37. tracdap/rt/_impl/grpc/tracdap/metadata/stoarge_pb2.py +50 -0
  38. tracdap/rt/_impl/grpc/tracdap/metadata/stoarge_pb2.pyi +89 -0
  39. tracdap/rt/_impl/grpc/tracdap/metadata/tag_pb2.py +34 -0
  40. tracdap/rt/_impl/grpc/tracdap/metadata/tag_pb2.pyi +26 -0
  41. tracdap/rt/_impl/grpc/tracdap/metadata/tag_update_pb2.py +30 -0
  42. tracdap/rt/_impl/grpc/tracdap/metadata/tag_update_pb2.pyi +34 -0
  43. tracdap/rt/_impl/grpc/tracdap/metadata/type_pb2.py +47 -0
  44. tracdap/rt/_impl/grpc/tracdap/metadata/type_pb2.pyi +101 -0
  45. tracdap/rt/_impl/guard_rails.py +26 -6
  46. tracdap/rt/_impl/models.py +25 -0
  47. tracdap/rt/_impl/static_api.py +27 -9
  48. tracdap/rt/_impl/type_system.py +17 -0
  49. tracdap/rt/_impl/validation.py +10 -0
  50. tracdap/rt/_plugins/config_local.py +49 -0
  51. tracdap/rt/_version.py +1 -1
  52. tracdap/rt/api/hook.py +10 -3
  53. tracdap/rt/api/model_api.py +22 -0
  54. tracdap/rt/api/static_api.py +79 -19
  55. tracdap/rt/config/__init__.py +3 -3
  56. tracdap/rt/config/common.py +10 -0
  57. tracdap/rt/config/platform.py +9 -19
  58. tracdap/rt/config/runtime.py +2 -0
  59. tracdap/rt/ext/config.py +34 -0
  60. tracdap/rt/ext/embed.py +1 -3
  61. tracdap/rt/ext/plugins.py +47 -6
  62. tracdap/rt/launch/cli.py +7 -5
  63. tracdap/rt/launch/launch.py +49 -12
  64. tracdap/rt/metadata/__init__.py +24 -24
  65. tracdap/rt/metadata/common.py +7 -7
  66. tracdap/rt/metadata/custom.py +2 -0
  67. tracdap/rt/metadata/data.py +28 -5
  68. tracdap/rt/metadata/file.py +2 -0
  69. tracdap/rt/metadata/flow.py +66 -4
  70. tracdap/rt/metadata/job.py +56 -16
  71. tracdap/rt/metadata/model.py +10 -0
  72. tracdap/rt/metadata/object.py +3 -0
  73. tracdap/rt/metadata/object_id.py +9 -9
  74. tracdap/rt/metadata/search.py +35 -13
  75. tracdap/rt/metadata/stoarge.py +64 -6
  76. tracdap/rt/metadata/tag_update.py +21 -7
  77. tracdap/rt/metadata/type.py +28 -13
  78. {tracdap_runtime-0.6.1.dev3.dist-info → tracdap_runtime-0.6.3.dist-info}/METADATA +22 -19
  79. tracdap_runtime-0.6.3.dist-info/RECORD +112 -0
  80. {tracdap_runtime-0.6.1.dev3.dist-info → tracdap_runtime-0.6.3.dist-info}/WHEEL +1 -1
  81. tracdap/rt/config/common_pb2.py +0 -55
  82. tracdap/rt/config/job_pb2.py +0 -42
  83. tracdap/rt/config/platform_pb2.py +0 -71
  84. tracdap/rt/config/result_pb2.py +0 -37
  85. tracdap/rt/config/runtime_pb2.py +0 -42
  86. tracdap/rt/ext/_guard.py +0 -37
  87. tracdap/rt/metadata/common_pb2.py +0 -33
  88. tracdap/rt/metadata/data_pb2.py +0 -51
  89. tracdap/rt/metadata/file_pb2.py +0 -28
  90. tracdap/rt/metadata/flow_pb2.py +0 -55
  91. tracdap/rt/metadata/job_pb2.py +0 -76
  92. tracdap/rt/metadata/model_pb2.py +0 -51
  93. tracdap/rt/metadata/object_id_pb2.py +0 -32
  94. tracdap/rt/metadata/object_pb2.py +0 -35
  95. tracdap/rt/metadata/search_pb2.py +0 -39
  96. tracdap/rt/metadata/stoarge_pb2.py +0 -50
  97. tracdap/rt/metadata/tag_pb2.py +0 -34
  98. tracdap/rt/metadata/tag_update_pb2.py +0 -30
  99. tracdap/rt/metadata/type_pb2.py +0 -48
  100. tracdap_runtime-0.6.1.dev3.dist-info/RECORD +0 -96
  101. {tracdap_runtime-0.6.1.dev3.dist-info → tracdap_runtime-0.6.3.dist-info}/LICENSE +0 -0
  102. {tracdap_runtime-0.6.1.dev3.dist-info → tracdap_runtime-0.6.3.dist-info}/top_level.txt +0 -0
@@ -14,6 +14,7 @@
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
+ import sys
17
18
  import typing as _tp
18
19
  import types as _ts
19
20
 
@@ -111,7 +112,8 @@ def A( # noqa
111
112
 
112
113
  def define_parameter(
113
114
  param_name: str, param_type: _tp.Union[TypeDescriptor, BasicType],
114
- label: str, default_value: _tp.Optional[_tp.Any] = None) \
115
+ label: str, default_value: _tp.Optional[_tp.Any] = None,
116
+ *, param_props: _tp.Optional[_tp.Dict[str, _tp.Any]] = None) \
115
117
  -> _Named[ModelParameter]:
116
118
 
117
119
  """
@@ -128,6 +130,10 @@ def define_parameter(
128
130
  the model. TRAC will apply type coercion where possible to ensure the default value matches the parameter type,
129
131
  if the default value cannot be coerced to match the parameter type then model validation will fail.
130
132
 
133
+ You can use param_props to associate arbitrary key-value properties with this model parameter.
134
+ These properties are not used by the TRAC engine, but are stored in the model metadata for
135
+ the parameter and can be used as needed in 3rd-party applications.
136
+
131
137
  Once defined model parameters can be passed to :py:func:`define_parameters`,
132
138
  either as a list or as individual arguments, to create the set of parameters for a model.
133
139
 
@@ -135,6 +141,7 @@ def define_parameter(
135
141
  :param param_type: The parameter type, expressed in the TRAC type system
136
142
  :param label: A descriptive label for the parameter (required)
137
143
  :param default_value: A default value to use if no explicit value is supplied (optional)
144
+ :param param_props: Associate key-value properties with this parameter (not used by the TRAC engine)
138
145
  :return: A named model parameter, suitable for passing to :py:func:`define_parameters`
139
146
 
140
147
  :type param_name: str
@@ -142,11 +149,12 @@ def define_parameter(
142
149
  :py:class:`BasicType <tracdap.rt.metadata.BasicType>`
143
150
  :type label: str
144
151
  :type default_value: Optional[Any]
152
+ :type param_props: Optional[Dict[str, Any]]
145
153
  :rtype: _Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]
146
154
  """
147
155
 
148
156
  sa = _StaticApiHook.get_instance()
149
- return sa.define_parameter(param_name, param_type, label, default_value)
157
+ return sa.define_parameter(param_name, param_type, label, default_value, param_props=param_props)
150
158
 
151
159
 
152
160
  def declare_parameter(
@@ -160,6 +168,9 @@ def declare_parameter(
160
168
  .. deprecated:: 0.4.4
161
169
  Use :py:func:`define_parameter` or :py:func:`P` instead.
162
170
 
171
+ This function is deprecated and will be removed in a future version.
172
+ Please use :py:func:`define_parameter() <tracdap.rt.api.define_parameter>` instead.
173
+
163
174
  :type param_name: str
164
175
  :type param_type: :py:class:`TypeDescriptor <tracdap.rt.metadata.TypeDescriptor>` |
165
176
  :py:class:`BasicType <tracdap.rt.metadata.BasicType>`
@@ -168,6 +179,8 @@ def declare_parameter(
168
179
  :rtype: _Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]
169
180
  """
170
181
 
182
+ print("TRAC Warning: declare_parameter() is deprecated, please use define_parameter()", file=sys.stderr)
183
+
171
184
  return define_parameter(param_name, param_type, label, default_value)
172
185
 
173
186
 
@@ -175,7 +188,8 @@ def P( # noqa
175
188
  param_name: str,
176
189
  param_type: _tp.Union[TypeDescriptor, BasicType],
177
190
  label: str,
178
- default_value: _tp.Optional[_tp.Any] = None) \
191
+ default_value: _tp.Optional[_tp.Any] = None,
192
+ *, param_props: _tp.Optional[_tp.Dict[str, _tp.Any]] = None) \
179
193
  -> _Named[ModelParameter]:
180
194
 
181
195
  """
@@ -186,12 +200,11 @@ def P( # noqa
186
200
  :py:class:`BasicType <tracdap.rt.metadata.BasicType>`
187
201
  :type label: str
188
202
  :type default_value: Optional[Any]
203
+ :type param_props: Optional[Dict[str, Any]]
189
204
  :rtype: _Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]
190
205
  """
191
206
 
192
- return declare_parameter(
193
- param_name, param_type, label,
194
- default_value)
207
+ return define_parameter(param_name, param_type, label, default_value, param_props=param_props)
195
208
 
196
209
 
197
210
  def define_parameters(
@@ -226,11 +239,16 @@ def declare_parameters(
226
239
  .. deprecated:: 0.4.4
227
240
  Use :py:func:`define_parameters` instead.
228
241
 
242
+ This function is deprecated and will be removed in a future version.
243
+ Please use :py:func:`define_parameters() <tracdap.rt.api.define_parameters>` instead.
244
+
229
245
  :type params: _Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`] |
230
246
  List[_Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]]
231
247
  :rtype: Dict[str, :py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]
232
248
  """
233
249
 
250
+ print("TRAC Warning: declare_parameters() is deprecated, please use define_parameters()", file=sys.stderr)
251
+
234
252
  return define_parameters(*params)
235
253
 
236
254
 
@@ -278,9 +296,9 @@ def define_field(
278
296
  :type label: str
279
297
  :type business_key: bool
280
298
  :type categorical: bool
281
- :type not_null: _tp.Optional[bool]
282
- :type format_code: _tp.Optional[str]
283
- :type field_order: _tp.Optional[int]
299
+ :type not_null: Optional[bool]
300
+ :type format_code: Optional[str]
301
+ :type field_order: Optional[int]
284
302
  :rtype: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`
285
303
  """
286
304
 
@@ -307,17 +325,22 @@ def declare_field(
307
325
  .. deprecated:: 0.4.4
308
326
  Use :py:func:`define_field` or :py:func:`F` instead.
309
327
 
328
+ This function is deprecated and will be removed in a future version.
329
+ Please use :py:func:`define_field() <tracdap.rt.api.define_field>` instead.
330
+
310
331
  :type field_name: str
311
332
  :type field_type: :py:class:`BasicType <tracdap.rt.metadata.BasicType>`
312
333
  :type label: str
313
334
  :type business_key: bool
314
335
  :type categorical: bool
315
- :type not_null: _tp.Optional[bool]
316
- :type format_code: _tp.Optional[str]
317
- :type field_order: _tp.Optional[int]
336
+ :type not_null: Optional[bool]
337
+ :type format_code: Optional[str]
338
+ :type field_order: Optional[int]
318
339
  :rtype: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`
319
340
  """
320
341
 
342
+ print("TRAC Warning: declare_field() is deprecated, please use define_field()", file=sys.stderr)
343
+
321
344
  return define_field(
322
345
  field_name, field_type, label,
323
346
  business_key, categorical, not_null,
@@ -343,9 +366,9 @@ def F( # noqa
343
366
  :type label: str
344
367
  :type business_key: bool
345
368
  :type categorical: bool
346
- :type not_null: _tp.Optional[bool]
347
- :type format_code: _tp.Optional[str]
348
- :type field_order: _tp.Optional[int]
369
+ :type not_null: Optional[bool]
370
+ :type format_code: Optional[str]
371
+ :type field_order: Optional[int]
349
372
  :rtype: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`
350
373
  """
351
374
 
@@ -427,7 +450,10 @@ def load_schema(
427
450
 
428
451
 
429
452
  def define_input_table(
430
- *fields: _tp.Union[FieldSchema, _tp.List[FieldSchema]], label: _tp.Optional[str] = None) \
453
+ *fields: _tp.Union[FieldSchema, _tp.List[FieldSchema]],
454
+ label: _tp.Optional[str] = None,
455
+ optional: bool = False,
456
+ input_props: _tp.Optional[_tp.Dict[str, _tp.Any]] = None) \
431
457
  -> ModelInputSchema:
432
458
 
433
459
  """
@@ -436,17 +462,26 @@ def define_input_table(
436
462
  Fields can be supplied either as individual arguments to this function or as a list.
437
463
  Individual fields should be defined using :py:func:`define_field` or the shorthand alias :py:func:`F`.
438
464
 
465
+ You can use input_props to associate arbitrary key-value properties with this model input.
466
+ These properties are not used by the TRAC engine, but are stored in the model metadata for
467
+ the input and can be used as needed in 3rd-party applications.
468
+
439
469
  :param fields: A set of fields to make up a :py:class:`TableSchema <tracdap.rt.metadata.TableSchema>`
440
470
  :param label: An optional label (of type str) for a model input schema. Default value: None.
471
+ :param optional: Mark this input as an optional model input
472
+ :param input_props: Associate key-value properties with this input (not used by the TRAC engine)
441
473
  :return: A model input schema, suitable for returning from :py:meth:`TracModel.define_inputs`
442
474
 
443
475
  :type fields: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>` |
444
476
  List[:py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`]
477
+ :type label: Optional[str]
478
+ :type optional: bool
479
+ :type input_props: Optional[Dict[str, Any]]
445
480
  :rtype: :py:class:`ModelInputSchema <tracdap.rt.metadata.ModelInputSchema>`
446
481
  """
447
482
 
448
483
  sa = _StaticApiHook.get_instance()
449
- return sa.define_input_table(*fields, label=label)
484
+ return sa.define_input_table(*fields, label=label, optional=optional, input_props=input_props)
450
485
 
451
486
 
452
487
  def declare_input_table(
@@ -457,16 +492,24 @@ def declare_input_table(
457
492
  .. deprecated:: 0.4.4
458
493
  Use :py:func:`define_input_table` instead.
459
494
 
495
+ This function is deprecated and will be removed in a future version.
496
+ Please use :py:func:`define_input_table() <tracdap.rt.api.define_input_table>` instead.
497
+
460
498
  :type fields: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>` |
461
499
  List[:py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`]
462
500
  :rtype: :py:class:`ModelInputSchema <tracdap.rt.metadata.ModelInputSchema>`
463
501
  """
464
502
 
503
+ print("TRAC Warning: declare_input_table() is deprecated, please use define_input_table()", file=sys.stderr)
504
+
465
505
  return define_input_table(*fields)
466
506
 
467
507
 
468
508
  def define_output_table(
469
- *fields: _tp.Union[FieldSchema, _tp.List[FieldSchema]], label: _tp.Optional[str] = None) \
509
+ *fields: _tp.Union[FieldSchema, _tp.List[FieldSchema]],
510
+ label: _tp.Optional[str] = None,
511
+ optional: bool = False,
512
+ output_props: _tp.Optional[_tp.Dict[str, _tp.Any]] = None) \
470
513
  -> ModelOutputSchema:
471
514
 
472
515
  """
@@ -475,17 +518,26 @@ def define_output_table(
475
518
  Fields can be supplied either as individual arguments to this function or as a list.
476
519
  Individual fields should be defined using :py:func:`define_field` or the shorthand alias :py:func:`F`.
477
520
 
521
+ You can use output_props to associate arbitrary key-value properties with this model output.
522
+ These properties are not used by the TRAC engine, but are stored in the model metadata for
523
+ the output and can be used as needed in 3rd-party applications.
524
+
478
525
  :param fields: A set of fields to make up a :py:class:`TableSchema <tracdap.rt.metadata.TableSchema>`
479
526
  :param label: An optional label (of type str) for a model output schema. Default value: None.
527
+ :param optional: Mark this output as an optional model output
528
+ :param output_props: Associate key-value properties with this output (not used by the TRAC engine)
480
529
  :return: A model output schema, suitable for returning from :py:meth:`TracModel.define_outputs`
481
530
 
482
531
  :type fields: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>` |
483
532
  List[:py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`]
533
+ :type label: Optional[str]
534
+ :type optional: bool
535
+ :type output_props: Optional[Dict[str, Any]]
484
536
  :rtype: :py:class:`ModelOutputSchema <tracdap.rt.metadata.ModelOutputSchema>`
485
537
  """
486
538
 
487
539
  sa = _StaticApiHook.get_instance()
488
- return sa.define_output_table(*fields, label=label)
540
+ return sa.define_output_table(*fields, label=label, optional=optional, output_props=output_props)
489
541
 
490
542
 
491
543
  def declare_output_table(
@@ -496,9 +548,17 @@ def declare_output_table(
496
548
  .. deprecated:: 0.4.4
497
549
  Use :py:func:`define_output_table` instead.
498
550
 
551
+ This function is deprecated and will be removed in a future version.
552
+ Please use :py:func:`define_output_table() <tracdap.rt.api.define_output_table>` instead.
553
+
554
+ This function is deprecated and will be removed in a future version.
555
+ Please use define_output_table() instead.
556
+
499
557
  :type fields: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>` |
500
558
  List[:py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`]
501
559
  :rtype: :py:class:`ModelOutputSchema <tracdap.rt.metadata.ModelOutputSchema>`
502
560
  """
503
561
 
562
+ print("TRAC Warning: declare_output_table() is deprecated, please use define_output_table()", file==sys.stderr)
563
+
504
564
  return define_output_table(*fields)
@@ -5,6 +5,7 @@ from .common import PluginConfig
5
5
  from .common import PlatformInfo
6
6
  from .common import AuthenticationConfig
7
7
  from .common import StorageConfig
8
+ from .common import ServiceConfig
8
9
 
9
10
  from .runtime import RuntimeConfig
10
11
  from .runtime import SparkSettings
@@ -21,10 +22,9 @@ from .platform import GatewayConfig
21
22
  from .platform import RouteConfig
22
23
  from .platform import RoutingMatch
23
24
  from .platform import RoutingTarget
24
- from .platform import ServiceConfig
25
25
  from .platform import DeploymentConfig
26
26
 
27
+ from .job import JobConfig
28
+
27
29
  from .result import TagUpdateList
28
30
  from .result import JobResult
29
-
30
- from .job import JobConfig
@@ -66,3 +66,13 @@ class StorageConfig:
66
66
  defaultBucket: str = None
67
67
 
68
68
  defaultFormat: str = None
69
+
70
+
71
+ @_dc.dataclass
72
+ class ServiceConfig:
73
+
74
+ enabled: _tp.Optional[bool] = None
75
+
76
+ alias: str = None
77
+
78
+ port: int = None
@@ -11,26 +11,26 @@ from .common import * # noqa
11
11
 
12
12
  class RoutingProtocol(_enum.Enum):
13
13
 
14
- PROTOCOL_NOT_SET = 0,
14
+ PROTOCOL_NOT_SET = 0
15
15
 
16
- HTTP = 1,
16
+ HTTP = 1
17
17
 
18
- GRPC = 2,
18
+ GRPC = 2
19
19
 
20
- GRPC_WEB = 3,
20
+ GRPC_WEB = 3
21
21
 
22
- REST = 4,
22
+ REST = 4
23
23
 
24
24
 
25
25
  class DeploymentLayout(_enum.Enum):
26
26
 
27
- LAYOUT_NOT_SET = 0,
27
+ LAYOUT_NOT_SET = 0
28
28
 
29
- SANDBOX = 1,
29
+ SANDBOX = 1
30
30
 
31
- HOSTED = 2,
31
+ HOSTED = 2
32
32
 
33
- CUSTOM = 3,
33
+ CUSTOM = 3
34
34
 
35
35
 
36
36
  @_dc.dataclass
@@ -153,16 +153,6 @@ class RoutingTarget:
153
153
  path: str = None
154
154
 
155
155
 
156
- @_dc.dataclass
157
- class ServiceConfig:
158
-
159
- enabled: _tp.Optional[bool] = None
160
-
161
- alias: str = None
162
-
163
- port: int = None
164
-
165
-
166
156
  @_dc.dataclass
167
157
  class DeploymentConfig:
168
158
 
@@ -20,6 +20,8 @@ class RuntimeConfig:
20
20
 
21
21
  sparkSettings: SparkSettings = None
22
22
 
23
+ runtimeApi: ServiceConfig = None
24
+
23
25
 
24
26
  @_dc.dataclass
25
27
  class SparkSettings:
@@ -0,0 +1,34 @@
1
+ # Copyright 2024 Accenture Global Solutions Limited
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import abc as _abc
16
+
17
+
18
+ class IConfigLoader:
19
+
20
+ @_abc.abstractmethod
21
+ def has_config_file(self, config_url: str) -> bool:
22
+ pass
23
+
24
+ @_abc.abstractmethod
25
+ def load_config_file(self, config_url: str) -> bytes:
26
+ pass
27
+
28
+ @_abc.abstractmethod
29
+ def has_config_dict(self, config_url: str) -> bool:
30
+ pass
31
+
32
+ @_abc.abstractmethod
33
+ def load_config_dict(self, config_url: str) -> dict:
34
+ pass
tracdap/rt/ext/embed.py CHANGED
@@ -13,9 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  import tracdap.rt.config as _cfg
16
- import tracdap.rt.ext._guard as _guard
17
-
18
- # Dependency back into the main runtime implementation
16
+ import tracdap.rt._impl.guard_rails as _guard # noqa
19
17
  import tracdap.rt._exec.runtime as _rt # noqa
20
18
 
21
19
 
tracdap/rt/ext/plugins.py CHANGED
@@ -19,7 +19,8 @@ import importlib as _il
19
19
 
20
20
  import tracdap.rt.config as _cfg
21
21
  import tracdap.rt.exceptions as _ex
22
- import tracdap.rt.ext._guard as _guard
22
+ import tracdap.rt._impl.guard_rails as _guard # noqa
23
+ from tracdap.rt.exceptions import EStartup
23
24
 
24
25
 
25
26
  class PluginManager:
@@ -29,6 +30,8 @@ class PluginManager:
29
30
  __log = _log.getLogger(f"{__name__}.PluginManager")
30
31
 
31
32
  __core_registered = False
33
+ __3rd_party_registered = list()
34
+
32
35
  __plugins = {}
33
36
 
34
37
  @classmethod
@@ -40,17 +43,42 @@ class PluginManager:
40
43
  return
41
44
 
42
45
  cls.__log.info("Register core plugins...")
46
+ cls.__register_plugin_package("tracdap.rt._plugins")
47
+
48
+ cls.__core_registered = True
49
+
50
+ @classmethod
51
+ def register_plugin_package(cls, plugin_package_name: str):
52
+
53
+ _guard.run_model_guard()
43
54
 
44
- plugins_package = _il.import_module("tracdap.rt._plugins")
55
+ if plugin_package_name in cls.__3rd_party_registered:
56
+ return
57
+
58
+ if plugin_package_name.startswith("tracdap."):
59
+ raise EStartup("3rd party plugins cannot be registered from the tracdap namespace")
60
+
61
+ cls.__log.info(f"Register plugins from package [{plugin_package_name}]...")
62
+ cls.__register_plugin_package(plugin_package_name)
63
+
64
+ cls.__3rd_party_registered.append(plugin_package_name)
65
+
66
+ @classmethod
67
+ def __register_plugin_package(cls, plugin_package_name: str):
68
+
69
+ _guard.run_model_guard()
70
+
71
+ plugins_package = _il.import_module(plugin_package_name)
45
72
 
46
73
  for module in _pkg.iter_modules(plugins_package.__path__):
74
+
75
+ module_name = f"{plugin_package_name}.{module.name}"
76
+
47
77
  try:
48
- module_name = f"tracdap.rt._plugins.{module.name}"
49
78
  _il.import_module(module_name)
50
79
  except ImportError:
51
- pass # Ignore plugins that fail to load
52
-
53
- cls.__core_registered = True
80
+ # It is not a fatal error if some plugins fail to load
81
+ cls.__log.warning(f"Failed to load plugins from module [{module_name}]")
54
82
 
55
83
  @classmethod
56
84
  def register_plugin(
@@ -94,3 +122,16 @@ class PluginManager:
94
122
  plugin = plugin_class(config.properties)
95
123
 
96
124
  return plugin
125
+
126
+ @classmethod
127
+ def load_config_plugin(cls,
128
+ service_type: _tp.Type[T_SERVICE],
129
+ config: _cfg.PluginConfig) \
130
+ -> T_SERVICE:
131
+
132
+ # Currently config plugins are loaded the same way as regular plugins
133
+ # However, regular plugins can be modified to take ConfigManager as an init parameter
134
+ # This is useful for loading secondary config files needed in particularly plugins
135
+ # Config plugins can never do this, because the config manager is not yet initialized
136
+
137
+ return cls.load_plugin(service_type, config)
tracdap/rt/launch/cli.py CHANGED
@@ -16,7 +16,7 @@ import argparse
16
16
  import pathlib
17
17
 
18
18
 
19
- def cli_args():
19
+ def _cli_args():
20
20
 
21
21
  parser = argparse.ArgumentParser(
22
22
  prog="python -m tracdap.rt.launch",
@@ -45,12 +45,14 @@ def cli_args():
45
45
  parser.add_argument(
46
46
  "--scratch-dir", dest="scratch_dir", type=pathlib.Path, required=False,
47
47
  help="Scratch directory for working files" +
48
- " (if not supplied the system's temp location will be used)"
49
- )
48
+ " (if not supplied the system's temp location will be used)")
50
49
 
51
50
  parser.add_argument(
52
51
  "--scratch-dir-persist", dest="scratch_dir_persist", default=False, action="store_true",
53
- help="Do not clean up the scratch location on exit"
54
- )
52
+ help="Do not clean up the scratch location on exit")
53
+
54
+ parser.add_argument(
55
+ "--plugin-package", dest="plugin_packages", type=str, action="append",
56
+ help="Do not clean up the scratch location on exit")
55
57
 
56
58
  return parser.parse_args()
@@ -23,7 +23,7 @@ import tracdap.rt._impl.config_parser as _cparse # noqa
23
23
  import tracdap.rt._impl.util as _util # noqa
24
24
  import tracdap.rt._exec.runtime as _runtime # noqa
25
25
 
26
- from .cli import cli_args
26
+ from .cli import _cli_args
27
27
 
28
28
 
29
29
  def _resolve_config_file(
@@ -53,13 +53,19 @@ def _resolve_config_file(
53
53
  return _pathlib.Path(config_path)
54
54
 
55
55
 
56
+ def _optional_arg(launch_args: _tp.Dict[str, _tp.Any], arg_name: str) -> _tp.Any:
57
+
58
+ return launch_args.get(arg_name, None)
59
+
60
+
56
61
  def launch_model(
57
62
  model_class: _api.TracModel.__class__,
58
63
  job_config: _tp.Union[str, _pathlib.Path],
59
- sys_config: _tp.Union[str, _pathlib.Path]):
64
+ sys_config: _tp.Union[str, _pathlib.Path],
65
+ **launch_args):
60
66
 
61
67
  """
62
- Launch an individual model component by class (embedded launch)
68
+ Launch an individual model using its Python class
63
69
 
64
70
  This launch method launches the supplied model class directly, it must be called
65
71
  from the Python codebase containing the model class. The TRAC runtime will launch
@@ -77,6 +83,7 @@ def launch_model(
77
83
  :param model_class: The model class that will be launched
78
84
  :param job_config: Path to the job configuration file
79
85
  :param sys_config: Path to the system configuration file
86
+ :param launch_args: Additional keyword args to control behavior of the TRAC runtime (not normally required)
80
87
  """
81
88
 
82
89
  model_file = _inspect.getfile(model_class)
@@ -85,7 +92,10 @@ def launch_model(
85
92
  _sys_config = _resolve_config_file(sys_config, model_dir)
86
93
  _job_config = _resolve_config_file(job_config, model_dir)
87
94
 
88
- runtime_instance = _runtime.TracRuntime(_sys_config, dev_mode=True)
95
+ plugin_package = _optional_arg(launch_args, 'plugin_package')
96
+ plugin_packages = [plugin_package] if plugin_package else None
97
+
98
+ runtime_instance = _runtime.TracRuntime(_sys_config, dev_mode=True, plugin_packages=plugin_packages)
89
99
  runtime_instance.pre_start()
90
100
 
91
101
  job = runtime_instance.load_job_config(_job_config, model_class=model_class)
@@ -98,12 +108,25 @@ def launch_model(
98
108
  def launch_job(
99
109
  job_config: _tp.Union[str, _pathlib.Path],
100
110
  sys_config: _tp.Union[str, _pathlib.Path],
101
- dev_mode: bool = False):
111
+ dev_mode: bool = False,
112
+ **launch_args):
113
+
114
+ """
115
+ Launch a TRAC job using external configuration files
116
+
117
+ :param job_config: Path to the job configuration file
118
+ :param sys_config: Path to the system configuration file
119
+ :param dev_mode: Whether to launch in dev mode (applies dev mode translation to the job inputs)
120
+ :param launch_args: Additional keyword args to control behavior of the TRAC runtime (not normally required)
121
+ """
102
122
 
103
123
  _sys_config = _resolve_config_file(sys_config, None)
104
124
  _job_config = _resolve_config_file(job_config, None)
105
125
 
106
- runtime_instance = _runtime.TracRuntime(_sys_config, dev_mode=dev_mode)
126
+ plugin_package = _optional_arg(launch_args, 'plugin_package')
127
+ plugin_packages = [plugin_package] if plugin_package else None
128
+
129
+ runtime_instance = _runtime.TracRuntime(_sys_config, dev_mode=dev_mode, plugin_packages=plugin_packages)
107
130
  runtime_instance.pre_start()
108
131
 
109
132
  job = runtime_instance.load_job_config(_job_config)
@@ -115,10 +138,13 @@ def launch_job(
115
138
 
116
139
  def launch_cli():
117
140
 
118
- launch_args = cli_args()
141
+ """
142
+ Launch the TRAC runtime using the command line interface
143
+ """
144
+
145
+ launch_args = _cli_args()
119
146
 
120
147
  _sys_config = _resolve_config_file(launch_args.sys_config, None)
121
- _job_config = _resolve_config_file(launch_args.job_config, None)
122
148
 
123
149
  runtime_instance = _runtime.TracRuntime(
124
150
  _sys_config,
@@ -126,12 +152,23 @@ def launch_cli():
126
152
  job_result_dir=launch_args.job_result_dir,
127
153
  job_result_format=launch_args.job_result_format,
128
154
  scratch_dir=launch_args.scratch_dir,
129
- scratch_dir_persist=launch_args.scratch_dir_persist)
155
+ scratch_dir_persist=launch_args.scratch_dir_persist,
156
+ plugin_packages=launch_args.plugin_packages)
130
157
 
131
158
  runtime_instance.pre_start()
132
159
 
133
- job = runtime_instance.load_job_config(_job_config)
160
+ if launch_args.job_config is not None:
161
+ _job_config = _resolve_config_file(launch_args.job_config, None)
162
+ job = runtime_instance.load_job_config(_job_config)
163
+ else:
164
+ job = None
134
165
 
135
166
  with runtime_instance as rt:
136
- rt.submit_job(job)
137
- rt.wait_for_job(job.jobId)
167
+
168
+ if job is not None:
169
+ rt.submit_job(job)
170
+
171
+ if rt.is_oneshot():
172
+ rt.wait_for_job(job.jobId)
173
+ else:
174
+ rt.run_until_done()