digitalhub 0.13.0b3__py3-none-any.whl → 0.14.9__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.
- digitalhub/__init__.py +3 -8
- digitalhub/context/api.py +43 -6
- digitalhub/context/builder.py +1 -5
- digitalhub/context/context.py +28 -13
- digitalhub/entities/_base/_base/entity.py +0 -15
- digitalhub/entities/_base/context/entity.py +1 -4
- digitalhub/entities/_base/entity/builder.py +5 -5
- digitalhub/entities/_base/entity/entity.py +0 -8
- digitalhub/entities/_base/executable/entity.py +195 -87
- digitalhub/entities/_base/material/entity.py +11 -23
- digitalhub/entities/_base/material/utils.py +28 -4
- digitalhub/entities/_base/runtime_entity/builder.py +53 -18
- digitalhub/entities/_base/unversioned/entity.py +1 -1
- digitalhub/entities/_base/versioned/entity.py +1 -1
- digitalhub/entities/_commons/enums.py +1 -31
- digitalhub/entities/_commons/metrics.py +64 -30
- digitalhub/entities/_commons/utils.py +119 -30
- digitalhub/entities/_constructors/_resources.py +151 -0
- digitalhub/entities/{_base/entity/_constructors → _constructors}/name.py +18 -0
- digitalhub/entities/_processors/base/crud.py +381 -0
- digitalhub/entities/_processors/base/import_export.py +118 -0
- digitalhub/entities/_processors/base/processor.py +299 -0
- digitalhub/entities/_processors/base/special_ops.py +104 -0
- digitalhub/entities/_processors/context/crud.py +652 -0
- digitalhub/entities/_processors/context/import_export.py +242 -0
- digitalhub/entities/_processors/context/material.py +123 -0
- digitalhub/entities/_processors/context/processor.py +400 -0
- digitalhub/entities/_processors/context/special_ops.py +476 -0
- digitalhub/entities/_processors/processors.py +12 -0
- digitalhub/entities/_processors/utils.py +38 -102
- digitalhub/entities/artifact/crud.py +58 -22
- digitalhub/entities/artifact/utils.py +28 -13
- digitalhub/entities/builders.py +2 -0
- digitalhub/entities/dataitem/crud.py +63 -20
- digitalhub/entities/dataitem/table/entity.py +27 -22
- digitalhub/entities/dataitem/utils.py +82 -32
- digitalhub/entities/function/_base/entity.py +3 -6
- digitalhub/entities/function/crud.py +55 -24
- digitalhub/entities/model/_base/entity.py +62 -20
- digitalhub/entities/model/crud.py +59 -23
- digitalhub/entities/model/mlflow/utils.py +29 -20
- digitalhub/entities/model/utils.py +28 -13
- digitalhub/entities/project/_base/builder.py +0 -6
- digitalhub/entities/project/_base/entity.py +337 -164
- digitalhub/entities/project/_base/spec.py +4 -4
- digitalhub/entities/project/crud.py +28 -71
- digitalhub/entities/project/utils.py +7 -3
- digitalhub/entities/run/_base/builder.py +0 -4
- digitalhub/entities/run/_base/entity.py +70 -63
- digitalhub/entities/run/crud.py +79 -26
- digitalhub/entities/secret/_base/entity.py +1 -5
- digitalhub/entities/secret/crud.py +31 -28
- digitalhub/entities/task/_base/builder.py +0 -4
- digitalhub/entities/task/_base/entity.py +5 -5
- digitalhub/entities/task/_base/models.py +13 -16
- digitalhub/entities/task/crud.py +61 -29
- digitalhub/entities/trigger/_base/entity.py +1 -5
- digitalhub/entities/trigger/crud.py +89 -30
- digitalhub/entities/workflow/_base/entity.py +3 -8
- digitalhub/entities/workflow/crud.py +55 -24
- digitalhub/factory/entity.py +283 -0
- digitalhub/factory/enums.py +18 -0
- digitalhub/factory/registry.py +197 -0
- digitalhub/factory/runtime.py +44 -0
- digitalhub/factory/utils.py +3 -54
- digitalhub/runtimes/_base.py +2 -2
- digitalhub/stores/client/{dhcore/api_builder.py → api_builder.py} +3 -3
- digitalhub/stores/client/builder.py +19 -31
- digitalhub/stores/client/client.py +322 -0
- digitalhub/stores/client/configurator.py +408 -0
- digitalhub/stores/client/enums.py +50 -0
- digitalhub/stores/client/{dhcore/error_parser.py → error_parser.py} +0 -4
- digitalhub/stores/client/header_manager.py +61 -0
- digitalhub/stores/client/http_handler.py +152 -0
- digitalhub/stores/client/{_base/key_builder.py → key_builder.py} +14 -14
- digitalhub/stores/client/params_builder.py +330 -0
- digitalhub/stores/client/response_processor.py +102 -0
- digitalhub/stores/client/utils.py +35 -0
- digitalhub/stores/{credentials → configurator}/api.py +5 -9
- digitalhub/stores/configurator/configurator.py +123 -0
- digitalhub/stores/{credentials → configurator}/enums.py +27 -10
- digitalhub/stores/configurator/handler.py +213 -0
- digitalhub/stores/{credentials → configurator}/ini_module.py +31 -22
- digitalhub/stores/data/_base/store.py +0 -20
- digitalhub/stores/data/api.py +5 -7
- digitalhub/stores/data/builder.py +53 -27
- digitalhub/stores/data/local/store.py +0 -103
- digitalhub/stores/data/remote/store.py +0 -4
- digitalhub/stores/data/s3/configurator.py +39 -77
- digitalhub/stores/data/s3/store.py +57 -37
- digitalhub/stores/data/sql/configurator.py +66 -46
- digitalhub/stores/data/sql/store.py +171 -104
- digitalhub/stores/readers/data/factory.py +0 -8
- digitalhub/stores/readers/data/pandas/reader.py +9 -19
- digitalhub/utils/file_utils.py +0 -17
- digitalhub/utils/generic_utils.py +1 -14
- digitalhub/utils/git_utils.py +0 -8
- digitalhub/utils/io_utils.py +0 -12
- digitalhub/utils/store_utils.py +44 -0
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/METADATA +5 -4
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/RECORD +112 -113
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/WHEEL +1 -1
- digitalhub/entities/_commons/types.py +0 -9
- digitalhub/entities/_processors/base.py +0 -531
- digitalhub/entities/_processors/context.py +0 -1299
- digitalhub/entities/task/_base/utils.py +0 -22
- digitalhub/factory/factory.py +0 -381
- digitalhub/stores/client/_base/api_builder.py +0 -34
- digitalhub/stores/client/_base/client.py +0 -243
- digitalhub/stores/client/_base/params_builder.py +0 -34
- digitalhub/stores/client/api.py +0 -36
- digitalhub/stores/client/dhcore/client.py +0 -613
- digitalhub/stores/client/dhcore/configurator.py +0 -675
- digitalhub/stores/client/dhcore/enums.py +0 -34
- digitalhub/stores/client/dhcore/key_builder.py +0 -62
- digitalhub/stores/client/dhcore/models.py +0 -40
- digitalhub/stores/client/dhcore/params_builder.py +0 -278
- digitalhub/stores/client/dhcore/utils.py +0 -94
- digitalhub/stores/client/local/api_builder.py +0 -116
- digitalhub/stores/client/local/client.py +0 -573
- digitalhub/stores/client/local/enums.py +0 -15
- digitalhub/stores/client/local/key_builder.py +0 -62
- digitalhub/stores/client/local/params_builder.py +0 -120
- digitalhub/stores/credentials/__init__.py +0 -3
- digitalhub/stores/credentials/configurator.py +0 -210
- digitalhub/stores/credentials/handler.py +0 -176
- digitalhub/stores/credentials/store.py +0 -81
- digitalhub/stores/data/enums.py +0 -15
- digitalhub/stores/data/s3/utils.py +0 -78
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/__init__.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/metadata.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/spec.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/status.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/uuid.py +0 -0
- /digitalhub/{stores/client/_base → entities/_processors/base}/__init__.py +0 -0
- /digitalhub/{stores/client/dhcore → entities/_processors/context}/__init__.py +0 -0
- /digitalhub/stores/{client/local → configurator}/__init__.py +0 -0
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.9.dist-info}/licenses/LICENSE +0 -0
digitalhub/entities/run/crud.py
CHANGED
|
@@ -7,8 +7,7 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
10
|
-
from digitalhub.entities._processors.
|
|
11
|
-
from digitalhub.utils.exceptions import EntityError
|
|
10
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
12
11
|
|
|
13
12
|
if typing.TYPE_CHECKING:
|
|
14
13
|
from digitalhub.entities.run._base.entity import Run
|
|
@@ -71,7 +70,6 @@ def new_run(
|
|
|
71
70
|
def get_run(
|
|
72
71
|
identifier: str,
|
|
73
72
|
project: str | None = None,
|
|
74
|
-
**kwargs,
|
|
75
73
|
) -> Run:
|
|
76
74
|
"""
|
|
77
75
|
Get object from backend.
|
|
@@ -82,8 +80,6 @@ def get_run(
|
|
|
82
80
|
Entity key (store://...) or entity ID.
|
|
83
81
|
project : str
|
|
84
82
|
Project name.
|
|
85
|
-
**kwargs : dict
|
|
86
|
-
Parameters to pass to the API call.
|
|
87
83
|
|
|
88
84
|
Returns
|
|
89
85
|
-------
|
|
@@ -100,14 +96,26 @@ def get_run(
|
|
|
100
96
|
>>> project="my-project")
|
|
101
97
|
"""
|
|
102
98
|
return context_processor.read_unversioned_entity(
|
|
103
|
-
identifier,
|
|
99
|
+
identifier=identifier,
|
|
104
100
|
entity_type=ENTITY_TYPE,
|
|
105
101
|
project=project,
|
|
106
|
-
**kwargs,
|
|
107
102
|
)
|
|
108
103
|
|
|
109
104
|
|
|
110
|
-
def list_runs(
|
|
105
|
+
def list_runs(
|
|
106
|
+
project: str,
|
|
107
|
+
q: str | None = None,
|
|
108
|
+
name: str | None = None,
|
|
109
|
+
kind: str | None = None,
|
|
110
|
+
user: str | None = None,
|
|
111
|
+
state: str | None = None,
|
|
112
|
+
created: str | None = None,
|
|
113
|
+
updated: str | None = None,
|
|
114
|
+
function: str | None = None,
|
|
115
|
+
workflow: str | None = None,
|
|
116
|
+
task: str | None = None,
|
|
117
|
+
action: str | None = None,
|
|
118
|
+
) -> list[Run]:
|
|
111
119
|
"""
|
|
112
120
|
List all latest version objects from backend.
|
|
113
121
|
|
|
@@ -115,34 +123,74 @@ def list_runs(project: str, **kwargs) -> list[Run]:
|
|
|
115
123
|
----------
|
|
116
124
|
project : str
|
|
117
125
|
Project name.
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
q : str
|
|
127
|
+
Query string to filter objects.
|
|
128
|
+
name : str
|
|
129
|
+
Object name.
|
|
130
|
+
kind : str
|
|
131
|
+
Kind of the object.
|
|
132
|
+
user : str
|
|
133
|
+
User that created the object.
|
|
134
|
+
state : str
|
|
135
|
+
Object state.
|
|
136
|
+
created : str
|
|
137
|
+
Creation date filter.
|
|
138
|
+
updated : str
|
|
139
|
+
Update date filter.
|
|
140
|
+
function : str
|
|
141
|
+
Function key filter.
|
|
142
|
+
workflow : str
|
|
143
|
+
Workflow key filter.
|
|
144
|
+
task : str
|
|
145
|
+
Task string filter.
|
|
146
|
+
action : str
|
|
147
|
+
Action name filter.
|
|
120
148
|
|
|
121
149
|
Returns
|
|
122
150
|
-------
|
|
123
|
-
list[
|
|
151
|
+
list[Model]
|
|
124
152
|
List of object instances.
|
|
125
153
|
|
|
126
154
|
Examples
|
|
127
155
|
--------
|
|
128
156
|
>>> objs = list_runs(project="my-project")
|
|
129
157
|
"""
|
|
130
|
-
# TODO more examples: search by function, latest for task and function
|
|
131
158
|
return context_processor.list_context_entities(
|
|
132
159
|
project=project,
|
|
133
160
|
entity_type=ENTITY_TYPE,
|
|
134
|
-
|
|
161
|
+
q=q,
|
|
162
|
+
name=name,
|
|
163
|
+
kind=kind,
|
|
164
|
+
user=user,
|
|
165
|
+
state=state,
|
|
166
|
+
created=created,
|
|
167
|
+
updated=updated,
|
|
168
|
+
function=function,
|
|
169
|
+
workflow=workflow,
|
|
170
|
+
task=task,
|
|
171
|
+
action=action,
|
|
135
172
|
)
|
|
136
173
|
|
|
137
174
|
|
|
138
|
-
def import_run(
|
|
175
|
+
def import_run(
|
|
176
|
+
file: str | None = None,
|
|
177
|
+
key: str | None = None,
|
|
178
|
+
reset_id: bool = False,
|
|
179
|
+
context: str | None = None,
|
|
180
|
+
) -> Run:
|
|
139
181
|
"""
|
|
140
|
-
Import object from a YAML file
|
|
182
|
+
Import an object from a YAML file or from a storage key.
|
|
141
183
|
|
|
142
184
|
Parameters
|
|
143
185
|
----------
|
|
144
186
|
file : str
|
|
145
|
-
Path to YAML file.
|
|
187
|
+
Path to the YAML file.
|
|
188
|
+
key : str
|
|
189
|
+
Entity key (store://...).
|
|
190
|
+
reset_id : bool
|
|
191
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
192
|
+
context : str
|
|
193
|
+
Project name to use for context resolution.
|
|
146
194
|
|
|
147
195
|
Returns
|
|
148
196
|
-------
|
|
@@ -153,7 +201,12 @@ def import_run(file: str) -> Run:
|
|
|
153
201
|
-------
|
|
154
202
|
>>> obj = import_run("my-run.yaml")
|
|
155
203
|
"""
|
|
156
|
-
return context_processor.import_context_entity(
|
|
204
|
+
return context_processor.import_context_entity(
|
|
205
|
+
file,
|
|
206
|
+
key,
|
|
207
|
+
reset_id,
|
|
208
|
+
context,
|
|
209
|
+
)
|
|
157
210
|
|
|
158
211
|
|
|
159
212
|
def load_run(file: str) -> Run:
|
|
@@ -206,7 +259,7 @@ def update_run(entity: Run) -> Run:
|
|
|
206
259
|
def delete_run(
|
|
207
260
|
identifier: str,
|
|
208
261
|
project: str | None = None,
|
|
209
|
-
|
|
262
|
+
entity_id: str | None = None,
|
|
210
263
|
) -> dict:
|
|
211
264
|
"""
|
|
212
265
|
Delete object from backend.
|
|
@@ -214,11 +267,11 @@ def delete_run(
|
|
|
214
267
|
Parameters
|
|
215
268
|
----------
|
|
216
269
|
identifier : str
|
|
217
|
-
Entity key (store://...) or entity
|
|
270
|
+
Entity key (store://...) or entity name.
|
|
218
271
|
project : str
|
|
219
272
|
Project name.
|
|
220
|
-
|
|
221
|
-
|
|
273
|
+
entity_id : str
|
|
274
|
+
Entity ID.
|
|
222
275
|
|
|
223
276
|
Returns
|
|
224
277
|
-------
|
|
@@ -228,14 +281,14 @@ def delete_run(
|
|
|
228
281
|
Examples
|
|
229
282
|
--------
|
|
230
283
|
>>> obj = delete_run("store://my-run-key")
|
|
231
|
-
>>> obj = delete_run(
|
|
284
|
+
>>> obj = delete_run(
|
|
285
|
+
... "my-run-id",
|
|
286
|
+
... project="my-project",
|
|
287
|
+
... )
|
|
232
288
|
"""
|
|
233
|
-
if not identifier.startswith("store://") and project is None:
|
|
234
|
-
raise EntityError("Specify entity key or entity ID combined with project")
|
|
235
289
|
return context_processor.delete_context_entity(
|
|
236
290
|
identifier=identifier,
|
|
237
291
|
entity_type=ENTITY_TYPE,
|
|
238
292
|
project=project,
|
|
239
|
-
entity_id=
|
|
240
|
-
**kwargs,
|
|
293
|
+
entity_id=entity_id,
|
|
241
294
|
)
|
|
@@ -8,7 +8,7 @@ import typing
|
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._base.versioned.entity import VersionedEntity
|
|
10
10
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
11
|
-
from digitalhub.entities._processors.
|
|
11
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
12
12
|
|
|
13
13
|
if typing.TYPE_CHECKING:
|
|
14
14
|
from digitalhub.entities._base.entity.metadata import Metadata
|
|
@@ -50,10 +50,6 @@ class Secret(VersionedEntity):
|
|
|
50
50
|
----------
|
|
51
51
|
value : str
|
|
52
52
|
Value of the secret.
|
|
53
|
-
|
|
54
|
-
Returns
|
|
55
|
-
-------
|
|
56
|
-
None
|
|
57
53
|
"""
|
|
58
54
|
obj = {self.name: value}
|
|
59
55
|
context_processor.update_secret_data(self.project, self.ENTITY_TYPE, obj)
|
|
@@ -6,8 +6,9 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
|
-
from digitalhub.entities._commons.enums import EntityTypes
|
|
10
|
-
from digitalhub.entities.
|
|
9
|
+
from digitalhub.entities._commons.enums import EntityKinds, EntityTypes
|
|
10
|
+
from digitalhub.entities._commons.utils import is_valid_key
|
|
11
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
11
12
|
from digitalhub.utils.exceptions import EntityNotExistsError
|
|
12
13
|
|
|
13
14
|
if typing.TYPE_CHECKING:
|
|
@@ -65,7 +66,7 @@ def new_secret(
|
|
|
65
66
|
obj: Secret = context_processor.create_context_entity(
|
|
66
67
|
project=project,
|
|
67
68
|
name=name,
|
|
68
|
-
kind=
|
|
69
|
+
kind=EntityKinds.SECRET_SECRET.value,
|
|
69
70
|
uuid=uuid,
|
|
70
71
|
description=description,
|
|
71
72
|
labels=labels,
|
|
@@ -80,7 +81,6 @@ def get_secret(
|
|
|
80
81
|
identifier: str,
|
|
81
82
|
project: str | None = None,
|
|
82
83
|
entity_id: str | None = None,
|
|
83
|
-
**kwargs,
|
|
84
84
|
) -> Secret:
|
|
85
85
|
"""
|
|
86
86
|
Get object from backend.
|
|
@@ -93,8 +93,6 @@ def get_secret(
|
|
|
93
93
|
Project name.
|
|
94
94
|
entity_id : str
|
|
95
95
|
Entity ID.
|
|
96
|
-
**kwargs : dict
|
|
97
|
-
Parameters to pass to the API call.
|
|
98
96
|
|
|
99
97
|
Returns
|
|
100
98
|
-------
|
|
@@ -111,28 +109,26 @@ def get_secret(
|
|
|
111
109
|
>>> project="my-project",
|
|
112
110
|
>>> entity_id="my-secret-id")
|
|
113
111
|
"""
|
|
114
|
-
if not identifier
|
|
112
|
+
if not is_valid_key(identifier):
|
|
115
113
|
if project is None:
|
|
116
114
|
raise ValueError("Project must be provided.")
|
|
117
|
-
secrets = list_secrets(project=project
|
|
115
|
+
secrets = list_secrets(project=project)
|
|
118
116
|
for secret in secrets:
|
|
119
117
|
if secret.name == identifier:
|
|
120
118
|
return secret
|
|
121
119
|
else:
|
|
122
120
|
raise EntityNotExistsError(f"Secret {identifier} not found.")
|
|
123
121
|
return context_processor.read_context_entity(
|
|
124
|
-
identifier,
|
|
122
|
+
identifier=identifier,
|
|
125
123
|
entity_type=ENTITY_TYPE,
|
|
126
124
|
project=project,
|
|
127
125
|
entity_id=entity_id,
|
|
128
|
-
**kwargs,
|
|
129
126
|
)
|
|
130
127
|
|
|
131
128
|
|
|
132
129
|
def get_secret_versions(
|
|
133
130
|
identifier: str,
|
|
134
131
|
project: str | None = None,
|
|
135
|
-
**kwargs,
|
|
136
132
|
) -> list[Secret]:
|
|
137
133
|
"""
|
|
138
134
|
Get object versions from backend.
|
|
@@ -143,8 +139,6 @@ def get_secret_versions(
|
|
|
143
139
|
Entity key (store://...) or entity name.
|
|
144
140
|
project : str
|
|
145
141
|
Project name.
|
|
146
|
-
**kwargs : dict
|
|
147
|
-
Parameters to pass to the API call.
|
|
148
142
|
|
|
149
143
|
Returns
|
|
150
144
|
-------
|
|
@@ -161,14 +155,13 @@ def get_secret_versions(
|
|
|
161
155
|
>>> project="my-project")
|
|
162
156
|
"""
|
|
163
157
|
return context_processor.read_context_entity_versions(
|
|
164
|
-
identifier,
|
|
158
|
+
identifier=identifier,
|
|
165
159
|
entity_type=ENTITY_TYPE,
|
|
166
160
|
project=project,
|
|
167
|
-
**kwargs,
|
|
168
161
|
)
|
|
169
162
|
|
|
170
163
|
|
|
171
|
-
def list_secrets(project: str
|
|
164
|
+
def list_secrets(project: str) -> list[Secret]:
|
|
172
165
|
"""
|
|
173
166
|
List all latest version objects from backend.
|
|
174
167
|
|
|
@@ -176,8 +169,6 @@ def list_secrets(project: str, **kwargs) -> list[Secret]:
|
|
|
176
169
|
----------
|
|
177
170
|
project : str
|
|
178
171
|
Project name.
|
|
179
|
-
**kwargs : dict
|
|
180
|
-
Parameters to pass to the API call.
|
|
181
172
|
|
|
182
173
|
Returns
|
|
183
174
|
-------
|
|
@@ -191,18 +182,28 @@ def list_secrets(project: str, **kwargs) -> list[Secret]:
|
|
|
191
182
|
return context_processor.list_context_entities(
|
|
192
183
|
project=project,
|
|
193
184
|
entity_type=ENTITY_TYPE,
|
|
194
|
-
**kwargs,
|
|
195
185
|
)
|
|
196
186
|
|
|
197
187
|
|
|
198
|
-
def import_secret(
|
|
188
|
+
def import_secret(
|
|
189
|
+
file: str | None = None,
|
|
190
|
+
key: str | None = None,
|
|
191
|
+
reset_id: bool = False,
|
|
192
|
+
context: str | None = None,
|
|
193
|
+
) -> Secret:
|
|
199
194
|
"""
|
|
200
|
-
Import object from a YAML file
|
|
195
|
+
Import an object from a YAML file or from a storage key.
|
|
201
196
|
|
|
202
197
|
Parameters
|
|
203
198
|
----------
|
|
204
199
|
file : str
|
|
205
|
-
Path to YAML file.
|
|
200
|
+
Path to the YAML file.
|
|
201
|
+
key : str
|
|
202
|
+
Entity key (store://...).
|
|
203
|
+
reset_id : bool
|
|
204
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
205
|
+
context : str
|
|
206
|
+
Project name to use for context resolution.
|
|
206
207
|
|
|
207
208
|
Returns
|
|
208
209
|
-------
|
|
@@ -213,7 +214,12 @@ def import_secret(file: str) -> Secret:
|
|
|
213
214
|
--------
|
|
214
215
|
>>> obj = import_secret("my-secret.yaml")
|
|
215
216
|
"""
|
|
216
|
-
return context_processor.import_context_entity(
|
|
217
|
+
return context_processor.import_context_entity(
|
|
218
|
+
file,
|
|
219
|
+
key,
|
|
220
|
+
reset_id,
|
|
221
|
+
context,
|
|
222
|
+
)
|
|
217
223
|
|
|
218
224
|
|
|
219
225
|
def load_secret(file: str) -> Secret:
|
|
@@ -268,7 +274,6 @@ def delete_secret(
|
|
|
268
274
|
project: str | None = None,
|
|
269
275
|
entity_id: str | None = None,
|
|
270
276
|
delete_all_versions: bool = False,
|
|
271
|
-
**kwargs,
|
|
272
277
|
) -> dict:
|
|
273
278
|
"""
|
|
274
279
|
Delete object from backend.
|
|
@@ -282,9 +287,8 @@ def delete_secret(
|
|
|
282
287
|
entity_id : str
|
|
283
288
|
Entity ID.
|
|
284
289
|
delete_all_versions : bool
|
|
285
|
-
Delete all versions of the named entity.
|
|
286
|
-
|
|
287
|
-
Parameters to pass to the API call.
|
|
290
|
+
Delete all versions of the named entity.
|
|
291
|
+
If True, use entity name instead of entity key as identifier.
|
|
288
292
|
|
|
289
293
|
Returns
|
|
290
294
|
-------
|
|
@@ -307,5 +311,4 @@ def delete_secret(
|
|
|
307
311
|
project=project,
|
|
308
312
|
entity_id=entity_id,
|
|
309
313
|
delete_all_versions=delete_all_versions,
|
|
310
|
-
**kwargs,
|
|
311
314
|
)
|
|
@@ -8,8 +8,8 @@ import typing
|
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._base.unversioned.entity import UnversionedEntity
|
|
10
10
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
11
|
-
from digitalhub.entities._processors.
|
|
12
|
-
from digitalhub.factory.
|
|
11
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
12
|
+
from digitalhub.factory.entity import entity_factory
|
|
13
13
|
|
|
14
14
|
if typing.TYPE_CHECKING:
|
|
15
15
|
from digitalhub.entities._base.entity.metadata import Metadata
|
|
@@ -67,8 +67,8 @@ class Task(UnversionedEntity):
|
|
|
67
67
|
Run
|
|
68
68
|
Run object.
|
|
69
69
|
"""
|
|
70
|
-
exec_kind =
|
|
71
|
-
exec_type =
|
|
70
|
+
exec_kind = entity_factory.get_executable_kind(self.kind)
|
|
71
|
+
exec_type = entity_factory.get_entity_type_from_kind(exec_kind)
|
|
72
72
|
kwargs[exec_type] = getattr(self.spec, exec_type)
|
|
73
73
|
return self.new_run(
|
|
74
74
|
save=save,
|
|
@@ -112,7 +112,7 @@ class Task(UnversionedEntity):
|
|
|
112
112
|
"""
|
|
113
113
|
if save:
|
|
114
114
|
return context_processor.create_context_entity(**kwargs)
|
|
115
|
-
return
|
|
115
|
+
return entity_factory.build_entity_from_params(**kwargs)
|
|
116
116
|
|
|
117
117
|
def get_run(self, entity_key: str) -> Run:
|
|
118
118
|
"""
|
|
@@ -18,6 +18,7 @@ class VolumeType(Enum):
|
|
|
18
18
|
PERSISTENT_VOLUME_CLAIM = "persistent_volume_claim"
|
|
19
19
|
EMPTY_DIR = "empty_dir"
|
|
20
20
|
EPHEMERAL = "ephemeral"
|
|
21
|
+
SHARED_VOLUME = "shared_volume"
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
class SpecEmptyDir(BaseModel):
|
|
@@ -46,6 +47,14 @@ class SpecEphemeral(BaseModel):
|
|
|
46
47
|
size: Optional[str] = None
|
|
47
48
|
|
|
48
49
|
|
|
50
|
+
class SharedVolumeSpec(BaseModel):
|
|
51
|
+
"""
|
|
52
|
+
Shared volume spec model.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
size: Optional[str] = None
|
|
56
|
+
|
|
57
|
+
|
|
49
58
|
class Volume(BaseModel):
|
|
50
59
|
"""
|
|
51
60
|
Volume model.
|
|
@@ -62,7 +71,7 @@ class Volume(BaseModel):
|
|
|
62
71
|
mount_path: str
|
|
63
72
|
"""Volume mount path inside the container."""
|
|
64
73
|
|
|
65
|
-
spec: Optional[Union[SpecEmptyDir, SpecPVC, SpecEphemeral]] = None
|
|
74
|
+
spec: Optional[Union[SpecEmptyDir, SpecPVC, SpecEphemeral, SharedVolumeSpec]] = None
|
|
66
75
|
"""Volume spec."""
|
|
67
76
|
|
|
68
77
|
|
|
@@ -78,30 +87,18 @@ class NodeSelector(BaseModel):
|
|
|
78
87
|
"""Node selector value."""
|
|
79
88
|
|
|
80
89
|
|
|
81
|
-
class ResourceItem(BaseModel):
|
|
82
|
-
"""
|
|
83
|
-
Resource item model.
|
|
84
|
-
"""
|
|
85
|
-
|
|
86
|
-
requests: str = Field(default=None, pattern=r"[\d]+|^([0-9])+([a-zA-Z])+$")
|
|
87
|
-
"""Resource requests."""
|
|
88
|
-
|
|
89
|
-
limits: str = Field(default=None, pattern=r"[\d]+|^([0-9])+([a-zA-Z])+$")
|
|
90
|
-
"""Resource limits."""
|
|
91
|
-
|
|
92
|
-
|
|
93
90
|
class Resource(BaseModel):
|
|
94
91
|
"""
|
|
95
92
|
Resource model.
|
|
96
93
|
"""
|
|
97
94
|
|
|
98
|
-
cpu: Optional[
|
|
95
|
+
cpu: Optional[str] = Field(default=None, pattern=r"[\d]+|^([0-9])+([a-zA-Z])+$")
|
|
99
96
|
"""CPU resource model."""
|
|
100
97
|
|
|
101
|
-
mem: Optional[
|
|
98
|
+
mem: Optional[str] = Field(default=None, pattern=r"[\d]+|^([0-9])+([a-zA-Z])+$")
|
|
102
99
|
"""Memory resource model."""
|
|
103
100
|
|
|
104
|
-
gpu: Optional[
|
|
101
|
+
gpu: Optional[str] = Field(default=None, pattern=r"[\d]+|^([0-9])+([a-zA-Z])+$")
|
|
105
102
|
"""GPU resource model."""
|
|
106
103
|
|
|
107
104
|
|
digitalhub/entities/task/crud.py
CHANGED
|
@@ -7,8 +7,7 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
10
|
-
from digitalhub.entities._processors.
|
|
11
|
-
from digitalhub.utils.exceptions import EntityError
|
|
10
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
12
11
|
|
|
13
12
|
if typing.TYPE_CHECKING:
|
|
14
13
|
from digitalhub.entities.task._base.entity import Task
|
|
@@ -71,7 +70,6 @@ def new_task(
|
|
|
71
70
|
def get_task(
|
|
72
71
|
identifier: str,
|
|
73
72
|
project: str | None = None,
|
|
74
|
-
**kwargs,
|
|
75
73
|
) -> Task:
|
|
76
74
|
"""
|
|
77
75
|
Get object from backend.
|
|
@@ -82,8 +80,6 @@ def get_task(
|
|
|
82
80
|
Entity key (store://...) or entity ID.
|
|
83
81
|
project : str
|
|
84
82
|
Project name.
|
|
85
|
-
**kwargs : dict
|
|
86
|
-
Parameters to pass to the API call.
|
|
87
83
|
|
|
88
84
|
Returns
|
|
89
85
|
-------
|
|
@@ -100,14 +96,24 @@ def get_task(
|
|
|
100
96
|
>>> project="my-project")
|
|
101
97
|
"""
|
|
102
98
|
return context_processor.read_unversioned_entity(
|
|
103
|
-
identifier,
|
|
99
|
+
identifier=identifier,
|
|
104
100
|
entity_type=ENTITY_TYPE,
|
|
105
101
|
project=project,
|
|
106
|
-
**kwargs,
|
|
107
102
|
)
|
|
108
103
|
|
|
109
104
|
|
|
110
|
-
def list_tasks(
|
|
105
|
+
def list_tasks(
|
|
106
|
+
project: str,
|
|
107
|
+
q: str | None = None,
|
|
108
|
+
name: str | None = None,
|
|
109
|
+
kind: str | None = None,
|
|
110
|
+
user: str | None = None,
|
|
111
|
+
state: str | None = None,
|
|
112
|
+
created: str | None = None,
|
|
113
|
+
updated: str | None = None,
|
|
114
|
+
function: str | None = None,
|
|
115
|
+
workflow: str | None = None,
|
|
116
|
+
) -> list[Task]:
|
|
111
117
|
"""
|
|
112
118
|
List all latest version objects from backend.
|
|
113
119
|
|
|
@@ -115,8 +121,24 @@ def list_tasks(project: str, **kwargs) -> list[Task]:
|
|
|
115
121
|
----------
|
|
116
122
|
project : str
|
|
117
123
|
Project name.
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
q : str
|
|
125
|
+
Query string to filter objects.
|
|
126
|
+
name : str
|
|
127
|
+
Object name.
|
|
128
|
+
kind : str
|
|
129
|
+
Kind of the object.
|
|
130
|
+
user : str
|
|
131
|
+
User that created the object.
|
|
132
|
+
state : str
|
|
133
|
+
Object state.
|
|
134
|
+
created : str
|
|
135
|
+
Creation date filter.
|
|
136
|
+
updated : str
|
|
137
|
+
Update date filter.
|
|
138
|
+
function : str
|
|
139
|
+
Function key filter.
|
|
140
|
+
workflow : str
|
|
141
|
+
Workflow key filter.
|
|
120
142
|
|
|
121
143
|
Returns
|
|
122
144
|
-------
|
|
@@ -130,18 +152,37 @@ def list_tasks(project: str, **kwargs) -> list[Task]:
|
|
|
130
152
|
return context_processor.list_context_entities(
|
|
131
153
|
project=project,
|
|
132
154
|
entity_type=ENTITY_TYPE,
|
|
133
|
-
|
|
155
|
+
q=q,
|
|
156
|
+
name=name,
|
|
157
|
+
kind=kind,
|
|
158
|
+
user=user,
|
|
159
|
+
state=state,
|
|
160
|
+
created=created,
|
|
161
|
+
updated=updated,
|
|
162
|
+
function=function,
|
|
163
|
+
workflow=workflow,
|
|
134
164
|
)
|
|
135
165
|
|
|
136
166
|
|
|
137
|
-
def import_task(
|
|
167
|
+
def import_task(
|
|
168
|
+
file: str | None = None,
|
|
169
|
+
key: str | None = None,
|
|
170
|
+
reset_id: bool = False,
|
|
171
|
+
context: str | None = None,
|
|
172
|
+
) -> Task:
|
|
138
173
|
"""
|
|
139
|
-
Import object from a YAML file
|
|
174
|
+
Import an object from a YAML file or from a storage key.
|
|
140
175
|
|
|
141
176
|
Parameters
|
|
142
177
|
----------
|
|
143
178
|
file : str
|
|
144
|
-
Path to YAML file.
|
|
179
|
+
Path to the YAML file.
|
|
180
|
+
key : str
|
|
181
|
+
Entity key (store://...).
|
|
182
|
+
reset_id : bool
|
|
183
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
184
|
+
context : str
|
|
185
|
+
Project name to use for context resolution.
|
|
145
186
|
|
|
146
187
|
Returns
|
|
147
188
|
-------
|
|
@@ -152,7 +193,12 @@ def import_task(file: str) -> Task:
|
|
|
152
193
|
-------
|
|
153
194
|
>>> obj = import_task("my-task.yaml")
|
|
154
195
|
"""
|
|
155
|
-
return context_processor.import_context_entity(
|
|
196
|
+
return context_processor.import_context_entity(
|
|
197
|
+
file,
|
|
198
|
+
key,
|
|
199
|
+
reset_id,
|
|
200
|
+
context,
|
|
201
|
+
)
|
|
156
202
|
|
|
157
203
|
|
|
158
204
|
def load_task(file: str) -> Task:
|
|
@@ -206,9 +252,7 @@ def delete_task(
|
|
|
206
252
|
identifier: str,
|
|
207
253
|
project: str | None = None,
|
|
208
254
|
entity_id: str | None = None,
|
|
209
|
-
delete_all_versions: bool = False,
|
|
210
255
|
cascade: bool = True,
|
|
211
|
-
**kwargs,
|
|
212
256
|
) -> dict:
|
|
213
257
|
"""
|
|
214
258
|
Delete object from backend.
|
|
@@ -221,8 +265,6 @@ def delete_task(
|
|
|
221
265
|
Project name.
|
|
222
266
|
entity_id : str
|
|
223
267
|
Entity ID.
|
|
224
|
-
delete_all_versions : bool
|
|
225
|
-
Delete all versions of the named entity. If True, use entity name instead of entity key as identifier.
|
|
226
268
|
cascade : bool
|
|
227
269
|
Cascade delete.
|
|
228
270
|
**kwargs : dict
|
|
@@ -235,22 +277,12 @@ def delete_task(
|
|
|
235
277
|
|
|
236
278
|
Examples
|
|
237
279
|
--------
|
|
238
|
-
If delete_all_versions is False:
|
|
239
280
|
>>> obj = delete_task("store://my-task-key")
|
|
240
|
-
|
|
241
|
-
Otherwise:
|
|
242
|
-
>>> obj = delete_task("task-name",
|
|
243
|
-
>>> project="my-project",
|
|
244
|
-
>>> delete_all_versions=True)
|
|
245
281
|
"""
|
|
246
|
-
if not identifier.startswith("store://"):
|
|
247
|
-
raise EntityError("Task has no name. Use key instead.")
|
|
248
282
|
return context_processor.delete_context_entity(
|
|
249
283
|
identifier=identifier,
|
|
250
284
|
entity_type=ENTITY_TYPE,
|
|
251
285
|
project=project,
|
|
252
286
|
entity_id=entity_id,
|
|
253
|
-
delete_all_versions=delete_all_versions,
|
|
254
287
|
cascade=cascade,
|
|
255
|
-
**kwargs,
|
|
256
288
|
)
|
|
@@ -8,7 +8,7 @@ import typing
|
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._base.versioned.entity import VersionedEntity
|
|
10
10
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
11
|
-
from digitalhub.entities._processors.
|
|
11
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
12
12
|
|
|
13
13
|
if typing.TYPE_CHECKING:
|
|
14
14
|
from digitalhub.entities._base.entity.metadata import Metadata
|
|
@@ -41,9 +41,5 @@ class Trigger(VersionedEntity):
|
|
|
41
41
|
def stop(self) -> None:
|
|
42
42
|
"""
|
|
43
43
|
Stop trigger.
|
|
44
|
-
|
|
45
|
-
Returns
|
|
46
|
-
-------
|
|
47
|
-
None
|
|
48
44
|
"""
|
|
49
45
|
return context_processor.stop_entity(self.project, self.ENTITY_TYPE, self.id)
|