digitalhub 0.14.0b2__py3-none-any.whl → 0.14.0b3__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/context/builder.py +0 -4
- digitalhub/context/context.py +12 -8
- digitalhub/entities/_base/_base/entity.py +0 -4
- digitalhub/entities/_base/context/entity.py +1 -1
- digitalhub/entities/_base/entity/entity.py +0 -8
- digitalhub/entities/_base/executable/entity.py +5 -25
- digitalhub/entities/_base/material/entity.py +3 -23
- digitalhub/entities/_base/unversioned/entity.py +1 -1
- digitalhub/entities/_base/versioned/entity.py +1 -1
- digitalhub/entities/_processors/base/__init__.py +3 -0
- digitalhub/entities/_processors/{base.py → base/crud.py} +6 -226
- digitalhub/entities/_processors/base/import_export.py +122 -0
- digitalhub/entities/_processors/base/processor.py +302 -0
- digitalhub/entities/_processors/base/special_ops.py +108 -0
- digitalhub/entities/_processors/context/__init__.py +3 -0
- digitalhub/entities/_processors/context/crud.py +654 -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/artifact/crud.py +8 -24
- digitalhub/entities/dataitem/crud.py +8 -24
- digitalhub/entities/dataitem/table/entity.py +2 -6
- digitalhub/entities/function/crud.py +8 -24
- digitalhub/entities/model/_base/entity.py +3 -23
- digitalhub/entities/model/crud.py +8 -22
- digitalhub/entities/project/_base/entity.py +40 -129
- digitalhub/entities/project/crud.py +7 -22
- digitalhub/entities/run/_base/builder.py +0 -4
- digitalhub/entities/run/_base/entity.py +3 -59
- digitalhub/entities/run/crud.py +7 -19
- digitalhub/entities/secret/_base/entity.py +1 -5
- digitalhub/entities/secret/crud.py +8 -22
- digitalhub/entities/task/_base/builder.py +0 -4
- digitalhub/entities/task/_base/entity.py +1 -1
- digitalhub/entities/task/crud.py +7 -19
- digitalhub/entities/trigger/_base/entity.py +1 -5
- digitalhub/entities/trigger/crud.py +8 -24
- digitalhub/entities/workflow/crud.py +8 -24
- digitalhub/factory/registry.py +0 -24
- digitalhub/stores/client/dhcore/client.py +0 -18
- digitalhub/stores/client/dhcore/configurator.py +5 -28
- digitalhub/stores/client/dhcore/error_parser.py +0 -4
- digitalhub/stores/credentials/configurator.py +0 -24
- digitalhub/stores/credentials/handler.py +0 -12
- digitalhub/stores/credentials/store.py +0 -4
- digitalhub/stores/data/_base/store.py +0 -16
- digitalhub/stores/data/builder.py +0 -4
- digitalhub/stores/data/remote/store.py +0 -4
- digitalhub/stores/data/s3/configurator.py +0 -8
- digitalhub/stores/data/s3/store.py +0 -12
- digitalhub/stores/data/sql/configurator.py +0 -8
- digitalhub/stores/data/sql/store.py +0 -4
- digitalhub/stores/readers/data/factory.py +0 -8
- digitalhub/stores/readers/data/pandas/reader.py +0 -16
- digitalhub/utils/io_utils.py +0 -4
- {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b3.dist-info}/METADATA +1 -1
- {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b3.dist-info}/RECORD +62 -52
- digitalhub/entities/_processors/context.py +0 -1499
- {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b3.dist-info}/WHEEL +0 -0
- {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b3.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.14.0b2.dist-info → digitalhub-0.14.0b3.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import typing
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from digitalhub.entities._commons.enums import ApiCategories, BackendOperations
|
|
11
|
+
from digitalhub.entities._processors.utils import get_context_from_project
|
|
12
|
+
|
|
13
|
+
if typing.TYPE_CHECKING:
|
|
14
|
+
from digitalhub.entities._base.context.entity import ContextEntity
|
|
15
|
+
from digitalhub.entities._processors.context.crud import ContextEntityCRUDProcessor
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ContextEntitySpecialOpsProcessor:
|
|
19
|
+
"""
|
|
20
|
+
Processor for specialized context entity operations.
|
|
21
|
+
|
|
22
|
+
Handles backend operations like secrets management, logging,
|
|
23
|
+
entity control (start/stop/resume), file operations, and metrics.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def build_context_entity_key(
|
|
27
|
+
self,
|
|
28
|
+
project: str,
|
|
29
|
+
entity_type: str,
|
|
30
|
+
entity_kind: str,
|
|
31
|
+
entity_name: str,
|
|
32
|
+
entity_id: str | None = None,
|
|
33
|
+
) -> str:
|
|
34
|
+
"""
|
|
35
|
+
Build a storage key for a context entity.
|
|
36
|
+
|
|
37
|
+
Creates a standardized key string for context entity identification
|
|
38
|
+
and storage, resolving the project context automatically.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
project : str
|
|
43
|
+
The project name containing the entity.
|
|
44
|
+
entity_type : str
|
|
45
|
+
The type of entity.
|
|
46
|
+
entity_kind : str
|
|
47
|
+
The kind/subtype of entity.
|
|
48
|
+
entity_name : str
|
|
49
|
+
The name of the entity.
|
|
50
|
+
entity_id : str, optional
|
|
51
|
+
The unique identifier of the entity version.
|
|
52
|
+
|
|
53
|
+
Returns
|
|
54
|
+
-------
|
|
55
|
+
str
|
|
56
|
+
The constructed context entity key string.
|
|
57
|
+
"""
|
|
58
|
+
context = get_context_from_project(project)
|
|
59
|
+
return context.client.build_key(
|
|
60
|
+
ApiCategories.CONTEXT.value,
|
|
61
|
+
project=context.name,
|
|
62
|
+
entity_type=entity_type,
|
|
63
|
+
entity_kind=entity_kind,
|
|
64
|
+
entity_name=entity_name,
|
|
65
|
+
entity_id=entity_id,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
def read_secret_data(
|
|
69
|
+
self,
|
|
70
|
+
project: str,
|
|
71
|
+
entity_type: str,
|
|
72
|
+
**kwargs,
|
|
73
|
+
) -> dict:
|
|
74
|
+
"""
|
|
75
|
+
Read secret data from the backend.
|
|
76
|
+
|
|
77
|
+
Retrieves secret data stored in the backend for a specific
|
|
78
|
+
project and entity type.
|
|
79
|
+
|
|
80
|
+
Parameters
|
|
81
|
+
----------
|
|
82
|
+
project : str
|
|
83
|
+
The project name containing the secrets.
|
|
84
|
+
entity_type : str
|
|
85
|
+
The type of entity (typically 'secret').
|
|
86
|
+
**kwargs : dict
|
|
87
|
+
Additional parameters to pass to the API call.
|
|
88
|
+
|
|
89
|
+
Returns
|
|
90
|
+
-------
|
|
91
|
+
dict
|
|
92
|
+
Secret data retrieved from the backend.
|
|
93
|
+
"""
|
|
94
|
+
context = get_context_from_project(project)
|
|
95
|
+
api = context.client.build_api(
|
|
96
|
+
ApiCategories.CONTEXT.value,
|
|
97
|
+
BackendOperations.DATA.value,
|
|
98
|
+
project=context.name,
|
|
99
|
+
entity_type=entity_type,
|
|
100
|
+
)
|
|
101
|
+
return context.client.read_object(api, **kwargs)
|
|
102
|
+
|
|
103
|
+
def update_secret_data(
|
|
104
|
+
self,
|
|
105
|
+
project: str,
|
|
106
|
+
entity_type: str,
|
|
107
|
+
data: dict,
|
|
108
|
+
**kwargs,
|
|
109
|
+
) -> None:
|
|
110
|
+
"""
|
|
111
|
+
Update secret data in the backend.
|
|
112
|
+
|
|
113
|
+
Stores or updates secret data in the backend for a specific
|
|
114
|
+
project and entity type.
|
|
115
|
+
|
|
116
|
+
Parameters
|
|
117
|
+
----------
|
|
118
|
+
project : str
|
|
119
|
+
The project name to store secrets in.
|
|
120
|
+
entity_type : str
|
|
121
|
+
The type of entity (typically 'secret').
|
|
122
|
+
data : dict
|
|
123
|
+
The secret data dictionary to store.
|
|
124
|
+
**kwargs : dict
|
|
125
|
+
Additional parameters to pass to the API call.
|
|
126
|
+
"""
|
|
127
|
+
context = get_context_from_project(project)
|
|
128
|
+
api = context.client.build_api(
|
|
129
|
+
ApiCategories.CONTEXT.value,
|
|
130
|
+
BackendOperations.DATA.value,
|
|
131
|
+
project=context.name,
|
|
132
|
+
entity_type=entity_type,
|
|
133
|
+
)
|
|
134
|
+
context.client.update_object(api, data, **kwargs)
|
|
135
|
+
|
|
136
|
+
def read_run_logs(
|
|
137
|
+
self,
|
|
138
|
+
project: str,
|
|
139
|
+
entity_type: str,
|
|
140
|
+
entity_id: str,
|
|
141
|
+
**kwargs,
|
|
142
|
+
) -> dict:
|
|
143
|
+
"""
|
|
144
|
+
Read execution logs from the backend.
|
|
145
|
+
|
|
146
|
+
Retrieves logs for a specific run or task execution from
|
|
147
|
+
the backend.
|
|
148
|
+
|
|
149
|
+
Parameters
|
|
150
|
+
----------
|
|
151
|
+
project : str
|
|
152
|
+
The project name containing the entity.
|
|
153
|
+
entity_type : str
|
|
154
|
+
The type of entity (typically 'run' or 'task').
|
|
155
|
+
entity_id : str
|
|
156
|
+
The unique identifier of the entity to get logs for.
|
|
157
|
+
**kwargs : dict
|
|
158
|
+
Additional parameters to pass to the API call.
|
|
159
|
+
|
|
160
|
+
Returns
|
|
161
|
+
-------
|
|
162
|
+
dict
|
|
163
|
+
Log data retrieved from the backend.
|
|
164
|
+
"""
|
|
165
|
+
context = get_context_from_project(project)
|
|
166
|
+
api = context.client.build_api(
|
|
167
|
+
ApiCategories.CONTEXT.value,
|
|
168
|
+
BackendOperations.LOGS.value,
|
|
169
|
+
project=context.name,
|
|
170
|
+
entity_type=entity_type,
|
|
171
|
+
entity_id=entity_id,
|
|
172
|
+
)
|
|
173
|
+
return context.client.read_object(api, **kwargs)
|
|
174
|
+
|
|
175
|
+
def stop_entity(
|
|
176
|
+
self,
|
|
177
|
+
project: str,
|
|
178
|
+
entity_type: str,
|
|
179
|
+
entity_id: str,
|
|
180
|
+
**kwargs,
|
|
181
|
+
) -> None:
|
|
182
|
+
"""
|
|
183
|
+
Stop a running entity in the backend.
|
|
184
|
+
|
|
185
|
+
Sends a stop signal to halt execution of a running entity
|
|
186
|
+
such as a workflow or long-running task.
|
|
187
|
+
|
|
188
|
+
Parameters
|
|
189
|
+
----------
|
|
190
|
+
project : str
|
|
191
|
+
The project name containing the entity.
|
|
192
|
+
entity_type : str
|
|
193
|
+
The type of entity to stop.
|
|
194
|
+
entity_id : str
|
|
195
|
+
The unique identifier of the entity to stop.
|
|
196
|
+
**kwargs : dict
|
|
197
|
+
Additional parameters to pass to the API call.
|
|
198
|
+
"""
|
|
199
|
+
context = get_context_from_project(project)
|
|
200
|
+
api = context.client.build_api(
|
|
201
|
+
ApiCategories.CONTEXT.value,
|
|
202
|
+
BackendOperations.STOP.value,
|
|
203
|
+
project=context.name,
|
|
204
|
+
entity_type=entity_type,
|
|
205
|
+
entity_id=entity_id,
|
|
206
|
+
)
|
|
207
|
+
context.client.create_object(api, **kwargs)
|
|
208
|
+
|
|
209
|
+
def resume_entity(
|
|
210
|
+
self,
|
|
211
|
+
project: str,
|
|
212
|
+
entity_type: str,
|
|
213
|
+
entity_id: str,
|
|
214
|
+
**kwargs,
|
|
215
|
+
) -> None:
|
|
216
|
+
"""
|
|
217
|
+
Resume a stopped entity in the backend.
|
|
218
|
+
|
|
219
|
+
Sends a resume signal to restart execution of a previously
|
|
220
|
+
stopped entity such as a workflow or task.
|
|
221
|
+
|
|
222
|
+
Parameters
|
|
223
|
+
----------
|
|
224
|
+
project : str
|
|
225
|
+
The project name containing the entity.
|
|
226
|
+
entity_type : str
|
|
227
|
+
The type of entity to resume.
|
|
228
|
+
entity_id : str
|
|
229
|
+
The unique identifier of the entity to resume.
|
|
230
|
+
**kwargs : dict
|
|
231
|
+
Additional parameters to pass to the API call.
|
|
232
|
+
"""
|
|
233
|
+
context = get_context_from_project(project)
|
|
234
|
+
api = context.client.build_api(
|
|
235
|
+
ApiCategories.CONTEXT.value,
|
|
236
|
+
BackendOperations.RESUME.value,
|
|
237
|
+
project=context.name,
|
|
238
|
+
entity_type=entity_type,
|
|
239
|
+
entity_id=entity_id,
|
|
240
|
+
)
|
|
241
|
+
context.client.create_object(api, **kwargs)
|
|
242
|
+
|
|
243
|
+
def read_files_info(
|
|
244
|
+
self,
|
|
245
|
+
project: str,
|
|
246
|
+
entity_type: str,
|
|
247
|
+
entity_id: str,
|
|
248
|
+
**kwargs,
|
|
249
|
+
) -> list[dict]:
|
|
250
|
+
"""
|
|
251
|
+
Read file information from the backend.
|
|
252
|
+
|
|
253
|
+
Retrieves metadata about files associated with an entity,
|
|
254
|
+
including file paths, sizes, and other attributes.
|
|
255
|
+
|
|
256
|
+
Parameters
|
|
257
|
+
----------
|
|
258
|
+
project : str
|
|
259
|
+
The project name containing the entity.
|
|
260
|
+
entity_type : str
|
|
261
|
+
The type of entity to get file info for.
|
|
262
|
+
entity_id : str
|
|
263
|
+
The unique identifier of the entity.
|
|
264
|
+
**kwargs : dict
|
|
265
|
+
Additional parameters to pass to the API call.
|
|
266
|
+
|
|
267
|
+
Returns
|
|
268
|
+
-------
|
|
269
|
+
list[dict]
|
|
270
|
+
List of file information dictionaries from the backend.
|
|
271
|
+
"""
|
|
272
|
+
context = get_context_from_project(project)
|
|
273
|
+
api = context.client.build_api(
|
|
274
|
+
ApiCategories.CONTEXT.value,
|
|
275
|
+
BackendOperations.FILES.value,
|
|
276
|
+
project=context.name,
|
|
277
|
+
entity_type=entity_type,
|
|
278
|
+
entity_id=entity_id,
|
|
279
|
+
)
|
|
280
|
+
return context.client.read_object(api, **kwargs)
|
|
281
|
+
|
|
282
|
+
def update_files_info(
|
|
283
|
+
self,
|
|
284
|
+
project: str,
|
|
285
|
+
entity_type: str,
|
|
286
|
+
entity_id: str,
|
|
287
|
+
entity_list: list[dict],
|
|
288
|
+
**kwargs,
|
|
289
|
+
) -> None:
|
|
290
|
+
"""
|
|
291
|
+
Get files info from backend.
|
|
292
|
+
|
|
293
|
+
Parameters
|
|
294
|
+
----------
|
|
295
|
+
project : str
|
|
296
|
+
Project name.
|
|
297
|
+
entity_type : str
|
|
298
|
+
Entity type.
|
|
299
|
+
entity_id : str
|
|
300
|
+
Entity ID.
|
|
301
|
+
entity_list : list[dict]
|
|
302
|
+
Entity list.
|
|
303
|
+
**kwargs : dict
|
|
304
|
+
Parameters to pass to the API call.
|
|
305
|
+
"""
|
|
306
|
+
context = get_context_from_project(project)
|
|
307
|
+
api = context.client.build_api(
|
|
308
|
+
ApiCategories.CONTEXT.value,
|
|
309
|
+
BackendOperations.FILES.value,
|
|
310
|
+
project=context.name,
|
|
311
|
+
entity_type=entity_type,
|
|
312
|
+
entity_id=entity_id,
|
|
313
|
+
)
|
|
314
|
+
return context.client.update_object(api, entity_list, **kwargs)
|
|
315
|
+
|
|
316
|
+
def read_metrics(
|
|
317
|
+
self,
|
|
318
|
+
project: str,
|
|
319
|
+
entity_type: str,
|
|
320
|
+
entity_id: str,
|
|
321
|
+
metric_name: str | None = None,
|
|
322
|
+
**kwargs,
|
|
323
|
+
) -> dict:
|
|
324
|
+
"""
|
|
325
|
+
Read metrics from the backend for a specific entity.
|
|
326
|
+
|
|
327
|
+
Retrieves metrics data associated with an entity. Can fetch either
|
|
328
|
+
all metrics or a specific metric by name. Used for performance
|
|
329
|
+
monitoring and analysis of entity operations.
|
|
330
|
+
|
|
331
|
+
Parameters
|
|
332
|
+
----------
|
|
333
|
+
project : str
|
|
334
|
+
The project name containing the entity.
|
|
335
|
+
entity_type : str
|
|
336
|
+
The type of entity to read metrics from.
|
|
337
|
+
entity_id : str
|
|
338
|
+
The unique identifier of the entity.
|
|
339
|
+
metric_name : str, optional
|
|
340
|
+
The name of a specific metric to retrieve.
|
|
341
|
+
If None, retrieves all available metrics.
|
|
342
|
+
**kwargs : dict
|
|
343
|
+
Additional parameters to pass to the API call.
|
|
344
|
+
|
|
345
|
+
Returns
|
|
346
|
+
-------
|
|
347
|
+
dict
|
|
348
|
+
Dictionary containing metric data from the backend.
|
|
349
|
+
"""
|
|
350
|
+
context = get_context_from_project(project)
|
|
351
|
+
api = context.client.build_api(
|
|
352
|
+
ApiCategories.CONTEXT.value,
|
|
353
|
+
BackendOperations.METRICS.value,
|
|
354
|
+
project=context.name,
|
|
355
|
+
entity_type=entity_type,
|
|
356
|
+
entity_id=entity_id,
|
|
357
|
+
metric_name=metric_name,
|
|
358
|
+
)
|
|
359
|
+
return context.client.read_object(api, **kwargs)
|
|
360
|
+
|
|
361
|
+
def update_metric(
|
|
362
|
+
self,
|
|
363
|
+
project: str,
|
|
364
|
+
entity_type: str,
|
|
365
|
+
entity_id: str,
|
|
366
|
+
metric_name: str,
|
|
367
|
+
metric_value: Any,
|
|
368
|
+
**kwargs,
|
|
369
|
+
) -> None:
|
|
370
|
+
"""
|
|
371
|
+
Update or create a metric value for an entity in the backend.
|
|
372
|
+
|
|
373
|
+
Updates an existing metric or creates a new one with the specified
|
|
374
|
+
value. Metrics are used for tracking performance, status, and
|
|
375
|
+
other quantitative aspects of entity operations.
|
|
376
|
+
|
|
377
|
+
Parameters
|
|
378
|
+
----------
|
|
379
|
+
project : str
|
|
380
|
+
The project name containing the entity.
|
|
381
|
+
entity_type : str
|
|
382
|
+
The type of entity to update metrics for.
|
|
383
|
+
entity_id : str
|
|
384
|
+
The unique identifier of the entity.
|
|
385
|
+
metric_name : str
|
|
386
|
+
The name of the metric to update or create.
|
|
387
|
+
metric_value : Any
|
|
388
|
+
The value to set for the metric.
|
|
389
|
+
Can be numeric, string, or other supported types.
|
|
390
|
+
**kwargs : dict
|
|
391
|
+
Additional parameters to pass to the API call.
|
|
392
|
+
"""
|
|
393
|
+
context = get_context_from_project(project)
|
|
394
|
+
api = context.client.build_api(
|
|
395
|
+
ApiCategories.CONTEXT.value,
|
|
396
|
+
BackendOperations.METRICS.value,
|
|
397
|
+
project=context.name,
|
|
398
|
+
entity_type=entity_type,
|
|
399
|
+
entity_id=entity_id,
|
|
400
|
+
metric_name=metric_name,
|
|
401
|
+
)
|
|
402
|
+
context.client.update_object(api, metric_value, **kwargs)
|
|
403
|
+
|
|
404
|
+
def search_entity(
|
|
405
|
+
self,
|
|
406
|
+
crud_processor: ContextEntityCRUDProcessor,
|
|
407
|
+
project: str,
|
|
408
|
+
query: str | None = None,
|
|
409
|
+
entity_types: list[str] | None = None,
|
|
410
|
+
name: str | None = None,
|
|
411
|
+
kind: str | None = None,
|
|
412
|
+
created: str | None = None,
|
|
413
|
+
updated: str | None = None,
|
|
414
|
+
description: str | None = None,
|
|
415
|
+
labels: list[str] | None = None,
|
|
416
|
+
**kwargs,
|
|
417
|
+
) -> list[ContextEntity]:
|
|
418
|
+
"""
|
|
419
|
+
Search for entities in the backend using various criteria.
|
|
420
|
+
|
|
421
|
+
Performs a flexible search across multiple entity attributes,
|
|
422
|
+
allowing for complex queries and filtering. Returns matching
|
|
423
|
+
entities from the project context.
|
|
424
|
+
|
|
425
|
+
Parameters
|
|
426
|
+
----------
|
|
427
|
+
crud_processor : ContextEntityCRUDProcessor
|
|
428
|
+
The CRUD processor instance for entity operations.
|
|
429
|
+
project : str
|
|
430
|
+
The project name to search within.
|
|
431
|
+
query : str, optional
|
|
432
|
+
Free-text search query to match against entity content.
|
|
433
|
+
entity_types : list[str], optional
|
|
434
|
+
List of entity types to filter by.
|
|
435
|
+
If None, searches all entity types.
|
|
436
|
+
name : str, optional
|
|
437
|
+
Entity name pattern to match.
|
|
438
|
+
kind : str, optional
|
|
439
|
+
Entity kind to filter by.
|
|
440
|
+
created : str, optional
|
|
441
|
+
Creation date filter (ISO format).
|
|
442
|
+
updated : str, optional
|
|
443
|
+
Last update date filter (ISO format).
|
|
444
|
+
description : str, optional
|
|
445
|
+
Description pattern to match.
|
|
446
|
+
labels : list[str], optional
|
|
447
|
+
List of label patterns to match.
|
|
448
|
+
**kwargs : dict
|
|
449
|
+
Additional search parameters to pass to the API call.
|
|
450
|
+
|
|
451
|
+
Returns
|
|
452
|
+
-------
|
|
453
|
+
list[ContextEntity]
|
|
454
|
+
List of matching entity instances from the search.
|
|
455
|
+
"""
|
|
456
|
+
context = get_context_from_project(project)
|
|
457
|
+
kwargs = context.client.build_parameters(
|
|
458
|
+
ApiCategories.CONTEXT.value,
|
|
459
|
+
BackendOperations.SEARCH.value,
|
|
460
|
+
query=query,
|
|
461
|
+
entity_types=entity_types,
|
|
462
|
+
name=name,
|
|
463
|
+
kind=kind,
|
|
464
|
+
created=created,
|
|
465
|
+
updated=updated,
|
|
466
|
+
description=description,
|
|
467
|
+
labels=labels,
|
|
468
|
+
**kwargs,
|
|
469
|
+
)
|
|
470
|
+
api = context.client.build_api(
|
|
471
|
+
ApiCategories.CONTEXT.value,
|
|
472
|
+
BackendOperations.SEARCH.value,
|
|
473
|
+
project=context.name,
|
|
474
|
+
)
|
|
475
|
+
entities_dict = context.client.read_object(api, **kwargs)
|
|
476
|
+
return [crud_processor.read_context_entity(entity["key"]) for entity in entities_dict["content"]]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
from digitalhub.entities._processors.base.processor import BaseEntityOperationsProcessor
|
|
6
|
+
from digitalhub.entities._processors.context.processor import ContextEntityOperationsProcessor
|
|
7
|
+
|
|
8
|
+
# Base processor singleton instance
|
|
9
|
+
base_processor = BaseEntityOperationsProcessor()
|
|
10
|
+
|
|
11
|
+
# Context processor singleton instance
|
|
12
|
+
context_processor = ContextEntityOperationsProcessor()
|
|
@@ -7,7 +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.
|
|
10
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
11
11
|
from digitalhub.entities.artifact._base.entity import Artifact
|
|
12
12
|
from digitalhub.entities.artifact.utils import eval_source, process_kwargs
|
|
13
13
|
from digitalhub.utils.types import SourcesOrListOfSources
|
|
@@ -156,9 +156,7 @@ def get_artifact(
|
|
|
156
156
|
Examples
|
|
157
157
|
--------
|
|
158
158
|
Using entity key:
|
|
159
|
-
>>> obj = get_artifact(
|
|
160
|
-
... "store://my-artifact-key"
|
|
161
|
-
... )
|
|
159
|
+
>>> obj = get_artifact("store://my-artifact-key")
|
|
162
160
|
|
|
163
161
|
Using entity name:
|
|
164
162
|
>>> obj = get_artifact("my-artifact-name"
|
|
@@ -199,9 +197,7 @@ def get_artifact_versions(
|
|
|
199
197
|
Examples
|
|
200
198
|
--------
|
|
201
199
|
Using entity key:
|
|
202
|
-
>>> obj = get_artifact_versions(
|
|
203
|
-
... "store://my-artifact-key"
|
|
204
|
-
... )
|
|
200
|
+
>>> obj = get_artifact_versions("store://my-artifact-key")
|
|
205
201
|
|
|
206
202
|
Using entity name:
|
|
207
203
|
>>> obj = get_artifact_versions("my-artifact-name"
|
|
@@ -233,9 +229,7 @@ def list_artifacts(project: str, **kwargs) -> list[Artifact]:
|
|
|
233
229
|
|
|
234
230
|
Examples
|
|
235
231
|
--------
|
|
236
|
-
>>> objs = list_artifacts(
|
|
237
|
-
... project="my-project"
|
|
238
|
-
... )
|
|
232
|
+
>>> objs = list_artifacts(project="my-project")
|
|
239
233
|
"""
|
|
240
234
|
return context_processor.list_context_entities(
|
|
241
235
|
project=project,
|
|
@@ -271,9 +265,7 @@ def import_artifact(
|
|
|
271
265
|
|
|
272
266
|
Examples
|
|
273
267
|
--------
|
|
274
|
-
>>> obj = import_artifact(
|
|
275
|
-
... "my-artifact.yaml"
|
|
276
|
-
... )
|
|
268
|
+
>>> obj = import_artifact("my-artifact.yaml")
|
|
277
269
|
"""
|
|
278
270
|
return context_processor.import_context_entity(
|
|
279
271
|
file,
|
|
@@ -299,9 +291,7 @@ def load_artifact(file: str) -> Artifact:
|
|
|
299
291
|
|
|
300
292
|
Examples
|
|
301
293
|
--------
|
|
302
|
-
>>> obj = load_artifact(
|
|
303
|
-
... "my-artifact.yaml"
|
|
304
|
-
... )
|
|
294
|
+
>>> obj = load_artifact("my-artifact.yaml")
|
|
305
295
|
"""
|
|
306
296
|
return context_processor.load_context_entity(file)
|
|
307
297
|
|
|
@@ -322,11 +312,7 @@ def update_artifact(entity: Artifact) -> Artifact:
|
|
|
322
312
|
|
|
323
313
|
Examples
|
|
324
314
|
--------
|
|
325
|
-
>>> obj = (
|
|
326
|
-
... update_artifact(
|
|
327
|
-
... obj
|
|
328
|
-
... )
|
|
329
|
-
... )
|
|
315
|
+
>>> obj = update_artifact(obj)
|
|
330
316
|
"""
|
|
331
317
|
return context_processor.update_context_entity(
|
|
332
318
|
project=entity.project,
|
|
@@ -370,9 +356,7 @@ def delete_artifact(
|
|
|
370
356
|
Examples
|
|
371
357
|
--------
|
|
372
358
|
If delete_all_versions is False:
|
|
373
|
-
>>> delete_artifact(
|
|
374
|
-
... "store://my-artifact-key"
|
|
375
|
-
... )
|
|
359
|
+
>>> delete_artifact("store://my-artifact-key")
|
|
376
360
|
|
|
377
361
|
Otherwise:
|
|
378
362
|
>>> delete_artifact("my-artifact-name",
|
|
@@ -8,7 +8,7 @@ import typing
|
|
|
8
8
|
from typing import Any
|
|
9
9
|
|
|
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
|
from digitalhub.entities.dataitem.utils import clean_tmp_path, eval_data, eval_source, post_process, process_kwargs
|
|
13
13
|
from digitalhub.utils.types import SourcesOrListOfSources
|
|
14
14
|
|
|
@@ -185,9 +185,7 @@ def get_dataitem(
|
|
|
185
185
|
Examples
|
|
186
186
|
--------
|
|
187
187
|
Using entity key:
|
|
188
|
-
>>> obj = get_dataitem(
|
|
189
|
-
... "store://my-dataitem-key"
|
|
190
|
-
... )
|
|
188
|
+
>>> obj = get_dataitem("store://my-dataitem-key")
|
|
191
189
|
|
|
192
190
|
Using entity name:
|
|
193
191
|
>>> obj = get_dataitem("my-dataitem-name"
|
|
@@ -228,9 +226,7 @@ def get_dataitem_versions(
|
|
|
228
226
|
Examples
|
|
229
227
|
--------
|
|
230
228
|
Using entity key:
|
|
231
|
-
>>> objs = get_dataitem_versions(
|
|
232
|
-
... "store://my-dataitem-key"
|
|
233
|
-
... )
|
|
229
|
+
>>> objs = get_dataitem_versions("store://my-dataitem-key")
|
|
234
230
|
|
|
235
231
|
Using entity name:
|
|
236
232
|
>>> objs = get_dataitem_versions("my-dataitem-name",
|
|
@@ -262,9 +258,7 @@ def list_dataitems(project: str, **kwargs) -> list[Dataitem]:
|
|
|
262
258
|
|
|
263
259
|
Examples
|
|
264
260
|
--------
|
|
265
|
-
>>> objs = list_dataitems(
|
|
266
|
-
... project="my-project"
|
|
267
|
-
... )
|
|
261
|
+
>>> objs = list_dataitems(project="my-project")
|
|
268
262
|
"""
|
|
269
263
|
return context_processor.list_context_entities(
|
|
270
264
|
project=project,
|
|
@@ -300,9 +294,7 @@ def import_dataitem(
|
|
|
300
294
|
|
|
301
295
|
Examples
|
|
302
296
|
--------
|
|
303
|
-
>>> obj = import_dataitem(
|
|
304
|
-
... "my-dataitem.yaml"
|
|
305
|
-
... )
|
|
297
|
+
>>> obj = import_dataitem("my-dataitem.yaml")
|
|
306
298
|
"""
|
|
307
299
|
return context_processor.import_context_entity(
|
|
308
300
|
file,
|
|
@@ -328,9 +320,7 @@ def load_dataitem(file: str) -> Dataitem:
|
|
|
328
320
|
|
|
329
321
|
Examples
|
|
330
322
|
--------
|
|
331
|
-
>>> obj = load_dataitem(
|
|
332
|
-
... "my-dataitem.yaml"
|
|
333
|
-
... )
|
|
323
|
+
>>> obj = load_dataitem("my-dataitem.yaml")
|
|
334
324
|
"""
|
|
335
325
|
return context_processor.load_context_entity(file)
|
|
336
326
|
|
|
@@ -351,11 +341,7 @@ def update_dataitem(entity: Dataitem) -> Dataitem:
|
|
|
351
341
|
|
|
352
342
|
Examples
|
|
353
343
|
--------
|
|
354
|
-
>>> obj = (
|
|
355
|
-
... update_dataitem(
|
|
356
|
-
... obj
|
|
357
|
-
... )
|
|
358
|
-
... )
|
|
344
|
+
>>> obj = update_dataitem(obj)
|
|
359
345
|
"""
|
|
360
346
|
return context_processor.update_context_entity(
|
|
361
347
|
project=entity.project,
|
|
@@ -399,9 +385,7 @@ def delete_dataitem(
|
|
|
399
385
|
Examples
|
|
400
386
|
--------
|
|
401
387
|
If delete_all_versions is False:
|
|
402
|
-
>>> obj = delete_dataitem(
|
|
403
|
-
... "store://my-dataitem-key"
|
|
404
|
-
... )
|
|
388
|
+
>>> obj = delete_dataitem("store://my-dataitem-key")
|
|
405
389
|
|
|
406
390
|
Otherwise:
|
|
407
391
|
>>> obj = delete_dataitem("my-dataitem-name",
|
|
@@ -139,12 +139,8 @@ class DataitemTable(Dataitem):
|
|
|
139
139
|
>>> import digitalhub as dh
|
|
140
140
|
>>> import pandas as pd
|
|
141
141
|
>>>
|
|
142
|
-
>>> p = dh.get_project(
|
|
143
|
-
|
|
144
|
-
... )
|
|
145
|
-
>>> df = pd.read_df(
|
|
146
|
-
... "data/my_data.csv"
|
|
147
|
-
... )
|
|
142
|
+
>>> p = dh.get_project("my_project")
|
|
143
|
+
>>> df = pd.read_df("data/my_data.csv")
|
|
148
144
|
>>> di = p.new_dataitem(
|
|
149
145
|
... name="my_dataitem",
|
|
150
146
|
... kind="table",
|