digitalhub 0.8.0b7__py3-none-any.whl → 0.8.0b11__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.
- digitalhub/__init__.py +1 -1
- digitalhub/client/api.py +63 -0
- digitalhub/client/builder.py +0 -55
- digitalhub/client/dhcore/client.py +39 -11
- digitalhub/client/dhcore/utils.py +1 -1
- digitalhub/client/local/client.py +1 -1
- digitalhub/context/api.py +93 -0
- digitalhub/context/builder.py +0 -84
- digitalhub/datastores/_base/datastore.py +2 -2
- digitalhub/datastores/api.py +37 -0
- digitalhub/datastores/builder.py +7 -31
- digitalhub/datastores/local/datastore.py +9 -1
- digitalhub/datastores/remote/datastore.py +8 -0
- digitalhub/datastores/s3/datastore.py +9 -1
- digitalhub/datastores/sql/datastore.py +9 -1
- digitalhub/entities/_base/api_utils.py +620 -0
- digitalhub/entities/_base/context/entity.py +2 -2
- digitalhub/entities/_base/crud.py +204 -408
- digitalhub/entities/_base/entity/entity.py +1 -1
- digitalhub/entities/_base/executable/entity.py +7 -6
- digitalhub/entities/_base/material/entity.py +2 -2
- digitalhub/entities/_base/runtime_entity/builder.py +11 -0
- digitalhub/entities/artifact/_base/builder.py +1 -1
- digitalhub/entities/artifact/crud.py +17 -43
- digitalhub/entities/dataitem/_base/builder.py +1 -1
- digitalhub/entities/dataitem/crud.py +20 -46
- digitalhub/entities/dataitem/table/entity.py +1 -1
- digitalhub/entities/function/_base/builder.py +1 -1
- digitalhub/entities/function/crud.py +14 -40
- digitalhub/entities/model/_base/builder.py +1 -1
- digitalhub/entities/model/crud.py +16 -43
- digitalhub/entities/project/_base/entity.py +71 -44
- digitalhub/entities/project/crud.py +8 -8
- digitalhub/entities/run/_base/builder.py +21 -1
- digitalhub/entities/run/_base/entity.py +1 -1
- digitalhub/entities/run/crud.py +17 -30
- digitalhub/entities/secret/_base/entity.py +1 -1
- digitalhub/entities/secret/crud.py +16 -28
- digitalhub/entities/task/_base/builder.py +22 -1
- digitalhub/entities/task/_base/entity.py +3 -2
- digitalhub/entities/task/crud.py +17 -30
- digitalhub/entities/workflow/_base/builder.py +1 -1
- digitalhub/entities/workflow/crud.py +14 -40
- digitalhub/factory/api.py +31 -25
- digitalhub/factory/factory.py +7 -5
- digitalhub/readers/_base/builder.py +26 -0
- digitalhub/readers/api.py +80 -0
- digitalhub/readers/factory.py +133 -0
- digitalhub/readers/pandas/builder.py +29 -0
- digitalhub/readers/pandas/{readers.py → reader.py} +1 -1
- digitalhub/stores/api.py +54 -0
- digitalhub/stores/builder.py +0 -46
- digitalhub/utils/io_utils.py +38 -2
- {digitalhub-0.8.0b7.dist-info → digitalhub-0.8.0b11.dist-info}/METADATA +1 -1
- {digitalhub-0.8.0b7.dist-info → digitalhub-0.8.0b11.dist-info}/RECORD +59 -61
- digitalhub/entities/artifact/builder.py +0 -51
- digitalhub/entities/dataitem/builder.py +0 -51
- digitalhub/entities/function/builder.py +0 -51
- digitalhub/entities/model/builder.py +0 -51
- digitalhub/entities/project/builder.py +0 -51
- digitalhub/entities/run/builder.py +0 -51
- digitalhub/entities/secret/builder.py +0 -51
- digitalhub/entities/task/builder.py +0 -51
- digitalhub/entities/workflow/builder.py +0 -51
- digitalhub/readers/builder.py +0 -54
- digitalhub/readers/registry.py +0 -15
- /digitalhub/readers/_base/{readers.py → reader.py} +0 -0
- {digitalhub-0.8.0b7.dist-info → digitalhub-0.8.0b11.dist-info}/LICENSE.txt +0 -0
- {digitalhub-0.8.0b7.dist-info → digitalhub-0.8.0b11.dist-info}/WHEEL +0 -0
- {digitalhub-0.8.0b7.dist-info → digitalhub-0.8.0b11.dist-info}/top_level.txt +0 -0
|
@@ -2,215 +2,138 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
|
-
from digitalhub.context.
|
|
6
|
-
from digitalhub.entities.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
api_base_update,
|
|
12
|
-
api_ctx_create,
|
|
13
|
-
api_ctx_data,
|
|
14
|
-
api_ctx_delete,
|
|
15
|
-
api_ctx_files,
|
|
16
|
-
api_ctx_list,
|
|
17
|
-
api_ctx_logs,
|
|
18
|
-
api_ctx_read,
|
|
19
|
-
api_ctx_resume,
|
|
20
|
-
api_ctx_stop,
|
|
21
|
-
api_ctx_update,
|
|
5
|
+
from digitalhub.context.api import check_context
|
|
6
|
+
from digitalhub.entities._base.api_utils import (
|
|
7
|
+
delete_entity_api_ctx,
|
|
8
|
+
list_entity_api_ctx,
|
|
9
|
+
read_entity_api_ctx,
|
|
10
|
+
read_entity_api_ctx_versions,
|
|
22
11
|
)
|
|
23
|
-
from digitalhub.
|
|
12
|
+
from digitalhub.factory.api import build_entity_from_dict, build_entity_from_params
|
|
13
|
+
from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityError
|
|
14
|
+
from digitalhub.utils.io_utils import read_yaml
|
|
24
15
|
|
|
25
16
|
if typing.TYPE_CHECKING:
|
|
26
|
-
from digitalhub.
|
|
17
|
+
from digitalhub.entities._base.context.entity import ContextEntity
|
|
18
|
+
from digitalhub.entities._base.executable.entity import ExecutableEntity
|
|
19
|
+
from digitalhub.entities._base.material.entity import MaterialEntity
|
|
20
|
+
from digitalhub.entities._base.unversioned.entity import UnversionedEntity
|
|
21
|
+
from digitalhub.entities._base.versioned.entity import VersionedEntity
|
|
27
22
|
|
|
28
23
|
|
|
29
|
-
def
|
|
30
|
-
client: Client,
|
|
31
|
-
entity_type: str,
|
|
32
|
-
entity_dict: dict,
|
|
33
|
-
**kwargs,
|
|
34
|
-
) -> dict:
|
|
24
|
+
def new_context_entity(**kwargs) -> ContextEntity:
|
|
35
25
|
"""
|
|
36
|
-
Create
|
|
26
|
+
Create a new object.
|
|
37
27
|
|
|
38
28
|
Parameters
|
|
39
29
|
----------
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Object instance.
|
|
53
|
-
"""
|
|
54
|
-
api = api_base_create(entity_type)
|
|
55
|
-
return client.create_object(api, entity_dict, **kwargs)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def read_entity_api_base(
|
|
59
|
-
client: Client,
|
|
60
|
-
entity_type: str,
|
|
61
|
-
entity_name: str,
|
|
62
|
-
**kwargs,
|
|
63
|
-
) -> dict:
|
|
64
|
-
"""
|
|
65
|
-
Read object from backend.
|
|
66
|
-
|
|
67
|
-
Parameters
|
|
68
|
-
----------
|
|
69
|
-
client : Client
|
|
70
|
-
Client instance.
|
|
71
|
-
entity_type : str
|
|
72
|
-
Entity type.
|
|
73
|
-
entity_name : str
|
|
74
|
-
Entity name.
|
|
75
|
-
**kwargs : dict
|
|
76
|
-
Parameters to pass to the API call.
|
|
30
|
+
project : str
|
|
31
|
+
Project name.
|
|
32
|
+
kind : str
|
|
33
|
+
Kind the object.
|
|
34
|
+
uuid : str
|
|
35
|
+
ID of the object.
|
|
36
|
+
description : str
|
|
37
|
+
Description of the object (human readable).
|
|
38
|
+
labels : list[str]
|
|
39
|
+
List of labels.
|
|
40
|
+
embedded : bool
|
|
41
|
+
Flag to determine if object spec must be embedded in project spec.
|
|
77
42
|
|
|
78
43
|
Returns
|
|
79
44
|
-------
|
|
80
|
-
|
|
45
|
+
ContextEntity
|
|
81
46
|
Object instance.
|
|
82
47
|
"""
|
|
83
|
-
|
|
84
|
-
|
|
48
|
+
check_context(kwargs["project"])
|
|
49
|
+
obj = build_entity_from_params(**kwargs)
|
|
50
|
+
obj.save()
|
|
51
|
+
return obj
|
|
85
52
|
|
|
86
53
|
|
|
87
|
-
def
|
|
88
|
-
|
|
89
|
-
entity_type: str,
|
|
90
|
-
|
|
91
|
-
|
|
54
|
+
def get_versioned_entity(
|
|
55
|
+
identifier: str,
|
|
56
|
+
entity_type: str | None = None,
|
|
57
|
+
project: str | None = None,
|
|
58
|
+
entity_id: str | None = None,
|
|
92
59
|
**kwargs,
|
|
93
|
-
) ->
|
|
60
|
+
) -> VersionedEntity:
|
|
94
61
|
"""
|
|
95
|
-
|
|
62
|
+
Get object from backend.
|
|
96
63
|
|
|
97
64
|
Parameters
|
|
98
65
|
----------
|
|
99
|
-
|
|
100
|
-
|
|
66
|
+
identifier : str
|
|
67
|
+
Entity key (store://...) or entity name.
|
|
101
68
|
entity_type : str
|
|
102
69
|
Entity type.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
70
|
+
project : str
|
|
71
|
+
Project name.
|
|
72
|
+
entity_id : str
|
|
73
|
+
Entity ID.
|
|
107
74
|
**kwargs : dict
|
|
108
75
|
Parameters to pass to the API call.
|
|
109
76
|
|
|
110
77
|
Returns
|
|
111
78
|
-------
|
|
112
|
-
|
|
79
|
+
VersionedEntity
|
|
113
80
|
Object instance.
|
|
114
81
|
"""
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
**kwargs,
|
|
124
|
-
) -> dict:
|
|
125
|
-
"""
|
|
126
|
-
Delete object from backend.
|
|
82
|
+
obj = read_entity_api_ctx(
|
|
83
|
+
identifier,
|
|
84
|
+
entity_type=entity_type,
|
|
85
|
+
project=project,
|
|
86
|
+
entity_id=entity_id,
|
|
87
|
+
**kwargs,
|
|
88
|
+
)
|
|
89
|
+
return build_entity_from_dict(obj)
|
|
127
90
|
|
|
128
|
-
Parameters
|
|
129
|
-
----------
|
|
130
|
-
client : Client
|
|
131
|
-
Client instance.
|
|
132
|
-
entity_type : str
|
|
133
|
-
Entity type.
|
|
134
|
-
entity_name : str
|
|
135
|
-
Entity name.
|
|
136
|
-
**kwargs : dict
|
|
137
|
-
Parameters to pass to the API call.
|
|
138
91
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
"""
|
|
144
|
-
if "params" not in kwargs:
|
|
145
|
-
kwargs["params"] = {}
|
|
146
|
-
if "cascade" in kwargs["params"]:
|
|
147
|
-
kwargs["params"]["cascade"] = str(kwargs["cascade"]).lower()
|
|
148
|
-
if "cascade" in kwargs:
|
|
149
|
-
kwargs["params"]["cascade"] = str(kwargs.pop("cascade")).lower()
|
|
150
|
-
api = api_base_delete(entity_type, entity_name)
|
|
151
|
-
return client.delete_object(api, **kwargs)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
def list_entity_api_base(
|
|
155
|
-
client: Client,
|
|
156
|
-
entity_type: str,
|
|
92
|
+
def get_unversioned_entity(
|
|
93
|
+
identifier: str,
|
|
94
|
+
entity_type: str | None = None,
|
|
95
|
+
project: str | None = None,
|
|
157
96
|
**kwargs,
|
|
158
|
-
) ->
|
|
97
|
+
) -> UnversionedEntity:
|
|
159
98
|
"""
|
|
160
|
-
|
|
99
|
+
Get object from backend.
|
|
161
100
|
|
|
162
101
|
Parameters
|
|
163
102
|
----------
|
|
164
103
|
entity_type : str
|
|
165
104
|
Entity type.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
Returns
|
|
170
|
-
-------
|
|
171
|
-
list[dict]
|
|
172
|
-
List of objects.
|
|
173
|
-
"""
|
|
174
|
-
api = api_base_list(entity_type)
|
|
175
|
-
return client.list_objects(api, **kwargs)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
def create_entity_api_ctx(
|
|
179
|
-
project: str,
|
|
180
|
-
entity_type: str,
|
|
181
|
-
entity_dict: dict,
|
|
182
|
-
**kwargs,
|
|
183
|
-
) -> dict:
|
|
184
|
-
"""
|
|
185
|
-
Create object in backend.
|
|
186
|
-
|
|
187
|
-
Parameters
|
|
188
|
-
----------
|
|
105
|
+
identifier : str
|
|
106
|
+
Entity key (store://...) or entity name.
|
|
189
107
|
project : str
|
|
190
108
|
Project name.
|
|
191
|
-
|
|
192
|
-
Entity
|
|
193
|
-
entity_dict : dict
|
|
194
|
-
Object instance.
|
|
109
|
+
entity_id : str
|
|
110
|
+
Entity ID.
|
|
195
111
|
**kwargs : dict
|
|
196
112
|
Parameters to pass to the API call.
|
|
197
113
|
|
|
198
114
|
Returns
|
|
199
115
|
-------
|
|
200
|
-
|
|
116
|
+
UnversionedEntity
|
|
201
117
|
Object instance.
|
|
202
118
|
"""
|
|
203
|
-
|
|
204
|
-
|
|
119
|
+
if not identifier.startswith("store://") and project is None:
|
|
120
|
+
raise EntityError("Specify entity key or entity ID combined with project")
|
|
121
|
+
obj = read_entity_api_ctx(
|
|
122
|
+
identifier,
|
|
123
|
+
entity_type=entity_type,
|
|
124
|
+
project=project,
|
|
125
|
+
**kwargs,
|
|
126
|
+
)
|
|
127
|
+
return build_entity_from_dict(obj)
|
|
205
128
|
|
|
206
129
|
|
|
207
|
-
def
|
|
130
|
+
def get_material_entity(
|
|
208
131
|
identifier: str,
|
|
209
132
|
entity_type: str | None = None,
|
|
210
133
|
project: str | None = None,
|
|
211
134
|
entity_id: str | None = None,
|
|
212
135
|
**kwargs,
|
|
213
|
-
) ->
|
|
136
|
+
) -> MaterialEntity:
|
|
214
137
|
"""
|
|
215
138
|
Get object from backend.
|
|
216
139
|
|
|
@@ -229,38 +152,28 @@ def read_entity_api_ctx(
|
|
|
229
152
|
|
|
230
153
|
Returns
|
|
231
154
|
-------
|
|
232
|
-
|
|
155
|
+
MaterialEntity
|
|
233
156
|
Object instance.
|
|
234
157
|
"""
|
|
158
|
+
obj: MaterialEntity = get_versioned_entity(
|
|
159
|
+
identifier,
|
|
160
|
+
entity_type=entity_type,
|
|
161
|
+
project=project,
|
|
162
|
+
entity_id=entity_id,
|
|
163
|
+
**kwargs,
|
|
164
|
+
)
|
|
165
|
+
obj._get_files_info()
|
|
166
|
+
return obj
|
|
235
167
|
|
|
236
|
-
if identifier.startswith("store://"):
|
|
237
|
-
project, entity_type, _, _, entity_id = parse_entity_key(identifier)
|
|
238
|
-
api = api_ctx_read(project, entity_type, entity_id)
|
|
239
|
-
return get_context(project).read_object(api, **kwargs)
|
|
240
|
-
|
|
241
|
-
if project is None or entity_type is None:
|
|
242
|
-
raise ValueError("Project and entity type must be specified.")
|
|
243
|
-
|
|
244
|
-
if "params" not in kwargs:
|
|
245
|
-
kwargs["params"] = {}
|
|
246
168
|
|
|
247
|
-
|
|
248
|
-
kwargs["params"]["name"] = identifier
|
|
249
|
-
api = api_ctx_list(project, entity_type)
|
|
250
|
-
return get_context(project).list_first_object(api, **kwargs)
|
|
251
|
-
|
|
252
|
-
api = api_ctx_read(project, entity_type, entity_id)
|
|
253
|
-
return get_context(project).read_object(api, **kwargs)
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
def read_entity_api_ctx_versions(
|
|
169
|
+
def get_context_entity_versions(
|
|
257
170
|
identifier: str,
|
|
258
171
|
entity_type: str | None = None,
|
|
259
172
|
project: str | None = None,
|
|
260
173
|
**kwargs,
|
|
261
|
-
) -> list[
|
|
174
|
+
) -> list[ContextEntity]:
|
|
262
175
|
"""
|
|
263
|
-
Get
|
|
176
|
+
Get object versions from backend.
|
|
264
177
|
|
|
265
178
|
Parameters
|
|
266
179
|
----------
|
|
@@ -275,66 +188,26 @@ def read_entity_api_ctx_versions(
|
|
|
275
188
|
|
|
276
189
|
Returns
|
|
277
190
|
-------
|
|
278
|
-
list[
|
|
279
|
-
|
|
280
|
-
"""
|
|
281
|
-
if not identifier.startswith("store://"):
|
|
282
|
-
if project is None or entity_type is None:
|
|
283
|
-
raise ValueError("Project and entity type must be specified.")
|
|
284
|
-
entity_name = identifier
|
|
285
|
-
else:
|
|
286
|
-
project, entity_type, _, entity_name, _ = parse_entity_key(identifier)
|
|
287
|
-
|
|
288
|
-
if "params" not in kwargs:
|
|
289
|
-
kwargs["params"] = {}
|
|
290
|
-
kwargs["params"]["name"] = entity_name
|
|
291
|
-
kwargs["params"]["versions"] = "all"
|
|
292
|
-
|
|
293
|
-
api = api_ctx_list(project, entity_type)
|
|
294
|
-
return get_context(project).list_objects(api, **kwargs)
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
def update_entity_api_ctx(
|
|
298
|
-
project: str,
|
|
299
|
-
entity_type: str,
|
|
300
|
-
entity_id: str,
|
|
301
|
-
entity_dict: dict,
|
|
302
|
-
**kwargs,
|
|
303
|
-
) -> dict:
|
|
191
|
+
list[ContextEntity]
|
|
192
|
+
List of object instances.
|
|
304
193
|
"""
|
|
305
|
-
|
|
194
|
+
obj = read_entity_api_ctx_versions(
|
|
195
|
+
identifier,
|
|
196
|
+
entity_type=entity_type,
|
|
197
|
+
project=project,
|
|
198
|
+
**kwargs,
|
|
199
|
+
)
|
|
200
|
+
return [build_entity_from_dict(o) for o in obj]
|
|
306
201
|
|
|
307
|
-
Parameters
|
|
308
|
-
----------
|
|
309
|
-
project : str
|
|
310
|
-
Project name.
|
|
311
|
-
entity_type : str
|
|
312
|
-
Entity type.
|
|
313
|
-
entity_id : str
|
|
314
|
-
Entity ID.
|
|
315
|
-
entity_dict : dict
|
|
316
|
-
Entity dictionary.
|
|
317
|
-
**kwargs : dict
|
|
318
|
-
Parameters to pass to the API call.
|
|
319
202
|
|
|
320
|
-
|
|
321
|
-
-------
|
|
322
|
-
dict
|
|
323
|
-
Response from backend.
|
|
324
|
-
"""
|
|
325
|
-
api = api_ctx_update(project, entity_type, entity_id=entity_id)
|
|
326
|
-
return get_context(project).update_object(api, entity_dict, **kwargs)
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
def delete_entity_api_ctx(
|
|
203
|
+
def get_material_entity_versions(
|
|
330
204
|
identifier: str,
|
|
331
|
-
entity_type: str,
|
|
205
|
+
entity_type: str | None = None,
|
|
332
206
|
project: str | None = None,
|
|
333
|
-
entity_id: str | None = None,
|
|
334
207
|
**kwargs,
|
|
335
|
-
) ->
|
|
208
|
+
) -> list[MaterialEntity]:
|
|
336
209
|
"""
|
|
337
|
-
|
|
210
|
+
Get object versions from backend.
|
|
338
211
|
|
|
339
212
|
Parameters
|
|
340
213
|
----------
|
|
@@ -344,54 +217,31 @@ def delete_entity_api_ctx(
|
|
|
344
217
|
Entity type.
|
|
345
218
|
project : str
|
|
346
219
|
Project name.
|
|
347
|
-
entity_id : str
|
|
348
|
-
Entity ID.
|
|
349
220
|
**kwargs : dict
|
|
350
221
|
Parameters to pass to the API call.
|
|
351
222
|
|
|
352
223
|
Returns
|
|
353
224
|
-------
|
|
354
|
-
|
|
355
|
-
|
|
225
|
+
list[MaterialEntity]
|
|
226
|
+
List of object instances.
|
|
356
227
|
"""
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
228
|
+
objs = read_entity_api_ctx_versions(
|
|
229
|
+
identifier,
|
|
230
|
+
entity_type=entity_type,
|
|
231
|
+
project=project,
|
|
232
|
+
**kwargs,
|
|
233
|
+
)
|
|
234
|
+
objects = []
|
|
235
|
+
for o in objs:
|
|
236
|
+
entity: MaterialEntity = build_entity_from_dict(o)
|
|
237
|
+
entity._get_files_info()
|
|
238
|
+
objects.append(entity)
|
|
239
|
+
return objects
|
|
365
240
|
|
|
366
|
-
if identifier.startswith("store://"):
|
|
367
|
-
project, _, _, _, entity_id = parse_entity_key(identifier)
|
|
368
|
-
api = api_ctx_delete(project, entity_type, entity_id)
|
|
369
|
-
return get_context(project).delete_object(api, **kwargs)
|
|
370
241
|
|
|
371
|
-
|
|
372
|
-
raise ValueError("Project must be provided.")
|
|
373
|
-
|
|
374
|
-
if entity_id is not None:
|
|
375
|
-
api = api_ctx_delete(project, entity_type, entity_id)
|
|
376
|
-
else:
|
|
377
|
-
kwargs["params"]["name"] = identifier
|
|
378
|
-
api = api_ctx_list(project, entity_type)
|
|
379
|
-
if delete_all_versions:
|
|
380
|
-
return get_context(project).delete_object(api, **kwargs)
|
|
381
|
-
obj = get_context(project).list_first_object(api, **kwargs)
|
|
382
|
-
entity_id = obj["id"]
|
|
383
|
-
|
|
384
|
-
api = api_ctx_delete(project, entity_type, entity_id)
|
|
385
|
-
return get_context(project).delete_object(api, **kwargs)
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
def list_entity_api_ctx(
|
|
389
|
-
project: str,
|
|
390
|
-
entity_type: str,
|
|
391
|
-
**kwargs,
|
|
392
|
-
) -> list[dict]:
|
|
242
|
+
def list_context_entities(project: str, entity_type: str, **kwargs) -> list[ContextEntity]:
|
|
393
243
|
"""
|
|
394
|
-
List objects from backend.
|
|
244
|
+
List all latest version objects from backend.
|
|
395
245
|
|
|
396
246
|
Parameters
|
|
397
247
|
----------
|
|
@@ -404,21 +254,24 @@ def list_entity_api_ctx(
|
|
|
404
254
|
|
|
405
255
|
Returns
|
|
406
256
|
-------
|
|
407
|
-
list[
|
|
408
|
-
List of
|
|
257
|
+
list[ContextEntity]
|
|
258
|
+
List of object instances.
|
|
409
259
|
"""
|
|
410
|
-
|
|
411
|
-
|
|
260
|
+
objs = list_entity_api_ctx(
|
|
261
|
+
project=project,
|
|
262
|
+
entity_type=entity_type,
|
|
263
|
+
**kwargs,
|
|
264
|
+
)
|
|
265
|
+
return [build_entity_from_dict(obj) for obj in objs]
|
|
412
266
|
|
|
413
267
|
|
|
414
|
-
def
|
|
268
|
+
def list_material_entities(
|
|
415
269
|
project: str,
|
|
416
270
|
entity_type: str,
|
|
417
|
-
data: dict,
|
|
418
271
|
**kwargs,
|
|
419
|
-
) ->
|
|
272
|
+
) -> list[MaterialEntity]:
|
|
420
273
|
"""
|
|
421
|
-
|
|
274
|
+
List all latest version objects from backend.
|
|
422
275
|
|
|
423
276
|
Parameters
|
|
424
277
|
----------
|
|
@@ -426,185 +279,128 @@ def set_data_api(
|
|
|
426
279
|
Project name.
|
|
427
280
|
entity_type : str
|
|
428
281
|
Entity type.
|
|
429
|
-
data : dict
|
|
430
|
-
Data dictionary.
|
|
431
282
|
**kwargs : dict
|
|
432
283
|
Parameters to pass to the API call.
|
|
433
284
|
|
|
434
285
|
Returns
|
|
435
286
|
-------
|
|
436
|
-
|
|
287
|
+
list[MaterialEntity]
|
|
288
|
+
List of object instances.
|
|
437
289
|
"""
|
|
438
|
-
|
|
439
|
-
|
|
290
|
+
objs = list_entity_api_ctx(
|
|
291
|
+
project=project,
|
|
292
|
+
entity_type=entity_type,
|
|
293
|
+
**kwargs,
|
|
294
|
+
)
|
|
295
|
+
objects = []
|
|
296
|
+
for o in objs:
|
|
297
|
+
entity: MaterialEntity = build_entity_from_dict(o)
|
|
298
|
+
entity._get_files_info()
|
|
299
|
+
objects.append(entity)
|
|
300
|
+
return objects
|
|
440
301
|
|
|
441
302
|
|
|
442
|
-
def
|
|
443
|
-
project: str,
|
|
444
|
-
entity_type: str,
|
|
445
|
-
**kwargs,
|
|
446
|
-
) -> dict:
|
|
303
|
+
def import_context_entity(file: str) -> ContextEntity:
|
|
447
304
|
"""
|
|
448
|
-
|
|
305
|
+
Get object from file.
|
|
449
306
|
|
|
450
307
|
Parameters
|
|
451
308
|
----------
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
entity_type : str
|
|
455
|
-
Entity type.
|
|
456
|
-
**kwargs : dict
|
|
457
|
-
Parameters to pass to the API call.
|
|
309
|
+
file : str
|
|
310
|
+
Path to YAML file.
|
|
458
311
|
|
|
459
312
|
Returns
|
|
460
313
|
-------
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
"""
|
|
464
|
-
api = api_ctx_data(project, entity_type)
|
|
465
|
-
return get_context(project).read_object(api, **kwargs)
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
def logs_api(
|
|
469
|
-
project: str,
|
|
470
|
-
entity_type: str,
|
|
471
|
-
entity_id: str,
|
|
472
|
-
**kwargs,
|
|
473
|
-
) -> dict:
|
|
314
|
+
ContextEntity
|
|
315
|
+
Object instance.
|
|
474
316
|
"""
|
|
475
|
-
|
|
317
|
+
dict_obj: dict = read_yaml(file)
|
|
476
318
|
|
|
477
|
-
|
|
478
|
-
----------
|
|
479
|
-
project : str
|
|
480
|
-
Project name.
|
|
481
|
-
entity_type : str
|
|
482
|
-
Entity type.
|
|
483
|
-
entity_id : str
|
|
484
|
-
Entity ID.
|
|
485
|
-
**kwargs : dict
|
|
486
|
-
Parameters to pass to the API call.
|
|
319
|
+
check_context(dict_obj["project"])
|
|
487
320
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
return get_context(project).read_object(api, **kwargs)
|
|
321
|
+
obj = build_entity_from_dict(dict_obj)
|
|
322
|
+
try:
|
|
323
|
+
obj.save()
|
|
324
|
+
except EntityAlreadyExistsError:
|
|
325
|
+
pass
|
|
326
|
+
return obj
|
|
495
327
|
|
|
496
328
|
|
|
497
|
-
def
|
|
498
|
-
project: str,
|
|
499
|
-
entity_type: str,
|
|
500
|
-
entity_id: str,
|
|
501
|
-
**kwargs,
|
|
502
|
-
) -> None:
|
|
329
|
+
def import_executable_entity(file: str) -> ExecutableEntity:
|
|
503
330
|
"""
|
|
504
|
-
|
|
331
|
+
Get object from file.
|
|
505
332
|
|
|
506
333
|
Parameters
|
|
507
334
|
----------
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
entity_type : str
|
|
511
|
-
Entity type.
|
|
512
|
-
entity_id : str
|
|
513
|
-
Entity ID.
|
|
514
|
-
**kwargs : dict
|
|
515
|
-
Parameters to pass to the API call.
|
|
335
|
+
file : str
|
|
336
|
+
Path to YAML file.
|
|
516
337
|
|
|
517
338
|
Returns
|
|
518
339
|
-------
|
|
519
|
-
|
|
340
|
+
ExecutableEntity
|
|
341
|
+
Object instance.
|
|
520
342
|
"""
|
|
521
|
-
|
|
522
|
-
|
|
343
|
+
dict_obj: dict | list[dict] = read_yaml(file)
|
|
344
|
+
if isinstance(dict_obj, list):
|
|
345
|
+
exec_dict = dict_obj[0]
|
|
346
|
+
tsk_dicts = dict_obj[1:]
|
|
347
|
+
else:
|
|
348
|
+
exec_dict = dict_obj
|
|
349
|
+
tsk_dicts = []
|
|
523
350
|
|
|
351
|
+
check_context(exec_dict["project"])
|
|
524
352
|
|
|
525
|
-
|
|
526
|
-
project: str,
|
|
527
|
-
entity_type: str,
|
|
528
|
-
entity_id: str,
|
|
529
|
-
**kwargs,
|
|
530
|
-
) -> None:
|
|
531
|
-
"""
|
|
532
|
-
Resume object in backend.
|
|
353
|
+
obj: ExecutableEntity = build_entity_from_dict(exec_dict)
|
|
533
354
|
|
|
534
|
-
|
|
535
|
-
----------
|
|
536
|
-
project : str
|
|
537
|
-
Project name.
|
|
538
|
-
entity_type : str
|
|
539
|
-
Entity type.
|
|
540
|
-
entity_id : str
|
|
541
|
-
Entity ID.
|
|
542
|
-
**kwargs : dict
|
|
543
|
-
Parameters to pass to the API call.
|
|
355
|
+
obj.import_tasks(tsk_dicts)
|
|
544
356
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
get_context(project).create_object(api, obj={}, **kwargs)
|
|
357
|
+
try:
|
|
358
|
+
obj.save()
|
|
359
|
+
except EntityAlreadyExistsError:
|
|
360
|
+
pass
|
|
361
|
+
return obj
|
|
551
362
|
|
|
552
363
|
|
|
553
|
-
def
|
|
554
|
-
|
|
555
|
-
entity_type: str,
|
|
556
|
-
|
|
364
|
+
def delete_entity(
|
|
365
|
+
identifier: str,
|
|
366
|
+
entity_type: str | None = None,
|
|
367
|
+
project: str | None = None,
|
|
368
|
+
entity_id: str | None = None,
|
|
369
|
+
delete_all_versions: bool = False,
|
|
370
|
+
cascade: bool = True,
|
|
557
371
|
**kwargs,
|
|
558
|
-
) ->
|
|
372
|
+
) -> dict:
|
|
559
373
|
"""
|
|
560
|
-
|
|
374
|
+
Delete object from backend.
|
|
561
375
|
|
|
562
376
|
Parameters
|
|
563
377
|
----------
|
|
564
|
-
|
|
565
|
-
|
|
378
|
+
identifier : str
|
|
379
|
+
Entity key (store://...) or entity name.
|
|
566
380
|
entity_type : str
|
|
567
381
|
Entity type.
|
|
568
|
-
entity_id : str
|
|
569
|
-
Entity ID.
|
|
570
|
-
**kwargs : dict
|
|
571
|
-
Parameters to pass to the API call.
|
|
572
|
-
|
|
573
|
-
Returns
|
|
574
|
-
-------
|
|
575
|
-
list[dict]
|
|
576
|
-
Response from backend.
|
|
577
|
-
"""
|
|
578
|
-
api = api_ctx_files(project, entity_type, entity_id)
|
|
579
|
-
return get_context(project).read_object(api, **kwargs)
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
def files_info_put_api(
|
|
583
|
-
project: str,
|
|
584
|
-
entity_type: str,
|
|
585
|
-
entity_id: str,
|
|
586
|
-
entity_list: list[dict],
|
|
587
|
-
**kwargs,
|
|
588
|
-
) -> None:
|
|
589
|
-
"""
|
|
590
|
-
Get files info from backend.
|
|
591
|
-
|
|
592
|
-
Parameters
|
|
593
|
-
----------
|
|
594
382
|
project : str
|
|
595
383
|
Project name.
|
|
596
|
-
entity_type : str
|
|
597
|
-
Entity type.
|
|
598
384
|
entity_id : str
|
|
599
385
|
Entity ID.
|
|
600
|
-
|
|
601
|
-
|
|
386
|
+
delete_all_versions : bool
|
|
387
|
+
Delete all versions of the named entity. If True, use entity name instead of entity key as identifier.
|
|
388
|
+
cascade : bool
|
|
389
|
+
Cascade delete.
|
|
602
390
|
**kwargs : dict
|
|
603
391
|
Parameters to pass to the API call.
|
|
604
392
|
|
|
605
393
|
Returns
|
|
606
394
|
-------
|
|
607
|
-
|
|
395
|
+
dict
|
|
396
|
+
Response from backend.
|
|
608
397
|
"""
|
|
609
|
-
|
|
610
|
-
|
|
398
|
+
return delete_entity_api_ctx(
|
|
399
|
+
identifier=identifier,
|
|
400
|
+
entity_type=entity_type,
|
|
401
|
+
project=project,
|
|
402
|
+
entity_id=entity_id,
|
|
403
|
+
delete_all_versions=delete_all_versions,
|
|
404
|
+
cascade=cascade,
|
|
405
|
+
**kwargs,
|
|
406
|
+
)
|