tracdap-runtime 0.6.5__py3-none-any.whl → 0.7.0rc1__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.
- tracdap/rt/__init__.py +6 -5
- tracdap/rt/_exec/actors.py +6 -5
- tracdap/rt/_exec/context.py +278 -110
- tracdap/rt/_exec/dev_mode.py +237 -143
- tracdap/rt/_exec/engine.py +223 -64
- tracdap/rt/_exec/functions.py +31 -6
- tracdap/rt/_exec/graph.py +15 -5
- tracdap/rt/_exec/graph_builder.py +301 -203
- tracdap/rt/_exec/runtime.py +13 -10
- tracdap/rt/_exec/server.py +6 -5
- tracdap/rt/_impl/__init__.py +6 -5
- tracdap/rt/_impl/config_parser.py +17 -9
- tracdap/rt/_impl/data.py +284 -172
- tracdap/rt/_impl/ext/__init__.py +14 -0
- tracdap/rt/_impl/ext/sql.py +117 -0
- tracdap/rt/_impl/ext/storage.py +58 -0
- tracdap/rt/_impl/grpc/__init__.py +6 -5
- tracdap/rt/_impl/grpc/codec.py +6 -5
- tracdap/rt/_impl/grpc/tracdap/metadata/job_pb2.py +62 -54
- tracdap/rt/_impl/grpc/tracdap/metadata/job_pb2.pyi +37 -2
- tracdap/rt/_impl/guard_rails.py +6 -5
- tracdap/rt/_impl/models.py +6 -5
- tracdap/rt/_impl/repos.py +6 -5
- tracdap/rt/_impl/schemas.py +6 -5
- tracdap/rt/_impl/shim.py +6 -5
- tracdap/rt/_impl/static_api.py +30 -16
- tracdap/rt/_impl/storage.py +8 -7
- tracdap/rt/_impl/type_system.py +6 -5
- tracdap/rt/_impl/util.py +16 -5
- tracdap/rt/_impl/validation.py +72 -18
- tracdap/rt/_plugins/__init__.py +6 -5
- tracdap/rt/_plugins/_helpers.py +6 -5
- tracdap/rt/_plugins/config_local.py +6 -5
- tracdap/rt/_plugins/format_arrow.py +6 -5
- tracdap/rt/_plugins/format_csv.py +6 -5
- tracdap/rt/_plugins/format_parquet.py +6 -5
- tracdap/rt/_plugins/repo_git.py +6 -5
- tracdap/rt/_plugins/repo_local.py +6 -5
- tracdap/rt/_plugins/repo_pypi.py +6 -5
- tracdap/rt/_plugins/storage_aws.py +6 -5
- tracdap/rt/_plugins/storage_azure.py +6 -5
- tracdap/rt/_plugins/storage_gcp.py +6 -5
- tracdap/rt/_plugins/storage_local.py +6 -5
- tracdap/rt/_plugins/storage_sql.py +418 -0
- tracdap/rt/_plugins/storage_sql_dialects.py +118 -0
- tracdap/rt/_version.py +7 -6
- tracdap/rt/api/__init__.py +23 -5
- tracdap/rt/api/experimental.py +85 -37
- tracdap/rt/api/hook.py +16 -5
- tracdap/rt/api/model_api.py +110 -90
- tracdap/rt/api/static_api.py +142 -100
- tracdap/rt/config/common.py +26 -27
- tracdap/rt/config/job.py +5 -6
- tracdap/rt/config/platform.py +41 -42
- tracdap/rt/config/result.py +5 -6
- tracdap/rt/config/runtime.py +6 -7
- tracdap/rt/exceptions.py +13 -7
- tracdap/rt/ext/__init__.py +6 -5
- tracdap/rt/ext/config.py +6 -5
- tracdap/rt/ext/embed.py +6 -5
- tracdap/rt/ext/plugins.py +6 -5
- tracdap/rt/ext/repos.py +6 -5
- tracdap/rt/ext/storage.py +6 -5
- tracdap/rt/launch/__init__.py +10 -5
- tracdap/rt/launch/__main__.py +6 -5
- tracdap/rt/launch/cli.py +6 -5
- tracdap/rt/launch/launch.py +38 -15
- tracdap/rt/metadata/__init__.py +4 -0
- tracdap/rt/metadata/common.py +2 -3
- tracdap/rt/metadata/custom.py +3 -4
- tracdap/rt/metadata/data.py +30 -31
- tracdap/rt/metadata/file.py +6 -7
- tracdap/rt/metadata/flow.py +22 -23
- tracdap/rt/metadata/job.py +89 -45
- tracdap/rt/metadata/model.py +26 -27
- tracdap/rt/metadata/object.py +11 -12
- tracdap/rt/metadata/object_id.py +23 -24
- tracdap/rt/metadata/resource.py +0 -1
- tracdap/rt/metadata/search.py +15 -16
- tracdap/rt/metadata/stoarge.py +22 -23
- tracdap/rt/metadata/tag.py +8 -9
- tracdap/rt/metadata/tag_update.py +11 -12
- tracdap/rt/metadata/type.py +38 -38
- {tracdap_runtime-0.6.5.dist-info → tracdap_runtime-0.7.0rc1.dist-info}/LICENSE +1 -1
- {tracdap_runtime-0.6.5.dist-info → tracdap_runtime-0.7.0rc1.dist-info}/METADATA +4 -2
- tracdap_runtime-0.7.0rc1.dist-info/RECORD +121 -0
- {tracdap_runtime-0.6.5.dist-info → tracdap_runtime-0.7.0rc1.dist-info}/WHEEL +1 -1
- tracdap_runtime-0.6.5.dist-info/RECORD +0 -116
- {tracdap_runtime-0.6.5.dist-info → tracdap_runtime-0.7.0rc1.dist-info}/top_level.txt +0 -0
tracdap/rt/api/static_api.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
1
|
+
# Licensed to the Fintech Open Source Foundation (FINOS) under one or
|
2
|
+
# more contributor license agreements. See the NOTICE file distributed
|
3
|
+
# with this work for additional information regarding copyright ownership.
|
4
|
+
# FINOS licenses this file to you under the Apache License, Version 2.0
|
5
|
+
# (the "License"); you may not use this file except in compliance with the
|
6
|
+
# License. You may obtain a copy of the License at
|
6
7
|
#
|
7
8
|
# http://www.apache.org/licenses/LICENSE-2.0
|
8
9
|
#
|
@@ -26,29 +27,30 @@ from .hook import _Named
|
|
26
27
|
from tracdap.rt.metadata import * # DOCGEN_REMOVE
|
27
28
|
|
28
29
|
|
29
|
-
def define_attributes(*
|
30
|
+
def define_attributes(*attributes: _tp.Union[TagUpdate, _tp.List[TagUpdate]]) -> _tp.List[TagUpdate]:
|
30
31
|
|
31
32
|
"""
|
32
|
-
|
33
|
+
Define a set of attributes to catalogue and describe a model
|
33
34
|
|
34
35
|
.. note::
|
35
36
|
This is an experimental API that is not yet stabilised, expect changes in future versions of TRAC
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
Model attributes can be defined using :py:func:`define_attribute` or the shorthand alias :py:func:`A`.
|
39
|
+
This function takes a number of model attributes, either as individual arguments or as a list,
|
40
|
+
and arranges them in the format required by
|
41
|
+
:py:meth:`TracModel.define_attributes() <tracdap.rt.api.TracModel.define_attributes>`.
|
40
42
|
|
41
|
-
:param
|
43
|
+
:param attributes: The attributes that will be defined, either as individual arguments or as a list
|
42
44
|
:return: A set of model attributes, in the correct format to return from
|
43
|
-
:py:meth:`TracModel.define_attributes
|
45
|
+
:py:meth:`TracModel.define_attributes() <tracdap.rt.api.TracModel.define_attributes>`
|
44
46
|
|
45
|
-
:type
|
47
|
+
:type attributes: :py:class:`TagUpdate <tracdap.rt.metadata.TagUpdate>` |
|
46
48
|
List[:py:class:`TagUpdate <tracdap.rt.metadata.TagUpdate>`]
|
47
49
|
:rtype: List[:py:class:`TagUpdate <tracdap.rt.metadata.TagUpdate>`]
|
48
50
|
"""
|
49
51
|
|
50
52
|
sa = _StaticApiHook.get_instance()
|
51
|
-
return sa.define_attributes(*
|
53
|
+
return sa.define_attributes(*attributes)
|
52
54
|
|
53
55
|
|
54
56
|
def define_attribute(
|
@@ -63,23 +65,23 @@ def define_attribute(
|
|
63
65
|
.. note::
|
64
66
|
This is an experimental API that is not yet stabilised, expect changes in future versions of TRAC
|
65
67
|
|
66
|
-
Model attributes can be defined using this
|
67
|
-
|
68
|
-
|
69
|
-
The categorical flag can be applied to STRING attributes
|
68
|
+
Model attributes can be defined using this function or the shorthand alias :py:func:`A`.
|
69
|
+
A name and value are always required to define an attribute.
|
70
|
+
Attribute type is required for multivalued attributes but is optional otherwise.
|
71
|
+
The categorical flag can be applied to STRING attributes to mark them as categorical.
|
70
72
|
|
71
|
-
|
72
|
-
either as
|
73
|
+
Model attributes can be passed to :py:func:`define_attributes`,
|
74
|
+
either as individual arguments or as a list, to create the set of attributes for a model.
|
73
75
|
|
74
76
|
:param attr_name: The attribute name
|
75
77
|
:param attr_value: The attribute value (as a raw Python value)
|
76
78
|
:param attr_type: The TRAC type for this attribute (optional, except for multivalued attributes)
|
77
79
|
:param categorical: A flag to indicate whether this attribute is categorical
|
78
|
-
:return:
|
80
|
+
:return: A model attribute, in the format understood by the TRAC platform
|
79
81
|
|
80
82
|
:type attr_name: str
|
81
83
|
:type attr_value: Any
|
82
|
-
:type attr_type:
|
84
|
+
:type attr_type: :py:class:`BasicType <tracdap.rt.metadata.BasicType>` | None
|
83
85
|
:type categorical: bool
|
84
86
|
:rtype: :py:class:`TagUpdate <tracdap.rt.metadata.TagUpdate>`
|
85
87
|
"""
|
@@ -102,7 +104,7 @@ def A( # noqa
|
|
102
104
|
|
103
105
|
:type attr_name: str
|
104
106
|
:type attr_value: Any
|
105
|
-
:type attr_type:
|
107
|
+
:type attr_type: :py:class:`BasicType <tracdap.rt.metadata.BasicType>` | None
|
106
108
|
:type categorical: bool
|
107
109
|
:rtype: :py:class:`TagUpdate <tracdap.rt.metadata.TagUpdate>`
|
108
110
|
"""
|
@@ -111,7 +113,7 @@ def A( # noqa
|
|
111
113
|
|
112
114
|
|
113
115
|
def define_parameter(
|
114
|
-
param_name: str, param_type: _tp.Union[
|
116
|
+
param_name: str, param_type: _tp.Union[BasicType, TypeDescriptor],
|
115
117
|
label: str, default_value: _tp.Optional[_tp.Any] = None,
|
116
118
|
*, param_props: _tp.Optional[_tp.Dict[str, _tp.Any]] = None) \
|
117
119
|
-> _Named[ModelParameter]:
|
@@ -119,23 +121,25 @@ def define_parameter(
|
|
119
121
|
"""
|
120
122
|
Define an individual model parameter
|
121
123
|
|
122
|
-
|
123
|
-
|
124
|
-
to
|
125
|
-
|
124
|
+
Model parameters can be defined using this method or the shorthand alias :py:func:`P`.
|
125
|
+
Name, type and label are always required to define a parameter. The parameter name
|
126
|
+
is used to set up parameters in a job and to access parameter values at runtime using
|
127
|
+
:py:meth:`TracContext.get_parameter() <tracdap.rt.api.TracContext.get_parameter>`.
|
126
128
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
Use the label property to add a descriptive label to a model parameter. If a default value
|
130
|
+
is specified, the model parameter becomes optional. It is ok to omit optional parameters
|
131
|
+
when running models or setting up jobs, in which case the default value will be used.
|
132
|
+
If no default is specified then the model parameter becomes mandatory, a value must always
|
133
|
+
be supplied in order to execute the model. TRAC will apply type coercion where possible to
|
134
|
+
ensure the default value matches the parameter type, if the default value cannot be coerced
|
135
|
+
to match the parameter type then model validation will fail.
|
132
136
|
|
133
137
|
You can use param_props to associate arbitrary key-value properties with this model parameter.
|
134
138
|
These properties are not used by the TRAC engine, but are stored in the model metadata for
|
135
139
|
the parameter and can be used as needed in 3rd-party applications.
|
136
140
|
|
137
|
-
|
138
|
-
either as
|
141
|
+
Model parameters can be passed to :py:func:`define_parameters`,
|
142
|
+
either as individual arguments or as a list, to create the set of parameters for a model.
|
139
143
|
|
140
144
|
:param param_name: The parameter name, used to identify the parameter in code (must be a valid identifier)
|
141
145
|
:param param_type: The parameter type, expressed in the TRAC type system
|
@@ -145,11 +149,12 @@ def define_parameter(
|
|
145
149
|
:return: A named model parameter, suitable for passing to :py:func:`define_parameters`
|
146
150
|
|
147
151
|
:type param_name: str
|
148
|
-
:type param_type: :py:class:`
|
149
|
-
:py:class:`
|
152
|
+
:type param_type: :py:class:`BasicType <tracdap.rt.metadata.BasicType>` |
|
153
|
+
:py:class:`TypeDescriptor <tracdap.rt.metadata.TypeDescriptor>`
|
154
|
+
|
150
155
|
:type label: str
|
151
|
-
:type default_value:
|
152
|
-
:type param_props:
|
156
|
+
:type default_value: Any | None
|
157
|
+
:type param_props: Dict[str, Any] | None
|
153
158
|
:rtype: _Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]
|
154
159
|
"""
|
155
160
|
|
@@ -159,7 +164,7 @@ def define_parameter(
|
|
159
164
|
|
160
165
|
def declare_parameter(
|
161
166
|
param_name: str,
|
162
|
-
param_type: _tp.Union[
|
167
|
+
param_type: _tp.Union[BasicType, TypeDescriptor],
|
163
168
|
label: str,
|
164
169
|
default_value: _tp.Optional[_tp.Any] = None) \
|
165
170
|
-> _Named[ModelParameter]:
|
@@ -172,11 +177,14 @@ def declare_parameter(
|
|
172
177
|
Please use :py:func:`define_parameter() <tracdap.rt.api.define_parameter>` instead.
|
173
178
|
|
174
179
|
:type param_name: str
|
175
|
-
:type param_type: :py:class:`
|
176
|
-
:py:class:`
|
180
|
+
:type param_type: :py:class:`BasicType <tracdap.rt.metadata.BasicType>` |
|
181
|
+
:py:class:`TypeDescriptor <tracdap.rt.metadata.TypeDescriptor>`
|
182
|
+
|
177
183
|
:type label: str
|
178
|
-
:type default_value:
|
184
|
+
:type default_value: Any | None
|
179
185
|
:rtype: _Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]
|
186
|
+
|
187
|
+
:display: False
|
180
188
|
"""
|
181
189
|
|
182
190
|
print("TRAC Warning: declare_parameter() is deprecated, please use define_parameter()", file=sys.stderr)
|
@@ -186,7 +194,7 @@ def declare_parameter(
|
|
186
194
|
|
187
195
|
def P( # noqa
|
188
196
|
param_name: str,
|
189
|
-
param_type: _tp.Union[
|
197
|
+
param_type: _tp.Union[BasicType, TypeDescriptor],
|
190
198
|
label: str,
|
191
199
|
default_value: _tp.Optional[_tp.Any] = None,
|
192
200
|
*, param_props: _tp.Optional[_tp.Dict[str, _tp.Any]] = None) \
|
@@ -196,11 +204,12 @@ def P( # noqa
|
|
196
204
|
Shorthand alias for :py:func:`define_parameter`
|
197
205
|
|
198
206
|
:type param_name: str
|
199
|
-
:type param_type: :py:class:`
|
200
|
-
:py:class:`
|
207
|
+
:type param_type: :py:class:`BasicType <tracdap.rt.metadata.BasicType>` |
|
208
|
+
:py:class:`TypeDescriptor <tracdap.rt.metadata.TypeDescriptor>`
|
201
209
|
:type label: str
|
202
|
-
:type default_value:
|
203
|
-
:type param_props:
|
210
|
+
:type default_value: Any | None
|
211
|
+
:type param_props: Dict[str, Any] | None
|
212
|
+
|
204
213
|
:rtype: _Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]
|
205
214
|
"""
|
206
215
|
|
@@ -208,27 +217,28 @@ def P( # noqa
|
|
208
217
|
|
209
218
|
|
210
219
|
def define_parameters(
|
211
|
-
*
|
220
|
+
*parameters: _tp.Union[_Named[ModelParameter], _tp.List[_Named[ModelParameter]]]) \
|
212
221
|
-> _tp.Dict[str, ModelParameter]:
|
213
222
|
|
214
223
|
"""
|
215
|
-
Defined
|
224
|
+
Defined the set of parameters used by a model
|
216
225
|
|
217
|
-
|
218
|
-
|
219
|
-
|
226
|
+
Model parameters can be defined using :py:func:`define_parameter` or the shorthand alias :py:func:`P`.
|
227
|
+
This function takes a number of parameters, either as individual arguments or as a list,
|
228
|
+
and arranges them in the format required by
|
229
|
+
:py:meth:`TracModel.define_parameters() <tracdap.rt.api.TracModel.define_parameters>`
|
220
230
|
|
221
|
-
:param
|
231
|
+
:param parameters: The parameters that will be defined, either as individual arguments or as a list
|
222
232
|
:return: A set of model parameters, in the correct format to return from
|
223
|
-
:py:meth:`TracModel.define_parameters
|
233
|
+
:py:meth:`TracModel.define_parameters() <tracdap.rt.api.TracModel.define_parameters>`
|
224
234
|
|
225
|
-
:type
|
235
|
+
:type parameters: _Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`] |
|
226
236
|
List[_Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]]
|
227
237
|
:rtype: Dict[str, :py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]
|
228
238
|
"""
|
229
239
|
|
230
240
|
sa = _StaticApiHook.get_instance()
|
231
|
-
return sa.define_parameters(*
|
241
|
+
return sa.define_parameters(*parameters)
|
232
242
|
|
233
243
|
|
234
244
|
def declare_parameters(
|
@@ -237,7 +247,7 @@ def declare_parameters(
|
|
237
247
|
|
238
248
|
"""
|
239
249
|
.. deprecated:: 0.4.4
|
240
|
-
Use :py:func:`define_parameters` instead
|
250
|
+
Use :py:func:`define_parameters` instead
|
241
251
|
|
242
252
|
This function is deprecated and will be removed in a future version.
|
243
253
|
Please use :py:func:`define_parameters() <tracdap.rt.api.define_parameters>` instead.
|
@@ -245,6 +255,8 @@ def declare_parameters(
|
|
245
255
|
:type params: _Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`] |
|
246
256
|
List[_Named[:py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]]
|
247
257
|
:rtype: Dict[str, :py:class:`ModelParameter <tracdap.rt.metadata.ModelParameter>`]
|
258
|
+
|
259
|
+
:display: False
|
248
260
|
"""
|
249
261
|
|
250
262
|
print("TRAC Warning: declare_parameters() is deprecated, please use define_parameters()", file=sys.stderr)
|
@@ -264,22 +276,24 @@ def define_field(
|
|
264
276
|
-> FieldSchema:
|
265
277
|
|
266
278
|
"""
|
267
|
-
Define
|
279
|
+
Define an individual field for use in a schema
|
268
280
|
|
269
|
-
Individual fields in a
|
281
|
+
Individual fields in a schema can be defined using this method or the shorthand alias :py:func:`F`.
|
270
282
|
The name, type and label of a field are always required.
|
271
283
|
The business_key and categorical flags are false by default.
|
272
284
|
The not_null flag is false by default unless the field is a business key, in which case it is true by default.
|
273
285
|
Explicitly specifying not_null=False for a business key will cause a validation error.
|
274
286
|
Format code is optional.
|
275
287
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
288
|
+
So long as field order is not specified for any field in a schema, field ordering will
|
289
|
+
be assigned automatically. If field orders are specified explicitly, the fields in a schema
|
290
|
+
must have a contiguous ordering starting at 0. When updating a model it is good practice
|
291
|
+
to leave existing fields in order and add any new fields to the end of the list.
|
280
292
|
|
281
|
-
|
282
|
-
|
293
|
+
Schema fields can be passed to :py:func:`define_schema`, either as individual arguments or as a list,
|
294
|
+
to create a :py:class:`SchemaDefinition <tracdap.rt.metadata.SchemaDefinition>`. To define the
|
295
|
+
inputs or outputs of a :py:class:`TracModel <tracdap.rt.api.TracModel>`, fields can also be
|
296
|
+
passed directly to :py:func:`define_input_table` or :py:func:`define_output_table`.
|
283
297
|
|
284
298
|
:param field_name: The field's name, used as the field identifier in code and queries (must be a valid identifier)
|
285
299
|
:param field_type: The data type of the field, only primitive types are allowed
|
@@ -296,9 +310,9 @@ def define_field(
|
|
296
310
|
:type label: str
|
297
311
|
:type business_key: bool
|
298
312
|
:type categorical: bool
|
299
|
-
:type not_null:
|
300
|
-
:type format_code:
|
301
|
-
:type field_order:
|
313
|
+
:type not_null: bool | None
|
314
|
+
:type format_code: str | None
|
315
|
+
:type field_order: int | None
|
302
316
|
:rtype: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`
|
303
317
|
"""
|
304
318
|
|
@@ -333,10 +347,12 @@ def declare_field(
|
|
333
347
|
:type label: str
|
334
348
|
:type business_key: bool
|
335
349
|
:type categorical: bool
|
336
|
-
:type not_null:
|
337
|
-
:type format_code:
|
338
|
-
:type field_order:
|
350
|
+
:type not_null: bool | None
|
351
|
+
:type format_code: str | None
|
352
|
+
:type field_order: int | None
|
339
353
|
:rtype: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`
|
354
|
+
|
355
|
+
:display: False
|
340
356
|
"""
|
341
357
|
|
342
358
|
print("TRAC Warning: declare_field() is deprecated, please use define_field()", file=sys.stderr)
|
@@ -366,9 +382,9 @@ def F( # noqa
|
|
366
382
|
:type label: str
|
367
383
|
:type business_key: bool
|
368
384
|
:type categorical: bool
|
369
|
-
:type not_null:
|
370
|
-
:type format_code:
|
371
|
-
:type field_order:
|
385
|
+
:type not_null: bool | None
|
386
|
+
:type format_code: str | None
|
387
|
+
:type field_order: int | None
|
372
388
|
:rtype: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`
|
373
389
|
"""
|
374
390
|
|
@@ -384,21 +400,23 @@ def define_schema(
|
|
384
400
|
-> SchemaDefinition:
|
385
401
|
|
386
402
|
"""
|
387
|
-
Create a :py:class:`SchemaDefinition <tracdap.rt.metadata.SchemaDefinition>` from a list of fields
|
403
|
+
Create a :py:class:`SchemaDefinition <tracdap.rt.metadata.SchemaDefinition>` from a list of fields
|
388
404
|
|
389
|
-
|
390
|
-
|
391
|
-
|
405
|
+
Individual fields can be defined using :py:func:`define_field` or the shorthand alias :py:func:`F`.
|
406
|
+
This function takes a number of fields, either as individual arguments or as a list, and arranges
|
407
|
+
them into a :py:class:`SchemaDefinition <tracdap.rt.metadata.SchemaDefinition>`.
|
392
408
|
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
:py:func:`define_input_table` or :py:func:`define_output_table` to create the input/output schema classes directly.
|
409
|
+
A schema type can be specified explicitly using the schema_type parameter, currently only
|
410
|
+
:py:attr:`TABLE <tracdap.rt.metadata.SchemaType.TABLE>` is supported and this
|
411
|
+
is also the default.
|
397
412
|
|
413
|
+
.. note::
|
414
|
+
To define the inputs or outputs of a :py:class:`TracModel <tracdap.rt.api.TracModel>`,
|
415
|
+
use :py:func:`define_input_table` or :py:func:`define_output_table` instead.
|
398
416
|
|
399
417
|
:param fields: The list of fields to include in the schema
|
400
418
|
:param schema_type: The type of schema to create (currently only TABLE schemas are supported)
|
401
|
-
:return: A schema definition built from the supplied fields
|
419
|
+
:return: A schema definition built from the supplied fields
|
402
420
|
|
403
421
|
:type fields: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>` |
|
404
422
|
List[:py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`]
|
@@ -416,7 +434,7 @@ def load_schema(
|
|
416
434
|
-> SchemaDefinition:
|
417
435
|
|
418
436
|
"""
|
419
|
-
|
437
|
+
Load a :py:class:`SchemaDefinition <tracdap.rt.metadata.SchemaDefinition>` from a CSV file in the model package
|
420
438
|
|
421
439
|
The schema CSV file must contain the following columns:
|
422
440
|
|
@@ -427,12 +445,16 @@ def load_schema(
|
|
427
445
|
* categorical (boolean, optional)
|
428
446
|
* format_code (string, optional)
|
429
447
|
|
430
|
-
Field
|
431
|
-
|
448
|
+
Field ordering is assigned by the order the fields are listed in the CSV file.
|
449
|
+
A schema type can be specified explicitly using the schema_type parameter, currently only
|
450
|
+
:py:attr:`TABLE <tracdap.rt.metadata.SchemaType.TABLE>` is supported and this
|
451
|
+
is also the default.
|
432
452
|
|
433
|
-
|
434
|
-
|
435
|
-
|
453
|
+
.. note::
|
454
|
+
To define the inputs or outputs of a :py:class:`TracModel <tracdap.rt.api.TracModel>`,
|
455
|
+
a schema can be loaded with this function and used to construct a
|
456
|
+
:py:class:`ModelInputSchema <tracdap.rt.metadata.ModelInputSchema>` or
|
457
|
+
:py:class:`ModelOutputSchema <tracdap.rt.metadata.ModelOutputSchema>`.
|
436
458
|
|
437
459
|
:param package: Package (or package name) in the model repository that contains the schema file
|
438
460
|
:param schema_file: Name of the schema file to load, which must be in the specified package
|
@@ -456,10 +478,19 @@ def define_input_table(
|
|
456
478
|
-> ModelInputSchema:
|
457
479
|
|
458
480
|
"""
|
459
|
-
Define a model input with a table schema
|
481
|
+
Define a model input with a table schema
|
482
|
+
|
483
|
+
Individual fields can be defined using :py:func:`define_field` or the shorthand alias :py:func:`F`.
|
484
|
+
This function takes a number of fields, either as individual arguments or as a list, and uses them
|
485
|
+
to create a :py:class:`ModelInputSchema <tracdap.rt.metadata.ModelInputSchema>`.
|
460
486
|
|
461
|
-
|
462
|
-
|
487
|
+
Use the label property to add a descriptive label to a model input. Inputs can be marked as
|
488
|
+
optional in which case they are not required when running a job, use
|
489
|
+
:py:meth:`TracContext.has_dataset() <tracdap.rt.api.TracContext.has_dataset>` to determine
|
490
|
+
whether an optional input has been provided. Inputs can be marked as dynamic in which
|
491
|
+
case the schema is not defined until the model runs, use
|
492
|
+
:py:meth:`TracContext.get_schema() <tracdap.rt.api.TracContext.get_schema>` to get the schema
|
493
|
+
of a dynamic input.
|
463
494
|
|
464
495
|
You can use input_props to associate arbitrary key-value properties with this model input.
|
465
496
|
These properties are not used by the TRAC engine, but are stored in the model metadata for
|
@@ -474,10 +505,10 @@ def define_input_table(
|
|
474
505
|
|
475
506
|
:type fields: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>` |
|
476
507
|
List[:py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`]
|
477
|
-
:type label:
|
508
|
+
:type label: str | None
|
478
509
|
:type optional: bool
|
479
510
|
:type dynamic: bool
|
480
|
-
:type input_props:
|
511
|
+
:type input_props: Dict[str, Any] | None
|
481
512
|
:rtype: :py:class:`ModelInputSchema <tracdap.rt.metadata.ModelInputSchema>`
|
482
513
|
"""
|
483
514
|
|
@@ -502,6 +533,8 @@ def declare_input_table(
|
|
502
533
|
:type fields: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>` |
|
503
534
|
List[:py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`]
|
504
535
|
:rtype: :py:class:`ModelInputSchema <tracdap.rt.metadata.ModelInputSchema>`
|
536
|
+
|
537
|
+
:display: False
|
505
538
|
"""
|
506
539
|
|
507
540
|
print("TRAC Warning: declare_input_table() is deprecated, please use define_input_table()", file=sys.stderr)
|
@@ -516,10 +549,17 @@ def define_output_table(
|
|
516
549
|
-> ModelOutputSchema:
|
517
550
|
|
518
551
|
"""
|
519
|
-
Define a model output with a table schema
|
552
|
+
Define a model output with a table schema
|
553
|
+
|
554
|
+
Individual fields can be defined using :py:func:`define_field` or the shorthand alias :py:func:`F`.
|
555
|
+
This function takes a number of fields, either as individual arguments or as a list, and uses them
|
556
|
+
to create a :py:class:`ModelOutputSchema <tracdap.rt.metadata.ModelOutputSchema>`.
|
520
557
|
|
521
|
-
|
522
|
-
|
558
|
+
Use the label property to add a descriptive label to a model output. Outputs can be marked as
|
559
|
+
optional, a model can decide not to provide an optional output without causing an error.
|
560
|
+
Outputs can be marked as dynamic in which case the schema is not defined until the model runs, use
|
561
|
+
:py:meth:`TracContext.put_schema() <tracdap.rt.api.TracContext.put_schema>` to set the schema
|
562
|
+
of a dynamic output before saving it.
|
523
563
|
|
524
564
|
You can use output_props to associate arbitrary key-value properties with this model output.
|
525
565
|
These properties are not used by the TRAC engine, but are stored in the model metadata for
|
@@ -534,10 +574,10 @@ def define_output_table(
|
|
534
574
|
|
535
575
|
:type fields: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>` |
|
536
576
|
List[:py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`]
|
537
|
-
:type label:
|
577
|
+
:type label: str | None
|
538
578
|
:type optional: bool
|
539
579
|
:type dynamic: bool
|
540
|
-
:type output_props:
|
580
|
+
:type output_props: Dict[str, Any] | None
|
541
581
|
:rtype: :py:class:`ModelOutputSchema <tracdap.rt.metadata.ModelOutputSchema>`
|
542
582
|
"""
|
543
583
|
|
@@ -565,6 +605,8 @@ def declare_output_table(
|
|
565
605
|
:type fields: :py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>` |
|
566
606
|
List[:py:class:`FieldSchema <tracdap.rt.metadata.FieldSchema>`]
|
567
607
|
:rtype: :py:class:`ModelOutputSchema <tracdap.rt.metadata.ModelOutputSchema>`
|
608
|
+
|
609
|
+
:display: False
|
568
610
|
"""
|
569
611
|
|
570
612
|
print("TRAC Warning: declare_output_table() is deprecated, please use define_output_table()", file==sys.stderr)
|
tracdap/rt/config/common.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Code generated by TRAC
|
2
2
|
|
3
|
-
from __future__ import annotations
|
4
3
|
import typing as _tp # noqa
|
5
4
|
import dataclasses as _dc # noqa
|
6
5
|
import enum as _enum # noqa
|
@@ -9,76 +8,76 @@ import enum as _enum # noqa
|
|
9
8
|
@_dc.dataclass
|
10
9
|
class _ConfigFile:
|
11
10
|
|
12
|
-
config: _tp.Dict[str, str] = _dc.field(default_factory=dict)
|
11
|
+
config: "_tp.Dict[str, str]" = _dc.field(default_factory=dict)
|
13
12
|
|
14
13
|
|
15
14
|
@_dc.dataclass
|
16
15
|
class PluginConfig:
|
17
16
|
|
18
|
-
protocol: str = ""
|
17
|
+
protocol: "str" = ""
|
19
18
|
|
20
|
-
publicProperties: _tp.Dict[str, str] = _dc.field(default_factory=dict)
|
19
|
+
publicProperties: "_tp.Dict[str, str]" = _dc.field(default_factory=dict)
|
21
20
|
|
22
|
-
properties: _tp.Dict[str, str] = _dc.field(default_factory=dict)
|
21
|
+
properties: "_tp.Dict[str, str]" = _dc.field(default_factory=dict)
|
23
22
|
|
24
|
-
secrets: _tp.Dict[str, str] = _dc.field(default_factory=dict)
|
23
|
+
secrets: "_tp.Dict[str, str]" = _dc.field(default_factory=dict)
|
25
24
|
|
26
25
|
|
27
26
|
@_dc.dataclass
|
28
27
|
class PlatformInfo:
|
29
28
|
|
30
|
-
environment: str = ""
|
29
|
+
environment: "str" = ""
|
31
30
|
|
32
|
-
production: bool = False
|
31
|
+
production: "bool" = False
|
33
32
|
|
34
|
-
deploymentInfo: _tp.Dict[str, str] = _dc.field(default_factory=dict)
|
33
|
+
deploymentInfo: "_tp.Dict[str, str]" = _dc.field(default_factory=dict)
|
35
34
|
|
36
35
|
|
37
36
|
@_dc.dataclass
|
38
37
|
class AuthenticationConfig:
|
39
38
|
|
40
|
-
jwtIssuer: str = ""
|
39
|
+
jwtIssuer: "str" = ""
|
41
40
|
|
42
|
-
jwtExpiry: int = 0
|
41
|
+
jwtExpiry: "int" = 0
|
43
42
|
|
44
|
-
jwtLimit: int = 0
|
43
|
+
jwtLimit: "int" = 0
|
45
44
|
|
46
|
-
jwtRefresh: int = 0
|
45
|
+
jwtRefresh: "int" = 0
|
47
46
|
|
48
|
-
provider: _tp.Optional[PluginConfig] = None
|
47
|
+
provider: "_tp.Optional[PluginConfig]" = None
|
49
48
|
|
50
|
-
disableAuth: bool = False
|
49
|
+
disableAuth: "bool" = False
|
51
50
|
|
52
|
-
disableSigning: bool = False
|
51
|
+
disableSigning: "bool" = False
|
53
52
|
|
54
|
-
systemUserId: str = ""
|
53
|
+
systemUserId: "str" = ""
|
55
54
|
|
56
|
-
systemUserName: str = ""
|
55
|
+
systemUserName: "str" = ""
|
57
56
|
|
58
|
-
systemTicketDuration: int = 0
|
57
|
+
systemTicketDuration: "int" = 0
|
59
58
|
|
60
|
-
systemTicketRefresh: int = 0
|
59
|
+
systemTicketRefresh: "int" = 0
|
61
60
|
|
62
61
|
|
63
62
|
@_dc.dataclass
|
64
63
|
class StorageConfig:
|
65
64
|
|
66
|
-
buckets: _tp.Dict[str, PluginConfig] = _dc.field(default_factory=dict)
|
65
|
+
buckets: "_tp.Dict[str, PluginConfig]" = _dc.field(default_factory=dict)
|
67
66
|
|
68
67
|
"""TODO: Rename "buckets" as "internal" for 0.7"""
|
69
68
|
|
70
|
-
external: _tp.Dict[str, PluginConfig] = _dc.field(default_factory=dict)
|
69
|
+
external: "_tp.Dict[str, PluginConfig]" = _dc.field(default_factory=dict)
|
71
70
|
|
72
|
-
defaultBucket: str = ""
|
71
|
+
defaultBucket: "str" = ""
|
73
72
|
|
74
|
-
defaultFormat: str = ""
|
73
|
+
defaultFormat: "str" = ""
|
75
74
|
|
76
75
|
|
77
76
|
@_dc.dataclass
|
78
77
|
class ServiceConfig:
|
79
78
|
|
80
|
-
enabled: _tp.Optional[bool] = None
|
79
|
+
enabled: "_tp.Optional[bool]" = None
|
81
80
|
|
82
|
-
alias: str = ""
|
81
|
+
alias: "str" = ""
|
83
82
|
|
84
|
-
port: int = 0
|
83
|
+
port: "int" = 0
|
tracdap/rt/config/job.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Code generated by TRAC
|
2
2
|
|
3
|
-
from __future__ import annotations
|
4
3
|
import typing as _tp # noqa
|
5
4
|
import dataclasses as _dc # noqa
|
6
5
|
import enum as _enum # noqa
|
@@ -12,12 +11,12 @@ import tracdap.rt.metadata as metadata
|
|
12
11
|
@_dc.dataclass
|
13
12
|
class JobConfig:
|
14
13
|
|
15
|
-
jobId: metadata.TagHeader = _dc.field(default_factory=lambda: metadata.TagHeader())
|
14
|
+
jobId: "metadata.TagHeader" = _dc.field(default_factory=lambda: metadata.TagHeader())
|
16
15
|
|
17
|
-
job: metadata.JobDefinition = _dc.field(default_factory=lambda: metadata.JobDefinition())
|
16
|
+
job: "metadata.JobDefinition" = _dc.field(default_factory=lambda: metadata.JobDefinition())
|
18
17
|
|
19
|
-
resources: _tp.Dict[str, metadata.ObjectDefinition] = _dc.field(default_factory=dict)
|
18
|
+
resources: "_tp.Dict[str, metadata.ObjectDefinition]" = _dc.field(default_factory=dict)
|
20
19
|
|
21
|
-
resourceMapping: _tp.Dict[str, metadata.TagHeader] = _dc.field(default_factory=dict)
|
20
|
+
resourceMapping: "_tp.Dict[str, metadata.TagHeader]" = _dc.field(default_factory=dict)
|
22
21
|
|
23
|
-
resultMapping: _tp.Dict[str, metadata.TagHeader] = _dc.field(default_factory=dict)
|
22
|
+
resultMapping: "_tp.Dict[str, metadata.TagHeader]" = _dc.field(default_factory=dict)
|