digitalhub 0.9.1__py3-none-any.whl → 0.10.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of digitalhub might be problematic. Click here for more details.

Files changed (121) hide show
  1. digitalhub/__init__.py +2 -3
  2. digitalhub/client/_base/api_builder.py +1 -1
  3. digitalhub/client/_base/client.py +25 -2
  4. digitalhub/client/_base/params_builder.py +16 -0
  5. digitalhub/client/dhcore/api_builder.py +10 -4
  6. digitalhub/client/dhcore/client.py +30 -398
  7. digitalhub/client/dhcore/configurator.py +361 -0
  8. digitalhub/client/dhcore/error_parser.py +107 -0
  9. digitalhub/client/dhcore/models.py +13 -23
  10. digitalhub/client/dhcore/params_builder.py +178 -0
  11. digitalhub/client/dhcore/utils.py +4 -44
  12. digitalhub/client/local/api_builder.py +13 -18
  13. digitalhub/client/local/client.py +18 -2
  14. digitalhub/client/local/enums.py +11 -0
  15. digitalhub/client/local/params_builder.py +116 -0
  16. digitalhub/configurator/api.py +31 -0
  17. digitalhub/configurator/configurator.py +195 -0
  18. digitalhub/configurator/credentials_store.py +65 -0
  19. digitalhub/configurator/ini_module.py +74 -0
  20. digitalhub/entities/_base/_base/entity.py +2 -2
  21. digitalhub/entities/_base/context/entity.py +4 -4
  22. digitalhub/entities/_base/entity/builder.py +5 -5
  23. digitalhub/entities/_base/executable/entity.py +2 -2
  24. digitalhub/entities/_base/material/entity.py +12 -12
  25. digitalhub/entities/_base/material/status.py +1 -1
  26. digitalhub/entities/_base/material/utils.py +2 -2
  27. digitalhub/entities/_base/unversioned/entity.py +2 -2
  28. digitalhub/entities/_base/versioned/entity.py +2 -2
  29. digitalhub/entities/_commons/enums.py +2 -0
  30. digitalhub/entities/_commons/metrics.py +164 -0
  31. digitalhub/entities/_commons/types.py +5 -0
  32. digitalhub/entities/_commons/utils.py +2 -2
  33. digitalhub/entities/_processors/base.py +527 -0
  34. digitalhub/entities/{_operations/processor.py → _processors/context.py} +212 -837
  35. digitalhub/entities/_processors/utils.py +158 -0
  36. digitalhub/entities/artifact/artifact/spec.py +3 -1
  37. digitalhub/entities/artifact/crud.py +13 -12
  38. digitalhub/entities/artifact/utils.py +1 -1
  39. digitalhub/entities/builders.py +6 -18
  40. digitalhub/entities/dataitem/_base/entity.py +0 -41
  41. digitalhub/entities/dataitem/crud.py +27 -15
  42. digitalhub/entities/dataitem/table/entity.py +49 -35
  43. digitalhub/entities/dataitem/table/models.py +4 -3
  44. digitalhub/{utils/data_utils.py → entities/dataitem/table/utils.py} +46 -54
  45. digitalhub/entities/dataitem/utils.py +58 -10
  46. digitalhub/entities/function/crud.py +9 -9
  47. digitalhub/entities/model/_base/entity.py +120 -0
  48. digitalhub/entities/model/_base/spec.py +6 -17
  49. digitalhub/entities/model/_base/status.py +10 -0
  50. digitalhub/entities/model/crud.py +13 -12
  51. digitalhub/entities/model/huggingface/spec.py +9 -4
  52. digitalhub/entities/model/mlflow/models.py +2 -2
  53. digitalhub/entities/model/mlflow/spec.py +7 -7
  54. digitalhub/entities/model/mlflow/utils.py +44 -5
  55. digitalhub/entities/project/_base/entity.py +317 -9
  56. digitalhub/entities/project/_base/spec.py +8 -6
  57. digitalhub/entities/project/crud.py +12 -11
  58. digitalhub/entities/run/_base/entity.py +103 -6
  59. digitalhub/entities/run/_base/spec.py +4 -2
  60. digitalhub/entities/run/_base/status.py +12 -0
  61. digitalhub/entities/run/crud.py +8 -8
  62. digitalhub/entities/secret/_base/entity.py +3 -3
  63. digitalhub/entities/secret/_base/spec.py +4 -2
  64. digitalhub/entities/secret/crud.py +11 -9
  65. digitalhub/entities/task/_base/entity.py +4 -4
  66. digitalhub/entities/task/_base/models.py +51 -40
  67. digitalhub/entities/task/_base/spec.py +2 -0
  68. digitalhub/entities/task/_base/utils.py +2 -2
  69. digitalhub/entities/task/crud.py +12 -8
  70. digitalhub/entities/workflow/crud.py +9 -9
  71. digitalhub/factory/utils.py +9 -9
  72. digitalhub/readers/{_base → data/_base}/builder.py +1 -1
  73. digitalhub/readers/{_base → data/_base}/reader.py +16 -4
  74. digitalhub/readers/{api.py → data/api.py} +2 -2
  75. digitalhub/readers/{factory.py → data/factory.py} +3 -3
  76. digitalhub/readers/{pandas → data/pandas}/builder.py +2 -2
  77. digitalhub/readers/{pandas → data/pandas}/reader.py +110 -30
  78. digitalhub/readers/query/__init__.py +0 -0
  79. digitalhub/stores/_base/store.py +59 -69
  80. digitalhub/stores/api.py +8 -33
  81. digitalhub/stores/builder.py +44 -161
  82. digitalhub/stores/local/store.py +106 -89
  83. digitalhub/stores/remote/store.py +86 -11
  84. digitalhub/stores/s3/configurator.py +108 -0
  85. digitalhub/stores/s3/enums.py +17 -0
  86. digitalhub/stores/s3/models.py +21 -0
  87. digitalhub/stores/s3/store.py +154 -70
  88. digitalhub/{utils/s3_utils.py → stores/s3/utils.py} +7 -3
  89. digitalhub/stores/sql/configurator.py +88 -0
  90. digitalhub/stores/sql/enums.py +16 -0
  91. digitalhub/stores/sql/models.py +24 -0
  92. digitalhub/stores/sql/store.py +106 -85
  93. digitalhub/{readers/_commons → utils}/enums.py +5 -1
  94. digitalhub/utils/exceptions.py +6 -0
  95. digitalhub/utils/file_utils.py +8 -7
  96. digitalhub/utils/generic_utils.py +28 -15
  97. digitalhub/utils/git_utils.py +16 -9
  98. digitalhub/utils/types.py +5 -0
  99. digitalhub/utils/uri_utils.py +2 -2
  100. {digitalhub-0.9.1.dist-info → digitalhub-0.10.0.dist-info}/METADATA +25 -31
  101. {digitalhub-0.9.1.dist-info → digitalhub-0.10.0.dist-info}/RECORD +108 -99
  102. {digitalhub-0.9.1.dist-info → digitalhub-0.10.0.dist-info}/WHEEL +1 -2
  103. digitalhub/client/dhcore/env.py +0 -23
  104. digitalhub/entities/_base/project/entity.py +0 -341
  105. digitalhub-0.9.1.dist-info/top_level.txt +0 -2
  106. test/local/CRUD/test_artifacts.py +0 -96
  107. test/local/CRUD/test_dataitems.py +0 -96
  108. test/local/CRUD/test_models.py +0 -95
  109. test/local/imports/test_imports.py +0 -66
  110. test/local/instances/test_validate.py +0 -55
  111. test/test_crud_functions.py +0 -109
  112. test/test_crud_runs.py +0 -86
  113. test/test_crud_tasks.py +0 -81
  114. test/testkfp.py +0 -37
  115. test/testkfp_pipeline.py +0 -22
  116. /digitalhub/{entities/_base/project → configurator}/__init__.py +0 -0
  117. /digitalhub/entities/{_operations → _processors}/__init__.py +0 -0
  118. /digitalhub/readers/{_base → data}/__init__.py +0 -0
  119. /digitalhub/readers/{_commons → data/_base}/__init__.py +0 -0
  120. /digitalhub/readers/{pandas → data/pandas}/__init__.py +0 -0
  121. {digitalhub-0.9.1.dist-info → digitalhub-0.10.0.dist-info/licenses}/LICENSE.txt +0 -0
@@ -5,7 +5,8 @@ import typing
5
5
 
6
6
  from digitalhub.entities._base.unversioned.entity import UnversionedEntity
7
7
  from digitalhub.entities._commons.enums import EntityTypes, State
8
- from digitalhub.entities._operations.processor import processor
8
+ from digitalhub.entities._commons.metrics import MetricType, set_metrics, validate_metric_value
9
+ from digitalhub.entities._processors.context import context_processor
9
10
  from digitalhub.factory.api import (
10
11
  build_runtime,
11
12
  build_spec,
@@ -137,7 +138,7 @@ class Run(UnversionedEntity):
137
138
  dict
138
139
  Run logs.
139
140
  """
140
- return processor.read_run_logs(self.project, self.ENTITY_TYPE, self.id)
141
+ return context_processor.read_run_logs(self.project, self.ENTITY_TYPE, self.id)
141
142
 
142
143
  def stop(self) -> None:
143
144
  """
@@ -148,7 +149,7 @@ class Run(UnversionedEntity):
148
149
  None
149
150
  """
150
151
  if not self.spec.local_execution:
151
- return processor.stop_run(self.project, self.ENTITY_TYPE, self.id)
152
+ return context_processor.stop_run(self.project, self.ENTITY_TYPE, self.id)
152
153
 
153
154
  def resume(self) -> None:
154
155
  """
@@ -159,7 +160,55 @@ class Run(UnversionedEntity):
159
160
  None
160
161
  """
161
162
  if not self.spec.local_execution:
162
- return processor.resume_run(self.project, self.ENTITY_TYPE, self.id)
163
+ return context_processor.resume_run(self.project, self.ENTITY_TYPE, self.id)
164
+
165
+ def log_metric(
166
+ self,
167
+ key: str,
168
+ value: MetricType,
169
+ overwrite: bool = False,
170
+ single_value: bool = False,
171
+ ) -> None:
172
+ """
173
+ Log metric into entity status.
174
+ A metric is named by a key and value (single number or list of numbers).
175
+ The metric by default is put in a list or appended to an existing list.
176
+ If single_value is True, the value will be a single number.
177
+
178
+ Parameters
179
+ ----------
180
+ key : str
181
+ Key of the metric.
182
+ value : MetricType
183
+ Value of the metric.
184
+ overwrite : bool
185
+ If True, overwrite existing metric.
186
+ single_value : bool
187
+ If True, value is a single value.
188
+
189
+ Returns
190
+ -------
191
+ None
192
+
193
+ Examples
194
+ --------
195
+ Log a new value in a list
196
+ >>> entity.log_metric("loss", 0.002)
197
+
198
+ Append a new value in a list
199
+ >>> entity.log_metric("loss", 0.0019)
200
+
201
+ Log a list of values and append them to existing metric:
202
+ >>> entity.log_metric("loss", [0.0018, 0.0015])
203
+
204
+ Log a single value (not represented as list):
205
+ >>> entity.log_metric("accuracy", 0.9, single_value=True)
206
+
207
+ Log a list of values and overwrite existing metric:
208
+ >>> entity.log_metric("accuracy", [0.8, 0.9], overwrite=True)
209
+ """
210
+ self._set_metrics(key, value, overwrite, single_value)
211
+ context_processor.update_metric(self.project, self.ENTITY_TYPE, self.id, key, self.status.metrics[key])
163
212
 
164
213
  ##############################
165
214
  # Helpers
@@ -280,7 +329,7 @@ class Run(UnversionedEntity):
280
329
  exec_type = get_entity_type_from_kind(exec_kind)
281
330
  string_to_split = getattr(self.spec, exec_type)
282
331
  exec_name, exec_id = string_to_split.split("://")[-1].split("/")[-1].split(":")
283
- return processor.read_context_entity(
332
+ return context_processor.read_context_entity(
284
333
  exec_name,
285
334
  entity_type=exec_type,
286
335
  project=self.project,
@@ -298,8 +347,56 @@ class Run(UnversionedEntity):
298
347
  Task from backend.
299
348
  """
300
349
  task_id = self.spec.task.split("://")[-1].split("/")[-1]
301
- return processor.read_unversioned_entity(
350
+ return context_processor.read_unversioned_entity(
302
351
  task_id,
303
352
  entity_type=EntityTypes.TASK.value,
304
353
  project=self.project,
305
354
  ).to_dict()
355
+
356
+ def _get_metrics(self) -> None:
357
+ """
358
+ Get model metrics from backend.
359
+
360
+ Returns
361
+ -------
362
+ None
363
+ """
364
+ self.status.metrics = context_processor.read_metrics(
365
+ project=self.project,
366
+ entity_type=self.ENTITY_TYPE,
367
+ entity_id=self.id,
368
+ )
369
+
370
+ def _set_metrics(
371
+ self,
372
+ key: str,
373
+ value: MetricType,
374
+ overwrite: bool,
375
+ single_value: bool,
376
+ ) -> None:
377
+ """
378
+ Set model metrics.
379
+
380
+ Parameters
381
+ ----------
382
+ key : str
383
+ Key of the metric.
384
+ value : MetricType
385
+ Value of the metric.
386
+ overwrite : bool
387
+ If True, overwrite existing metric.
388
+ single_value : bool
389
+ If True, value is a single value.
390
+
391
+ Returns
392
+ -------
393
+ None
394
+ """
395
+ value = validate_metric_value(value)
396
+ self.status.metrics = set_metrics(
397
+ self.status.metrics,
398
+ key,
399
+ value,
400
+ overwrite,
401
+ single_value,
402
+ )
@@ -1,5 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from typing import Optional
4
+
3
5
  from digitalhub.entities._base.entity.spec import Spec, SpecValidator
4
6
  from digitalhub.entities.task._base.models import K8s
5
7
 
@@ -47,8 +49,8 @@ class RunValidator(SpecValidator, K8s):
47
49
  """
48
50
 
49
51
  # Task parameters
50
- function: str = None
51
- workflow: str = None
52
+ function: Optional[str] = None
53
+ workflow: Optional[str] = None
52
54
 
53
55
  # Run parameters
54
56
  task: str
@@ -7,3 +7,15 @@ class RunStatus(Status):
7
7
  """
8
8
  RunStatus status.
9
9
  """
10
+
11
+ def __init__(
12
+ self,
13
+ state: str,
14
+ message: str | None = None,
15
+ transitions: list[dict] | None = None,
16
+ k8s: dict | None = None,
17
+ metrics: dict | None = None,
18
+ **kwargs,
19
+ ) -> None:
20
+ super().__init__(state, message, transitions, k8s, **kwargs)
21
+ self.metrics = metrics if metrics is not None else {}
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import typing
4
4
 
5
5
  from digitalhub.entities._commons.enums import EntityTypes
6
- from digitalhub.entities._operations.processor import processor
6
+ from digitalhub.entities._processors.context import context_processor
7
7
  from digitalhub.utils.exceptions import EntityError
8
8
 
9
9
  if typing.TYPE_CHECKING:
@@ -53,7 +53,7 @@ def new_run(
53
53
  >>> kind="python+run",
54
54
  >>> task="task-string")
55
55
  """
56
- return processor.create_context_entity(
56
+ return context_processor.create_context_entity(
57
57
  project=project,
58
58
  kind=kind,
59
59
  uuid=uuid,
@@ -95,7 +95,7 @@ def get_run(
95
95
  >>> obj = get_run("my-run-id"
96
96
  >>> project="my-project")
97
97
  """
98
- return processor.read_unversioned_entity(
98
+ return context_processor.read_unversioned_entity(
99
99
  identifier,
100
100
  entity_type=ENTITY_TYPE,
101
101
  project=project,
@@ -124,7 +124,7 @@ def list_runs(project: str, **kwargs) -> list[Run]:
124
124
  >>> objs = list_runs(project="my-project")
125
125
  """
126
126
  # TODO more examples: search by function, latest for task and function
127
- return processor.list_context_entities(
127
+ return context_processor.list_context_entities(
128
128
  project=project,
129
129
  entity_type=ENTITY_TYPE,
130
130
  **kwargs,
@@ -149,7 +149,7 @@ def import_run(file: str) -> Run:
149
149
  -------
150
150
  >>> obj = import_run("my-run.yaml")
151
151
  """
152
- return processor.import_context_entity(file)
152
+ return context_processor.import_context_entity(file)
153
153
 
154
154
 
155
155
  def load_run(file: str) -> Run:
@@ -170,7 +170,7 @@ def load_run(file: str) -> Run:
170
170
  --------
171
171
  >>> obj = load_run("my-run.yaml")
172
172
  """
173
- return processor.load_context_entity(file)
173
+ return context_processor.load_context_entity(file)
174
174
 
175
175
 
176
176
  def update_run(entity: Run) -> Run:
@@ -191,7 +191,7 @@ def update_run(entity: Run) -> Run:
191
191
  --------
192
192
  >>> obj = update_run(obj)
193
193
  """
194
- return processor.update_context_entity(
194
+ return context_processor.update_context_entity(
195
195
  project=entity.project,
196
196
  entity_type=entity.ENTITY_TYPE,
197
197
  entity_id=entity.id,
@@ -228,7 +228,7 @@ def delete_run(
228
228
  """
229
229
  if not identifier.startswith("store://") and project is None:
230
230
  raise EntityError("Specify entity key or entity ID combined with project")
231
- return processor.delete_context_entity(
231
+ return context_processor.delete_context_entity(
232
232
  identifier=identifier,
233
233
  entity_type=ENTITY_TYPE,
234
234
  project=project,
@@ -4,7 +4,7 @@ import typing
4
4
 
5
5
  from digitalhub.entities._base.versioned.entity import VersionedEntity
6
6
  from digitalhub.entities._commons.enums import EntityTypes
7
- from digitalhub.entities._operations.processor import processor
7
+ from digitalhub.entities._processors.context import context_processor
8
8
 
9
9
  if typing.TYPE_CHECKING:
10
10
  from digitalhub.entities._base.entity.metadata import Metadata
@@ -52,7 +52,7 @@ class Secret(VersionedEntity):
52
52
  None
53
53
  """
54
54
  obj = {self.name: value}
55
- processor.update_secret_data(self.project, self.ENTITY_TYPE, obj)
55
+ context_processor.update_secret_data(self.project, self.ENTITY_TYPE, obj)
56
56
 
57
57
  def read_secret_value(self) -> dict:
58
58
  """
@@ -64,5 +64,5 @@ class Secret(VersionedEntity):
64
64
  Value of the secret.
65
65
  """
66
66
  params = {"keys": self.name}
67
- data = processor.read_secret_data(self.project, self.ENTITY_TYPE, params=params)
67
+ data = context_processor.read_secret_data(self.project, self.ENTITY_TYPE, params=params)
68
68
  return data[self.name]
@@ -1,5 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from typing import Optional
4
+
3
5
  from digitalhub.entities._base.entity.spec import Spec, SpecValidator
4
6
 
5
7
 
@@ -28,8 +30,8 @@ class SecretValidator(SpecValidator):
28
30
  SecretValidator validator.
29
31
  """
30
32
 
31
- path: str = None
33
+ path: Optional[str] = None
32
34
  """Path to the secret."""
33
35
 
34
- provider: str = None
36
+ provider: Optional[str] = None
35
37
  """Provider of the secret."""
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import typing
4
4
 
5
5
  from digitalhub.entities._commons.enums import EntityTypes
6
- from digitalhub.entities._operations.processor import processor
6
+ from digitalhub.entities._processors.context import context_processor
7
7
  from digitalhub.utils.exceptions import EntityNotExistsError
8
8
 
9
9
  if typing.TYPE_CHECKING:
@@ -58,7 +58,7 @@ def new_secret(
58
58
  """
59
59
  if secret_value is None:
60
60
  raise ValueError("secret_value must be provided.")
61
- obj: Secret = processor.create_context_entity(
61
+ obj: Secret = context_processor.create_context_entity(
62
62
  project=project,
63
63
  name=name,
64
64
  kind="secret",
@@ -108,13 +108,15 @@ def get_secret(
108
108
  >>> entity_id="my-secret-id")
109
109
  """
110
110
  if not identifier.startswith("store://"):
111
+ if project is None:
112
+ raise ValueError("Project must be provided.")
111
113
  secrets = list_secrets(project=project, **kwargs)
112
114
  for secret in secrets:
113
115
  if secret.name == identifier:
114
116
  return secret
115
117
  else:
116
118
  raise EntityNotExistsError(f"Secret {identifier} not found.")
117
- return processor.read_context_entity(
119
+ return context_processor.read_context_entity(
118
120
  identifier,
119
121
  entity_type=ENTITY_TYPE,
120
122
  project=project,
@@ -154,7 +156,7 @@ def get_secret_versions(
154
156
  >>> objs = get_secret_versions("my-secret-name",
155
157
  >>> project="my-project")
156
158
  """
157
- return processor.read_context_entity_versions(
159
+ return context_processor.read_context_entity_versions(
158
160
  identifier,
159
161
  entity_type=ENTITY_TYPE,
160
162
  project=project,
@@ -182,7 +184,7 @@ def list_secrets(project: str, **kwargs) -> list[Secret]:
182
184
  --------
183
185
  >>> objs = list_secrets(project="my-project")
184
186
  """
185
- return processor.list_context_entities(
187
+ return context_processor.list_context_entities(
186
188
  project=project,
187
189
  entity_type=ENTITY_TYPE,
188
190
  **kwargs,
@@ -207,7 +209,7 @@ def import_secret(file: str) -> Secret:
207
209
  --------
208
210
  >>> obj = import_secret("my-secret.yaml")
209
211
  """
210
- return processor.import_context_entity(file)
212
+ return context_processor.import_context_entity(file)
211
213
 
212
214
 
213
215
  def load_secret(file: str) -> Secret:
@@ -228,7 +230,7 @@ def load_secret(file: str) -> Secret:
228
230
  --------
229
231
  >>> obj = load_secret("my-secret.yaml")
230
232
  """
231
- return processor.load_context_entity(file)
233
+ return context_processor.load_context_entity(file)
232
234
 
233
235
 
234
236
  def update_secret(entity: Secret) -> Secret:
@@ -249,7 +251,7 @@ def update_secret(entity: Secret) -> Secret:
249
251
  --------
250
252
  >>> obj = update_secret(obj)
251
253
  """
252
- return processor.update_context_entity(
254
+ return context_processor.update_context_entity(
253
255
  project=entity.project,
254
256
  entity_type=entity.ENTITY_TYPE,
255
257
  entity_id=entity.id,
@@ -295,7 +297,7 @@ def delete_secret(
295
297
  >>> project="my-project",
296
298
  >>> delete_all_versions=True)
297
299
  """
298
- return processor.delete_context_entity(
300
+ return context_processor.delete_context_entity(
299
301
  identifier=identifier,
300
302
  entity_type=ENTITY_TYPE,
301
303
  project=project,
@@ -4,7 +4,7 @@ import typing
4
4
 
5
5
  from digitalhub.entities._base.unversioned.entity import UnversionedEntity
6
6
  from digitalhub.entities._commons.enums import EntityTypes
7
- from digitalhub.entities._operations.processor import processor
7
+ from digitalhub.entities._processors.context import context_processor
8
8
  from digitalhub.factory.api import build_entity_from_params, get_entity_type_from_kind, get_executable_kind
9
9
 
10
10
  if typing.TYPE_CHECKING:
@@ -107,7 +107,7 @@ class Task(UnversionedEntity):
107
107
  Run object.
108
108
  """
109
109
  if save:
110
- return processor.create_context_entity(**kwargs)
110
+ return context_processor.create_context_entity(**kwargs)
111
111
  return build_entity_from_params(**kwargs)
112
112
 
113
113
  def get_run(self, entity_key: str) -> Run:
@@ -124,7 +124,7 @@ class Task(UnversionedEntity):
124
124
  Run
125
125
  Run object.
126
126
  """
127
- return processor.read_context_entity(entity_key)
127
+ return context_processor.read_context_entity(entity_key)
128
128
 
129
129
  def delete_run(self, entity_key: str) -> dict:
130
130
  """
@@ -140,4 +140,4 @@ class Task(UnversionedEntity):
140
140
  dict
141
141
  Response from backend.
142
142
  """
143
- return processor.delete_context_entity(entity_key)
143
+ return context_processor.delete_context_entity(entity_key)
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from enum import Enum
4
+ from typing import Optional
4
5
 
5
6
  from pydantic import BaseModel, ConfigDict, Field
6
7
 
@@ -30,7 +31,7 @@ class Volume(BaseModel):
30
31
  mount_path: str
31
32
  """Volume mount path inside the container."""
32
33
 
33
- spec: dict[str, str] = None
34
+ spec: Optional[dict[str, str]] = None
34
35
  """Volume spec."""
35
36
 
36
37
 
@@ -63,13 +64,13 @@ class Resource(BaseModel):
63
64
  Resource model.
64
65
  """
65
66
 
66
- cpu: ResourceItem = None
67
+ cpu: Optional[ResourceItem] = None
67
68
  """CPU resource model."""
68
69
 
69
- mem: ResourceItem = None
70
+ mem: Optional[ResourceItem] = None
70
71
  """Memory resource model."""
71
72
 
72
- gpu: ResourceItem = None
73
+ gpu: Optional[ResourceItem] = None
73
74
  """GPU resource model."""
74
75
 
75
76
 
@@ -90,31 +91,31 @@ class Toleration(BaseModel):
90
91
  Toleration model.
91
92
  """
92
93
 
93
- key: str = None
94
+ key: Optional[str] = None
94
95
  """Toleration key."""
95
96
 
96
- operator: str = None
97
+ operator: Optional[str] = None
97
98
  """Toleration operator."""
98
99
 
99
- value: str = None
100
+ value: Optional[str] = None
100
101
  """Toleration value."""
101
102
 
102
- effect: str = None
103
+ effect: Optional[str] = None
103
104
  """Toleration effect."""
104
105
 
105
- toleration_seconds: int = None
106
+ toleration_seconds: Optional[int] = None
106
107
  """Toleration seconds."""
107
108
 
108
109
 
109
110
  class V1NodeSelectorRequirement(BaseModel):
110
111
  key: str
111
112
  operator: str
112
- values: list[str] = None
113
+ values: Optional[list[str]] = None
113
114
 
114
115
 
115
116
  class V1NodeSelectorTerm(BaseModel):
116
- match_expressions: list[V1NodeSelectorRequirement] = None
117
- match_fields: list[V1NodeSelectorRequirement] = None
117
+ match_expressions: Optional[list[V1NodeSelectorRequirement]] = None
118
+ match_fields: Optional[list[V1NodeSelectorRequirement]] = None
118
119
 
119
120
 
120
121
  class V1NodeSelector(BaseModel):
@@ -129,21 +130,21 @@ class V1PreferredSchedulingTerm(BaseModel):
129
130
  class V1LabelSelectorRequirement(BaseModel):
130
131
  key: str
131
132
  operator: str
132
- values: list[str] = None
133
+ values: Optional[list[str]] = None
133
134
 
134
135
 
135
136
  class V1LabelSelector(BaseModel):
136
- match_expressions: list[V1LabelSelectorRequirement] = None
137
- match_labels: dict[str, str] = None
137
+ match_expressions: Optional[list[V1LabelSelectorRequirement]] = None
138
+ match_labels: Optional[dict[str, str]] = None
138
139
 
139
140
 
140
141
  class V1PodAffinityTerm(BaseModel):
141
- label_selector: V1LabelSelector = None
142
- match_label_keys: list[str] = None
143
- mismatch_label_keys: list[str] = None
144
- namespace_selector: V1LabelSelector = None
145
- namespaces: list[str] = None
146
- topology_key: str
142
+ label_selector: Optional[V1LabelSelector] = None
143
+ match_label_keys: Optional[list[str]] = None
144
+ mismatch_label_keys: Optional[list[str]] = None
145
+ namespace_selector: Optional[V1LabelSelector] = None
146
+ namespaces: Optional[list[str]] = None
147
+ topology_key: Optional[str] = None
147
148
 
148
149
 
149
150
  class V1WeightedPodAffinityTerm(BaseModel):
@@ -152,18 +153,18 @@ class V1WeightedPodAffinityTerm(BaseModel):
152
153
 
153
154
 
154
155
  class V1NodeAffinity(BaseModel):
155
- preferred_during_scheduling_ignored_during_execution: list[V1PreferredSchedulingTerm] = None
156
- required_during_scheduling_ignored_during_execution: V1NodeSelector = None
156
+ preferred_during_scheduling_ignored_during_execution: Optional[list[V1PreferredSchedulingTerm]] = None
157
+ required_during_scheduling_ignored_during_execution: Optional[V1NodeSelector] = None
157
158
 
158
159
 
159
160
  class V1PodAffinity(BaseModel):
160
- preferred_during_scheduling_ignored_during_execution: list[V1WeightedPodAffinityTerm] = None
161
- required_during_scheduling_ignored_during_execution: list[V1PodAffinityTerm] = None
161
+ preferred_during_scheduling_ignored_during_execution: Optional[list[V1WeightedPodAffinityTerm]] = None
162
+ required_during_scheduling_ignored_during_execution: Optional[list[V1PodAffinityTerm]] = None
162
163
 
163
164
 
164
165
  class V1PodAntiAffinity(BaseModel):
165
- preferred_during_scheduling_ignored_during_execution: list[V1WeightedPodAffinityTerm] = None
166
- required_during_scheduling_ignored_during_execution: list[V1PodAffinityTerm] = None
166
+ preferred_during_scheduling_ignored_during_execution: Optional[list[V1WeightedPodAffinityTerm]] = None
167
+ required_during_scheduling_ignored_during_execution: Optional[list[V1PodAffinityTerm]] = None
167
168
 
168
169
 
169
170
  class Affinity(BaseModel):
@@ -171,13 +172,13 @@ class Affinity(BaseModel):
171
172
  Affinity model.
172
173
  """
173
174
 
174
- node_affinity: V1NodeAffinity = None
175
+ node_affinity: Optional[V1NodeAffinity] = None
175
176
  """Node affinity."""
176
177
 
177
- pod_affinity: V1PodAffinity = None
178
+ pod_affinity: Optional[V1PodAffinity] = None
178
179
  """Pod affinity."""
179
180
 
180
- pod_anti_affinity: V1PodAntiAffinity = None
181
+ pod_anti_affinity: Optional[V1PodAntiAffinity] = None
181
182
  """Pod anti affinity."""
182
183
 
183
184
 
@@ -186,34 +187,34 @@ class K8s(BaseModel):
186
187
  Kubernetes resource model.
187
188
  """
188
189
 
189
- node_selector: list[NodeSelector] = None
190
+ node_selector: Optional[list[NodeSelector]] = None
190
191
  """Node selector."""
191
192
 
192
- volumes: list[Volume] = None
193
+ volumes: Optional[list[Volume]] = None
193
194
  """List of volumes."""
194
195
 
195
- resources: Resource = None
196
+ resources: Optional[Resource] = None
196
197
  """Resources restrictions."""
197
198
 
198
- affinity: Affinity = None
199
+ affinity: Optional[Affinity] = None
199
200
  """Affinity."""
200
201
 
201
- tolerations: list[Toleration] = None
202
+ tolerations: Optional[list[Toleration]] = None
202
203
  """Tolerations."""
203
204
 
204
- envs: list[Env] = None
205
+ envs: Optional[list[Env]] = None
205
206
  """Env variables."""
206
207
 
207
- secrets: list[str] = None
208
+ secrets: Optional[list[str]] = None
208
209
  """List of secret names."""
209
210
 
210
- profile: str = None
211
+ profile: Optional[str] = None
211
212
  """Profile template."""
212
213
 
213
- runtime_class: str = None
214
+ runtime_class: Optional[str] = None
214
215
  """Runtime class name."""
215
216
 
216
- priority_class: str = None
217
+ priority_class: Optional[str] = None
217
218
  """Priority class."""
218
219
 
219
220
 
@@ -235,3 +236,13 @@ class CoreServiceType(Enum):
235
236
  CLUSTER_IP = "ClusterIP"
236
237
  NODE_PORT = "NodePort"
237
238
  LOAD_BALANCER = "LoadBalancer"
239
+
240
+
241
+ class CorePullPolicy(Enum):
242
+ """
243
+ CorePullPolicy enum.
244
+ """
245
+
246
+ ALWAYS = "Always"
247
+ IF_NOT_PRESENT = "IfNotPresent"
248
+ NEVER = "Never"
@@ -66,6 +66,8 @@ class TaskSpecWorkflow(TaskSpec):
66
66
  self.envs = envs
67
67
  self.secrets = secrets
68
68
  self.profile = profile
69
+ self.runtime_class = runtime_class
70
+ self.priority_class = priority_class
69
71
 
70
72
 
71
73
  class TaskValidator(SpecValidator):
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
 
4
- def build_task_actions(kind_action_list: list[tuple[str, str]]) -> dict[str, str]:
4
+ def build_task_actions(kind_action_list: list[tuple[str, str]]) -> list[dict[str, str]]:
5
5
  """
6
6
  Build task actions.
7
7
 
@@ -12,7 +12,7 @@ def build_task_actions(kind_action_list: list[tuple[str, str]]) -> dict[str, str
12
12
 
13
13
  Returns
14
14
  -------
15
- dict[str, str]
15
+ list[dict[str, str]]
16
16
  Returns the task actions.
17
17
  """
18
18
  return [{"kind": kind, "action": action} for (kind, action) in kind_action_list]