digitalhub 0.14.0b5__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 +2 -2
- digitalhub/context/api.py +43 -6
- digitalhub/context/builder.py +1 -1
- digitalhub/context/context.py +3 -6
- digitalhub/entities/_base/context/entity.py +0 -3
- digitalhub/entities/_base/executable/entity.py +29 -11
- digitalhub/entities/_base/material/entity.py +2 -2
- digitalhub/entities/_base/material/utils.py +0 -4
- digitalhub/entities/_commons/enums.py +1 -0
- digitalhub/entities/_commons/utils.py +19 -0
- digitalhub/entities/_processors/base/crud.py +15 -24
- digitalhub/entities/_processors/base/import_export.py +3 -7
- digitalhub/entities/_processors/base/processor.py +4 -7
- digitalhub/entities/_processors/base/special_ops.py +4 -8
- digitalhub/entities/_processors/context/crud.py +27 -29
- digitalhub/entities/_processors/context/import_export.py +7 -7
- digitalhub/entities/_processors/context/material.py +2 -2
- digitalhub/entities/_processors/context/special_ops.py +25 -25
- digitalhub/entities/_processors/utils.py +7 -116
- digitalhub/entities/artifact/crud.py +3 -3
- digitalhub/entities/artifact/utils.py +2 -2
- digitalhub/entities/builders.py +2 -0
- digitalhub/entities/dataitem/crud.py +3 -3
- digitalhub/entities/dataitem/utils.py +10 -14
- digitalhub/entities/function/_base/entity.py +0 -3
- digitalhub/entities/function/crud.py +3 -3
- digitalhub/entities/model/crud.py +3 -3
- digitalhub/entities/model/mlflow/utils.py +29 -20
- digitalhub/entities/model/utils.py +2 -2
- digitalhub/entities/project/_base/builder.py +0 -6
- digitalhub/entities/project/_base/entity.py +264 -114
- digitalhub/entities/project/_base/spec.py +4 -4
- digitalhub/entities/project/crud.py +16 -51
- digitalhub/entities/project/utils.py +7 -3
- digitalhub/entities/secret/crud.py +2 -2
- digitalhub/entities/task/_base/models.py +13 -16
- digitalhub/entities/trigger/crud.py +28 -9
- digitalhub/entities/workflow/_base/entity.py +0 -5
- digitalhub/entities/workflow/crud.py +3 -6
- digitalhub/stores/client/{dhcore/api_builder.py → api_builder.py} +2 -3
- digitalhub/stores/client/builder.py +20 -32
- digitalhub/stores/client/client.py +322 -0
- digitalhub/stores/client/{dhcore/configurator.py → configurator.py} +148 -195
- digitalhub/stores/client/{_base/enums.py → enums.py} +11 -0
- 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/{dhcore/params_builder.py → params_builder.py} +51 -12
- 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 +26 -10
- digitalhub/stores/configurator/handler.py +213 -0
- digitalhub/stores/{credentials → configurator}/ini_module.py +31 -6
- digitalhub/stores/data/_base/store.py +0 -4
- digitalhub/stores/data/api.py +4 -6
- digitalhub/stores/data/builder.py +6 -38
- digitalhub/stores/data/s3/configurator.py +30 -114
- digitalhub/stores/data/s3/store.py +9 -22
- digitalhub/stores/data/sql/configurator.py +49 -71
- digitalhub/stores/data/sql/store.py +26 -61
- digitalhub/utils/generic_utils.py +0 -12
- digitalhub/utils/git_utils.py +0 -8
- digitalhub/utils/io_utils.py +0 -8
- digitalhub/utils/store_utils.py +1 -1
- {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/METADATA +3 -3
- {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/RECORD +73 -86
- {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/WHEEL +1 -1
- 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 -82
- digitalhub/stores/client/api.py +0 -32
- digitalhub/stores/client/dhcore/__init__.py +0 -3
- digitalhub/stores/client/dhcore/client.py +0 -553
- digitalhub/stores/client/dhcore/enums.py +0 -18
- digitalhub/stores/client/dhcore/key_builder.py +0 -62
- digitalhub/stores/client/dhcore/utils.py +0 -86
- digitalhub/stores/client/local/__init__.py +0 -3
- digitalhub/stores/client/local/api_builder.py +0 -116
- digitalhub/stores/client/local/client.py +0 -605
- 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 -97
- digitalhub/stores/credentials/__init__.py +0 -3
- digitalhub/stores/credentials/configurator.py +0 -185
- digitalhub/stores/credentials/handler.py +0 -164
- digitalhub/stores/credentials/store.py +0 -77
- digitalhub/stores/data/enums.py +0 -15
- /digitalhub/stores/client/{dhcore/error_parser.py → error_parser.py} +0 -0
- /digitalhub/stores/{client/_base → configurator}/__init__.py +0 -0
- {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/licenses/LICENSE +0 -0
|
@@ -17,7 +17,7 @@ class ProjectSpec(Spec):
|
|
|
17
17
|
|
|
18
18
|
def __init__(
|
|
19
19
|
self,
|
|
20
|
-
|
|
20
|
+
source: str | None = None,
|
|
21
21
|
functions: list | None = None,
|
|
22
22
|
artifacts: list | None = None,
|
|
23
23
|
workflows: list | None = None,
|
|
@@ -26,7 +26,7 @@ class ProjectSpec(Spec):
|
|
|
26
26
|
config: dict | None = None,
|
|
27
27
|
**kwargs,
|
|
28
28
|
) -> None:
|
|
29
|
-
self.
|
|
29
|
+
self.source = source if source is not None else "./"
|
|
30
30
|
self.functions = functions if functions is not None else []
|
|
31
31
|
self.artifacts = artifacts if artifacts is not None else []
|
|
32
32
|
self.workflows = workflows if workflows is not None else []
|
|
@@ -40,8 +40,8 @@ class ProjectValidator(SpecValidator):
|
|
|
40
40
|
ProjectValidator validator.
|
|
41
41
|
"""
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
"""The project's
|
|
43
|
+
source: Optional[str] = None
|
|
44
|
+
"""The project's source."""
|
|
45
45
|
|
|
46
46
|
functions: Optional[list] = None
|
|
47
47
|
"""List of project's functions."""
|
|
@@ -6,7 +6,7 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
|
-
from digitalhub.entities._commons.enums import EntityTypes
|
|
9
|
+
from digitalhub.entities._commons.enums import EntityKinds, EntityTypes
|
|
10
10
|
from digitalhub.entities._processors.processors import base_processor, context_processor
|
|
11
11
|
from digitalhub.entities.project.utils import setup_project
|
|
12
12
|
from digitalhub.utils.exceptions import BackendError
|
|
@@ -23,11 +23,9 @@ def new_project(
|
|
|
23
23
|
name: str,
|
|
24
24
|
description: str | None = None,
|
|
25
25
|
labels: list[str] | None = None,
|
|
26
|
-
local: bool = False,
|
|
27
26
|
config: dict | None = None,
|
|
28
|
-
|
|
27
|
+
source: str | None = None,
|
|
29
28
|
setup_kwargs: dict | None = None,
|
|
30
|
-
**kwargs,
|
|
31
29
|
) -> Project:
|
|
32
30
|
"""
|
|
33
31
|
Create a new object.
|
|
@@ -40,16 +38,12 @@ def new_project(
|
|
|
40
38
|
Description of the object (human readable).
|
|
41
39
|
labels : list[str]
|
|
42
40
|
List of labels.
|
|
43
|
-
local : bool
|
|
44
|
-
If True, use local backend, if False use DHCore backend. Default to False.
|
|
45
41
|
config : dict
|
|
46
42
|
DHCore environment configuration.
|
|
47
|
-
|
|
43
|
+
source : str
|
|
48
44
|
The context local folder of the project.
|
|
49
45
|
setup_kwargs : dict
|
|
50
46
|
Setup keyword arguments passed to setup_project() function.
|
|
51
|
-
**kwargs : dict
|
|
52
|
-
Keyword arguments.
|
|
53
47
|
|
|
54
48
|
Returns
|
|
55
49
|
-------
|
|
@@ -60,24 +54,21 @@ def new_project(
|
|
|
60
54
|
--------
|
|
61
55
|
>>> obj = new_project("my-project")
|
|
62
56
|
"""
|
|
63
|
-
if
|
|
64
|
-
|
|
57
|
+
if source is None:
|
|
58
|
+
source = "./"
|
|
65
59
|
obj = base_processor.create_project_entity(
|
|
66
60
|
name=name,
|
|
67
|
-
kind=
|
|
61
|
+
kind=EntityKinds.PROJECT_PROJECT.value,
|
|
68
62
|
description=description,
|
|
69
63
|
labels=labels,
|
|
70
|
-
local=local,
|
|
71
64
|
config=config,
|
|
72
|
-
|
|
73
|
-
**kwargs,
|
|
65
|
+
source=source,
|
|
74
66
|
)
|
|
75
67
|
return setup_project(obj, setup_kwargs)
|
|
76
68
|
|
|
77
69
|
|
|
78
70
|
def get_project(
|
|
79
71
|
name: str,
|
|
80
|
-
local: bool = False,
|
|
81
72
|
setup_kwargs: dict | None = None,
|
|
82
73
|
) -> Project:
|
|
83
74
|
"""
|
|
@@ -87,8 +78,6 @@ def get_project(
|
|
|
87
78
|
----------
|
|
88
79
|
name : str
|
|
89
80
|
The Project name.
|
|
90
|
-
local : bool
|
|
91
|
-
Flag to determine if backend is local.
|
|
92
81
|
setup_kwargs : dict
|
|
93
82
|
Setup keyword arguments passed to setup_project() function.
|
|
94
83
|
|
|
@@ -104,14 +93,12 @@ def get_project(
|
|
|
104
93
|
obj = base_processor.read_project_entity(
|
|
105
94
|
entity_type=ENTITY_TYPE,
|
|
106
95
|
entity_name=name,
|
|
107
|
-
local=local,
|
|
108
96
|
)
|
|
109
97
|
return setup_project(obj, setup_kwargs)
|
|
110
98
|
|
|
111
99
|
|
|
112
100
|
def import_project(
|
|
113
101
|
file: str,
|
|
114
|
-
local: bool = False,
|
|
115
102
|
setup_kwargs: dict | None = None,
|
|
116
103
|
reset_id: bool = False,
|
|
117
104
|
) -> Project:
|
|
@@ -122,8 +109,6 @@ def import_project(
|
|
|
122
109
|
----------
|
|
123
110
|
file : str
|
|
124
111
|
Path to YAML file.
|
|
125
|
-
local : bool
|
|
126
|
-
Flag to determine if backend is local.
|
|
127
112
|
setup_kwargs : dict
|
|
128
113
|
Setup keyword arguments passed to setup_project() function.
|
|
129
114
|
reset_id : bool
|
|
@@ -140,7 +125,6 @@ def import_project(
|
|
|
140
125
|
"""
|
|
141
126
|
obj = base_processor.import_project_entity(
|
|
142
127
|
file=file,
|
|
143
|
-
local=local,
|
|
144
128
|
reset_id=reset_id,
|
|
145
129
|
)
|
|
146
130
|
return setup_project(obj, setup_kwargs)
|
|
@@ -148,7 +132,6 @@ def import_project(
|
|
|
148
132
|
|
|
149
133
|
def load_project(
|
|
150
134
|
file: str,
|
|
151
|
-
local: bool = False,
|
|
152
135
|
setup_kwargs: dict | None = None,
|
|
153
136
|
) -> Project:
|
|
154
137
|
"""
|
|
@@ -158,8 +141,6 @@ def load_project(
|
|
|
158
141
|
----------
|
|
159
142
|
file : str
|
|
160
143
|
Path to YAML file.
|
|
161
|
-
local : bool
|
|
162
|
-
Flag to determine if backend is local.
|
|
163
144
|
setup_kwargs : dict
|
|
164
145
|
Setup keyword arguments passed to setup_project() function.
|
|
165
146
|
|
|
@@ -172,34 +153,30 @@ def load_project(
|
|
|
172
153
|
--------
|
|
173
154
|
>>> obj = load_project("my-project.yaml")
|
|
174
155
|
"""
|
|
175
|
-
obj = base_processor.load_project_entity(file=file
|
|
156
|
+
obj = base_processor.load_project_entity(file=file)
|
|
176
157
|
return setup_project(obj, setup_kwargs)
|
|
177
158
|
|
|
178
159
|
|
|
179
|
-
def list_projects(
|
|
160
|
+
def list_projects() -> list[Project]:
|
|
180
161
|
"""
|
|
181
162
|
List projects in backend.
|
|
182
163
|
|
|
183
|
-
Parameters
|
|
184
|
-
----------
|
|
185
|
-
local : bool
|
|
186
|
-
Flag to determine if backend is local.
|
|
187
164
|
|
|
188
165
|
Returns
|
|
189
166
|
-------
|
|
190
167
|
list
|
|
191
168
|
List of objects.
|
|
192
169
|
"""
|
|
193
|
-
return base_processor.list_project_entities(
|
|
170
|
+
return base_processor.list_project_entities(ENTITY_TYPE)
|
|
194
171
|
|
|
195
172
|
|
|
196
173
|
def get_or_create_project(
|
|
197
174
|
name: str,
|
|
198
|
-
|
|
175
|
+
description: str | None = None,
|
|
176
|
+
labels: list[str] | None = None,
|
|
199
177
|
config: dict | None = None,
|
|
200
178
|
context: str | None = None,
|
|
201
179
|
setup_kwargs: dict | None = None,
|
|
202
|
-
**kwargs,
|
|
203
180
|
) -> Project:
|
|
204
181
|
"""
|
|
205
182
|
Try to get project. If not exists, create it.
|
|
@@ -208,8 +185,6 @@ def get_or_create_project(
|
|
|
208
185
|
----------
|
|
209
186
|
name : str
|
|
210
187
|
Project name.
|
|
211
|
-
local : bool
|
|
212
|
-
Flag to determine if backend is local.
|
|
213
188
|
config : dict
|
|
214
189
|
DHCore environment configuration.
|
|
215
190
|
context : str
|
|
@@ -227,22 +202,20 @@ def get_or_create_project(
|
|
|
227
202
|
try:
|
|
228
203
|
return get_project(
|
|
229
204
|
name,
|
|
230
|
-
local=local,
|
|
231
205
|
setup_kwargs=setup_kwargs,
|
|
232
|
-
**kwargs,
|
|
233
206
|
)
|
|
234
207
|
except BackendError:
|
|
235
208
|
return new_project(
|
|
236
209
|
name,
|
|
237
|
-
|
|
210
|
+
description=description,
|
|
211
|
+
labels=labels,
|
|
238
212
|
config=config,
|
|
239
213
|
setup_kwargs=setup_kwargs,
|
|
240
|
-
|
|
241
|
-
**kwargs,
|
|
214
|
+
source=context,
|
|
242
215
|
)
|
|
243
216
|
|
|
244
217
|
|
|
245
|
-
def update_project(entity: Project
|
|
218
|
+
def update_project(entity: Project) -> Project:
|
|
246
219
|
"""
|
|
247
220
|
Update object. Note that object spec are immutable.
|
|
248
221
|
|
|
@@ -250,8 +223,6 @@ def update_project(entity: Project, **kwargs) -> Project:
|
|
|
250
223
|
----------
|
|
251
224
|
entity : Project
|
|
252
225
|
Object to update.
|
|
253
|
-
**kwargs : dict
|
|
254
|
-
Parameters to pass to the API call.
|
|
255
226
|
|
|
256
227
|
Returns
|
|
257
228
|
-------
|
|
@@ -266,8 +237,6 @@ def update_project(entity: Project, **kwargs) -> Project:
|
|
|
266
237
|
entity_type=entity.ENTITY_TYPE,
|
|
267
238
|
entity_name=entity.name,
|
|
268
239
|
entity_dict=entity.to_dict(),
|
|
269
|
-
local=entity._client.is_local(),
|
|
270
|
-
**kwargs,
|
|
271
240
|
)
|
|
272
241
|
|
|
273
242
|
|
|
@@ -275,7 +244,6 @@ def delete_project(
|
|
|
275
244
|
name: str,
|
|
276
245
|
cascade: bool = True,
|
|
277
246
|
clean_context: bool = True,
|
|
278
|
-
local: bool = False,
|
|
279
247
|
) -> dict:
|
|
280
248
|
"""
|
|
281
249
|
Delete a project.
|
|
@@ -288,8 +256,6 @@ def delete_project(
|
|
|
288
256
|
Flag to determine if delete is cascading.
|
|
289
257
|
clean_context : bool
|
|
290
258
|
Flag to determine if context will be deleted.
|
|
291
|
-
local : bool
|
|
292
|
-
Flag to determine if backend is local.
|
|
293
259
|
|
|
294
260
|
Returns
|
|
295
261
|
-------
|
|
@@ -303,7 +269,6 @@ def delete_project(
|
|
|
303
269
|
return base_processor.delete_project_entity(
|
|
304
270
|
entity_type=ENTITY_TYPE,
|
|
305
271
|
entity_name=name,
|
|
306
|
-
local=local,
|
|
307
272
|
cascade=cascade,
|
|
308
273
|
clean_context=clean_context,
|
|
309
274
|
)
|
|
@@ -12,6 +12,10 @@ from digitalhub.utils.generic_utils import import_function
|
|
|
12
12
|
if typing.TYPE_CHECKING:
|
|
13
13
|
from digitalhub.entities.project._base.entity import Project
|
|
14
14
|
|
|
15
|
+
CHECK_FILENAME = ".CHECK"
|
|
16
|
+
SETUP_MODULE = "setup_project.py"
|
|
17
|
+
SETUP_FUNCTION = "setup"
|
|
18
|
+
|
|
15
19
|
|
|
16
20
|
def setup_project(project: Project, setup_kwargs: dict | None = None) -> Project:
|
|
17
21
|
"""
|
|
@@ -30,10 +34,10 @@ def setup_project(project: Project, setup_kwargs: dict | None = None) -> Project
|
|
|
30
34
|
Set up project.
|
|
31
35
|
"""
|
|
32
36
|
setup_kwargs = setup_kwargs if setup_kwargs is not None else {}
|
|
33
|
-
check_pth = Path(project.spec.
|
|
34
|
-
setup_pth = Path(project.spec.
|
|
37
|
+
check_pth = Path(project.spec.source, CHECK_FILENAME)
|
|
38
|
+
setup_pth = Path(project.spec.source, SETUP_MODULE)
|
|
35
39
|
if setup_pth.exists() and not check_pth.exists():
|
|
36
|
-
setup_fnc = import_function(setup_pth,
|
|
40
|
+
setup_fnc = import_function(setup_pth, SETUP_FUNCTION)
|
|
37
41
|
project = setup_fnc(project, **setup_kwargs)
|
|
38
42
|
check_pth.touch()
|
|
39
43
|
return project
|
|
@@ -6,7 +6,7 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
|
-
from digitalhub.entities._commons.enums import EntityTypes
|
|
9
|
+
from digitalhub.entities._commons.enums import EntityKinds, EntityTypes
|
|
10
10
|
from digitalhub.entities._commons.utils import is_valid_key
|
|
11
11
|
from digitalhub.entities._processors.processors import context_processor
|
|
12
12
|
from digitalhub.utils.exceptions import EntityNotExistsError
|
|
@@ -66,7 +66,7 @@ def new_secret(
|
|
|
66
66
|
obj: Secret = context_processor.create_context_entity(
|
|
67
67
|
project=project,
|
|
68
68
|
name=name,
|
|
69
|
-
kind=
|
|
69
|
+
kind=EntityKinds.SECRET_SECRET.value,
|
|
70
70
|
uuid=uuid,
|
|
71
71
|
description=description,
|
|
72
72
|
labels=labels,
|
|
@@ -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
|
|
|
@@ -41,6 +41,12 @@ def new_trigger(
|
|
|
41
41
|
Object name.
|
|
42
42
|
kind : str
|
|
43
43
|
Kind the object.
|
|
44
|
+
task : str
|
|
45
|
+
Task string.
|
|
46
|
+
function : str
|
|
47
|
+
Function string.
|
|
48
|
+
workflow : str
|
|
49
|
+
Workflow string.
|
|
44
50
|
uuid : str
|
|
45
51
|
ID of the object.
|
|
46
52
|
description : str
|
|
@@ -63,18 +69,31 @@ def new_trigger(
|
|
|
63
69
|
>>> kind="trigger",
|
|
64
70
|
>>> name="my-trigger",)
|
|
65
71
|
"""
|
|
66
|
-
if workflow is None
|
|
67
|
-
|
|
72
|
+
if workflow is None:
|
|
73
|
+
if function is None:
|
|
74
|
+
raise ValueError("Workflow or function must be provided")
|
|
75
|
+
executable_type = "function"
|
|
76
|
+
executable = function
|
|
77
|
+
else:
|
|
78
|
+
executable_type = "workflow"
|
|
79
|
+
executable = workflow
|
|
80
|
+
|
|
81
|
+
# Prepare kwargs
|
|
68
82
|
if kwargs is None:
|
|
69
83
|
kwargs = {}
|
|
84
|
+
kwargs["task"] = task
|
|
85
|
+
kwargs[executable_type] = executable
|
|
86
|
+
|
|
87
|
+
# Template handling
|
|
70
88
|
if template is None:
|
|
71
89
|
template = {}
|
|
90
|
+
if not isinstance(template, dict):
|
|
91
|
+
raise ValueError("Template must be a dictionary")
|
|
72
92
|
template["task"] = task
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if function is not None:
|
|
76
|
-
template["function"] = function
|
|
93
|
+
template[executable_type] = executable
|
|
94
|
+
template["local_execution"] = False
|
|
77
95
|
kwargs["template"] = template
|
|
96
|
+
|
|
78
97
|
return context_processor.create_context_entity(
|
|
79
98
|
project=project,
|
|
80
99
|
name=name,
|
|
@@ -171,7 +190,7 @@ def list_triggers(
|
|
|
171
190
|
state: str | None = None,
|
|
172
191
|
created: str | None = None,
|
|
173
192
|
updated: str | None = None,
|
|
174
|
-
|
|
193
|
+
versions: str | None = None,
|
|
175
194
|
task: str | None = None,
|
|
176
195
|
) -> list[Trigger]:
|
|
177
196
|
"""
|
|
@@ -195,7 +214,7 @@ def list_triggers(
|
|
|
195
214
|
Creation date filter.
|
|
196
215
|
updated : str
|
|
197
216
|
Update date filter.
|
|
198
|
-
|
|
217
|
+
versions : str
|
|
199
218
|
Object version, default is latest.
|
|
200
219
|
task : str
|
|
201
220
|
Task string filter.
|
|
@@ -219,7 +238,7 @@ def list_triggers(
|
|
|
219
238
|
state=state,
|
|
220
239
|
created=created,
|
|
221
240
|
updated=updated,
|
|
222
|
-
|
|
241
|
+
versions=versions,
|
|
223
242
|
task=task,
|
|
224
243
|
)
|
|
225
244
|
|
|
@@ -9,7 +9,6 @@ import typing
|
|
|
9
9
|
from digitalhub.entities._base.executable.entity import ExecutableEntity
|
|
10
10
|
from digitalhub.entities._commons.enums import EntityTypes, Relationship
|
|
11
11
|
from digitalhub.factory.entity import entity_factory
|
|
12
|
-
from digitalhub.utils.exceptions import BackendError
|
|
13
12
|
|
|
14
13
|
if typing.TYPE_CHECKING:
|
|
15
14
|
from digitalhub.entities._base.entity.metadata import Metadata
|
|
@@ -78,10 +77,6 @@ class Workflow(ExecutableEntity):
|
|
|
78
77
|
# Create or update new task
|
|
79
78
|
task = self._get_or_create_task(task_kind)
|
|
80
79
|
|
|
81
|
-
# Raise error if execution is not done by DHCore backend
|
|
82
|
-
if self._context().local:
|
|
83
|
-
raise BackendError("Cannot run workflow with local backend.")
|
|
84
|
-
|
|
85
80
|
# Run task
|
|
86
81
|
run = task.run(run_kind, save=False, local_execution=False, **kwargs)
|
|
87
82
|
|
|
@@ -155,7 +155,7 @@ def list_workflows(
|
|
|
155
155
|
state: str | None = None,
|
|
156
156
|
created: str | None = None,
|
|
157
157
|
updated: str | None = None,
|
|
158
|
-
|
|
158
|
+
versions: str | None = None,
|
|
159
159
|
) -> list[Workflow]:
|
|
160
160
|
"""
|
|
161
161
|
List all latest version objects from backend.
|
|
@@ -178,7 +178,7 @@ def list_workflows(
|
|
|
178
178
|
Creation date filter.
|
|
179
179
|
updated : str
|
|
180
180
|
Update date filter.
|
|
181
|
-
|
|
181
|
+
versions : str
|
|
182
182
|
Object version, default is latest.
|
|
183
183
|
|
|
184
184
|
Returns
|
|
@@ -200,7 +200,7 @@ def list_workflows(
|
|
|
200
200
|
state=state,
|
|
201
201
|
created=created,
|
|
202
202
|
updated=updated,
|
|
203
|
-
|
|
203
|
+
versions=versions,
|
|
204
204
|
)
|
|
205
205
|
|
|
206
206
|
|
|
@@ -289,7 +289,6 @@ def delete_workflow(
|
|
|
289
289
|
entity_id: str | None = None,
|
|
290
290
|
delete_all_versions: bool = False,
|
|
291
291
|
cascade: bool = True,
|
|
292
|
-
**kwargs,
|
|
293
292
|
) -> dict:
|
|
294
293
|
"""
|
|
295
294
|
Delete object from backend.
|
|
@@ -307,8 +306,6 @@ def delete_workflow(
|
|
|
307
306
|
If True, use entity name instead of entity key as identifier.
|
|
308
307
|
cascade : bool
|
|
309
308
|
Cascade delete.
|
|
310
|
-
**kwargs : dict
|
|
311
|
-
Parameters to pass to the API call.
|
|
312
309
|
|
|
313
310
|
Returns
|
|
314
311
|
-------
|
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
-
from digitalhub.stores.client.
|
|
8
|
-
from digitalhub.stores.client._base.enums import ApiCategories, BackendOperations
|
|
7
|
+
from digitalhub.stores.client.enums import ApiCategories, BackendOperations
|
|
9
8
|
from digitalhub.utils.exceptions import BackendError
|
|
10
9
|
|
|
11
10
|
API_BASE = "/api/v1"
|
|
12
11
|
API_CONTEXT = f"{API_BASE}/-"
|
|
13
12
|
|
|
14
13
|
|
|
15
|
-
class
|
|
14
|
+
class ClientApiBuilder:
|
|
16
15
|
"""
|
|
17
16
|
This class is used to build the API for the DHCore client.
|
|
18
17
|
"""
|
|
@@ -4,53 +4,41 @@
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
from digitalhub.stores.client.dhcore.client import ClientDHCore
|
|
10
|
-
from digitalhub.stores.client.local.client import ClientLocal
|
|
11
|
-
|
|
12
|
-
if typing.TYPE_CHECKING:
|
|
13
|
-
pass
|
|
7
|
+
from digitalhub.stores.client.client import Client
|
|
14
8
|
|
|
15
9
|
|
|
16
10
|
class ClientBuilder:
|
|
17
11
|
"""
|
|
18
|
-
Client builder class.
|
|
19
|
-
|
|
20
|
-
This class is used to create two possible client instances:
|
|
21
|
-
Local and DHCore.
|
|
22
|
-
It saves the client instances in the class attributes using
|
|
23
|
-
singleton pattern.
|
|
12
|
+
Client builder class. Creates and returns client instance.
|
|
24
13
|
"""
|
|
25
14
|
|
|
26
15
|
def __init__(self) -> None:
|
|
27
|
-
self.
|
|
28
|
-
self._dhcore = None
|
|
16
|
+
self._client: Client = None
|
|
29
17
|
|
|
30
|
-
def build(self
|
|
18
|
+
def build(self) -> Client:
|
|
31
19
|
"""
|
|
32
20
|
Method to create a client instance.
|
|
33
21
|
|
|
34
|
-
Parameters
|
|
35
|
-
----------
|
|
36
|
-
local : bool, default False
|
|
37
|
-
Whether to create a local client or not.
|
|
38
|
-
config : dict, optional
|
|
39
|
-
DHCore environment configuration.
|
|
40
|
-
|
|
41
22
|
Returns
|
|
42
23
|
-------
|
|
43
|
-
|
|
24
|
+
Client
|
|
44
25
|
Returns the client instance.
|
|
45
26
|
"""
|
|
46
|
-
if
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return self._local
|
|
50
|
-
|
|
51
|
-
if self._dhcore is None:
|
|
52
|
-
self._dhcore = ClientDHCore(config)
|
|
53
|
-
return self._dhcore
|
|
27
|
+
if self._client is None:
|
|
28
|
+
self._client = Client()
|
|
29
|
+
return self._client
|
|
54
30
|
|
|
55
31
|
|
|
56
32
|
client_builder = ClientBuilder()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_client() -> Client:
|
|
36
|
+
"""
|
|
37
|
+
Wrapper around ClientBuilder.build.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
Client
|
|
42
|
+
The client instance.
|
|
43
|
+
"""
|
|
44
|
+
return client_builder.build()
|