digitalhub 0.13.0b2__py3-none-any.whl → 0.13.0b4__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/context/api.py +5 -5
- digitalhub/context/builder.py +3 -5
- digitalhub/context/context.py +9 -1
- digitalhub/entities/_base/material/entity.py +3 -3
- digitalhub/entities/_commons/metrics.py +64 -30
- digitalhub/entities/_commons/utils.py +36 -9
- digitalhub/entities/_processors/base.py +150 -79
- digitalhub/entities/_processors/context.py +363 -212
- digitalhub/entities/_processors/utils.py +74 -30
- digitalhub/entities/artifact/utils.py +28 -13
- digitalhub/entities/dataitem/crud.py +10 -2
- digitalhub/entities/dataitem/table/entity.py +3 -3
- digitalhub/entities/dataitem/utils.py +84 -35
- digitalhub/entities/model/utils.py +28 -13
- digitalhub/entities/task/_base/models.py +12 -3
- digitalhub/factory/factory.py +25 -3
- digitalhub/factory/utils.py +11 -3
- digitalhub/runtimes/_base.py +1 -1
- digitalhub/runtimes/builder.py +18 -1
- digitalhub/stores/client/__init__.py +12 -0
- digitalhub/stores/client/_base/api_builder.py +14 -0
- digitalhub/stores/client/_base/client.py +93 -0
- digitalhub/stores/client/_base/key_builder.py +28 -0
- digitalhub/stores/client/_base/params_builder.py +14 -0
- digitalhub/stores/client/api.py +10 -5
- digitalhub/stores/client/builder.py +3 -1
- digitalhub/stores/client/dhcore/api_builder.py +17 -0
- digitalhub/stores/client/dhcore/client.py +276 -58
- digitalhub/stores/client/dhcore/configurator.py +336 -141
- digitalhub/stores/client/dhcore/error_parser.py +35 -1
- digitalhub/stores/client/dhcore/params_builder.py +113 -17
- digitalhub/stores/client/dhcore/utils.py +32 -14
- digitalhub/stores/client/local/api_builder.py +17 -0
- digitalhub/stores/client/local/client.py +6 -8
- digitalhub/stores/credentials/api.py +8 -8
- digitalhub/stores/credentials/configurator.py +176 -3
- digitalhub/stores/credentials/enums.py +17 -3
- digitalhub/stores/credentials/handler.py +73 -45
- digitalhub/stores/credentials/ini_module.py +59 -27
- digitalhub/stores/credentials/store.py +33 -1
- digitalhub/stores/data/_base/store.py +8 -3
- digitalhub/stores/data/api.py +20 -16
- digitalhub/stores/data/builder.py +69 -13
- digitalhub/stores/data/s3/configurator.py +64 -23
- digitalhub/stores/data/s3/store.py +30 -27
- digitalhub/stores/data/s3/utils.py +9 -9
- digitalhub/stores/data/sql/configurator.py +76 -25
- digitalhub/stores/data/sql/store.py +180 -91
- digitalhub/utils/exceptions.py +6 -0
- digitalhub/utils/file_utils.py +53 -30
- digitalhub/utils/generic_utils.py +41 -33
- digitalhub/utils/git_utils.py +24 -14
- digitalhub/utils/io_utils.py +19 -18
- digitalhub/utils/uri_utils.py +31 -31
- {digitalhub-0.13.0b2.dist-info → digitalhub-0.13.0b4.dist-info}/METADATA +1 -1
- {digitalhub-0.13.0b2.dist-info → digitalhub-0.13.0b4.dist-info}/RECORD +60 -61
- digitalhub/entities/_commons/types.py +0 -9
- {digitalhub-0.13.0b2.dist-info → digitalhub-0.13.0b4.dist-info}/WHEEL +0 -0
- {digitalhub-0.13.0b2.dist-info → digitalhub-0.13.0b4.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.13.0b2.dist-info → digitalhub-0.13.0b4.dist-info}/licenses/LICENSE +0 -0
digitalhub/factory/factory.py
CHANGED
|
@@ -55,9 +55,13 @@ class Factory:
|
|
|
55
55
|
----------
|
|
56
56
|
name : str
|
|
57
57
|
The unique identifier for the builder.
|
|
58
|
-
builder : EntityBuilder
|
|
58
|
+
builder : EntityBuilder or RuntimeEntityBuilder
|
|
59
59
|
The builder instance to register.
|
|
60
60
|
|
|
61
|
+
Returns
|
|
62
|
+
-------
|
|
63
|
+
None
|
|
64
|
+
|
|
61
65
|
Raises
|
|
62
66
|
------
|
|
63
67
|
BuilderError
|
|
@@ -78,6 +82,10 @@ class Factory:
|
|
|
78
82
|
builder : RuntimeBuilder
|
|
79
83
|
The builder instance to register.
|
|
80
84
|
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
None
|
|
88
|
+
|
|
81
89
|
Raises
|
|
82
90
|
------
|
|
83
91
|
BuilderError
|
|
@@ -137,6 +145,8 @@ class Factory:
|
|
|
137
145
|
----------
|
|
138
146
|
kind_to_build_from : str
|
|
139
147
|
Entity type.
|
|
148
|
+
**kwargs
|
|
149
|
+
Additional spec parameters.
|
|
140
150
|
|
|
141
151
|
Returns
|
|
142
152
|
-------
|
|
@@ -154,6 +164,8 @@ class Factory:
|
|
|
154
164
|
----------
|
|
155
165
|
kind_to_build_from : str
|
|
156
166
|
Entity type.
|
|
167
|
+
**kwargs
|
|
168
|
+
Additional metadata parameters.
|
|
157
169
|
|
|
158
170
|
Returns
|
|
159
171
|
-------
|
|
@@ -171,6 +183,8 @@ class Factory:
|
|
|
171
183
|
----------
|
|
172
184
|
kind_to_build_from : str
|
|
173
185
|
Entity type.
|
|
186
|
+
**kwargs
|
|
187
|
+
Additional status parameters.
|
|
174
188
|
|
|
175
189
|
Returns
|
|
176
190
|
-------
|
|
@@ -265,7 +279,7 @@ class Factory:
|
|
|
265
279
|
|
|
266
280
|
Returns
|
|
267
281
|
-------
|
|
268
|
-
list
|
|
282
|
+
list of str
|
|
269
283
|
Task kinds.
|
|
270
284
|
"""
|
|
271
285
|
self._raise_if_entity_builder_not_found(kind)
|
|
@@ -299,7 +313,7 @@ class Factory:
|
|
|
299
313
|
|
|
300
314
|
Returns
|
|
301
315
|
-------
|
|
302
|
-
list
|
|
316
|
+
list of str
|
|
303
317
|
All kinds.
|
|
304
318
|
"""
|
|
305
319
|
return self._entity_builders[kind].get_all_kinds()
|
|
@@ -330,6 +344,10 @@ class Factory:
|
|
|
330
344
|
kind : str
|
|
331
345
|
The entity kind to verify.
|
|
332
346
|
|
|
347
|
+
Returns
|
|
348
|
+
-------
|
|
349
|
+
None
|
|
350
|
+
|
|
333
351
|
Raises
|
|
334
352
|
------
|
|
335
353
|
BuilderError
|
|
@@ -347,6 +365,10 @@ class Factory:
|
|
|
347
365
|
kind : str
|
|
348
366
|
The runtime kind to verify.
|
|
349
367
|
|
|
368
|
+
Returns
|
|
369
|
+
-------
|
|
370
|
+
None
|
|
371
|
+
|
|
350
372
|
Raises
|
|
351
373
|
------
|
|
352
374
|
BuilderError
|
digitalhub/factory/utils.py
CHANGED
|
@@ -50,7 +50,7 @@ def list_runtimes() -> list[str]:
|
|
|
50
50
|
|
|
51
51
|
Returns
|
|
52
52
|
-------
|
|
53
|
-
list
|
|
53
|
+
list of str
|
|
54
54
|
List of runtime package names.
|
|
55
55
|
|
|
56
56
|
Raises
|
|
@@ -75,6 +75,10 @@ def register_runtimes_entities() -> None:
|
|
|
75
75
|
|
|
76
76
|
Imports each runtime package and registers its entity and runtime
|
|
77
77
|
builders with the global factory instance.
|
|
78
|
+
|
|
79
|
+
Returns
|
|
80
|
+
-------
|
|
81
|
+
None
|
|
78
82
|
"""
|
|
79
83
|
for package in list_runtimes():
|
|
80
84
|
module = import_module(package)
|
|
@@ -93,8 +97,12 @@ def register_entities() -> None:
|
|
|
93
97
|
"""
|
|
94
98
|
Register core entity builders into the factory.
|
|
95
99
|
|
|
96
|
-
Imports the core entities module and registers all entity
|
|
97
|
-
with the global factory instance.
|
|
100
|
+
Imports the core entities module and registers all entity
|
|
101
|
+
builders with the global factory instance.
|
|
102
|
+
|
|
103
|
+
Returns
|
|
104
|
+
-------
|
|
105
|
+
None
|
|
98
106
|
|
|
99
107
|
Raises
|
|
100
108
|
------
|
digitalhub/runtimes/_base.py
CHANGED
digitalhub/runtimes/builder.py
CHANGED
|
@@ -34,12 +34,29 @@ class RuntimeBuilder:
|
|
|
34
34
|
RUNTIME_CLASS: Runtime = None
|
|
35
35
|
|
|
36
36
|
def __init__(self) -> None:
|
|
37
|
+
"""
|
|
38
|
+
Initialize a RuntimeBuilder instance.
|
|
39
|
+
|
|
40
|
+
Raises
|
|
41
|
+
------
|
|
42
|
+
BuilderError
|
|
43
|
+
If RUNTIME_CLASS is not set in the implementing class.
|
|
44
|
+
"""
|
|
37
45
|
if self.RUNTIME_CLASS is None:
|
|
38
46
|
raise BuilderError("RUNTIME_CLASS must be set")
|
|
39
47
|
|
|
40
48
|
def build(self, project: str, *args, **kwargs) -> Runtime:
|
|
41
49
|
"""
|
|
42
|
-
Build runtime object.
|
|
50
|
+
Build a runtime object.
|
|
51
|
+
|
|
52
|
+
Parameters
|
|
53
|
+
----------
|
|
54
|
+
project : str
|
|
55
|
+
The project identifier for the runtime instance.
|
|
56
|
+
*args
|
|
57
|
+
Additional positional arguments to pass to the Runtime constructor.
|
|
58
|
+
**kwargs
|
|
59
|
+
Additional keyword arguments to pass to the Runtime constructor.
|
|
43
60
|
|
|
44
61
|
Returns
|
|
45
62
|
-------
|
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
# SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Client module for DigitalHub SDK.
|
|
7
|
+
|
|
8
|
+
This module provides client implementations for interacting with different
|
|
9
|
+
backends:
|
|
10
|
+
- Local client for in-memory operations
|
|
11
|
+
- DHCore client for remote backend communication
|
|
12
|
+
|
|
13
|
+
The main entry point is through the get_client function which returns
|
|
14
|
+
the appropriate client instance based on the configuration.
|
|
15
|
+
"""
|
|
@@ -17,4 +17,18 @@ class ClientApiBuilder:
|
|
|
17
17
|
def build_api(self, category: str, operation: str, **kwargs) -> str:
|
|
18
18
|
"""
|
|
19
19
|
Build the API for the client.
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
category : str
|
|
24
|
+
The API category.
|
|
25
|
+
operation : str
|
|
26
|
+
The API operation.
|
|
27
|
+
**kwargs : dict
|
|
28
|
+
Additional keyword arguments.
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
str
|
|
33
|
+
The formatted API endpoint.
|
|
20
34
|
"""
|
|
@@ -36,42 +36,130 @@ class Client:
|
|
|
36
36
|
def create_object(self, api: str, obj: Any, **kwargs) -> dict:
|
|
37
37
|
"""
|
|
38
38
|
Create object method.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
api : str
|
|
43
|
+
The API endpoint to create the object.
|
|
44
|
+
obj : Any
|
|
45
|
+
The object to create.
|
|
46
|
+
**kwargs : dict
|
|
47
|
+
Additional keyword arguments.
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
dict
|
|
52
|
+
The created object.
|
|
39
53
|
"""
|
|
40
54
|
|
|
41
55
|
@abstractmethod
|
|
42
56
|
def read_object(self, api: str, **kwargs) -> dict:
|
|
43
57
|
"""
|
|
44
58
|
Read object method.
|
|
59
|
+
|
|
60
|
+
Parameters
|
|
61
|
+
----------
|
|
62
|
+
api : str
|
|
63
|
+
The API endpoint to read the object.
|
|
64
|
+
**kwargs : dict
|
|
65
|
+
Additional keyword arguments.
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
dict
|
|
70
|
+
The retrieved object.
|
|
45
71
|
"""
|
|
46
72
|
|
|
47
73
|
@abstractmethod
|
|
48
74
|
def update_object(self, api: str, obj: Any, **kwargs) -> dict:
|
|
49
75
|
"""
|
|
50
76
|
Update object method.
|
|
77
|
+
|
|
78
|
+
Parameters
|
|
79
|
+
----------
|
|
80
|
+
api : str
|
|
81
|
+
The API endpoint to update the object.
|
|
82
|
+
obj : Any
|
|
83
|
+
The object to update.
|
|
84
|
+
**kwargs : dict
|
|
85
|
+
Additional keyword arguments.
|
|
86
|
+
|
|
87
|
+
Returns
|
|
88
|
+
-------
|
|
89
|
+
dict
|
|
90
|
+
The updated object.
|
|
51
91
|
"""
|
|
52
92
|
|
|
53
93
|
@abstractmethod
|
|
54
94
|
def delete_object(self, api: str, **kwargs) -> dict:
|
|
55
95
|
"""
|
|
56
96
|
Delete object method.
|
|
97
|
+
|
|
98
|
+
Parameters
|
|
99
|
+
----------
|
|
100
|
+
api : str
|
|
101
|
+
The API endpoint to delete the object.
|
|
102
|
+
**kwargs : dict
|
|
103
|
+
Additional keyword arguments.
|
|
104
|
+
|
|
105
|
+
Returns
|
|
106
|
+
-------
|
|
107
|
+
dict
|
|
108
|
+
The deletion result.
|
|
57
109
|
"""
|
|
58
110
|
|
|
59
111
|
@abstractmethod
|
|
60
112
|
def list_objects(self, api: str, **kwargs) -> dict:
|
|
61
113
|
"""
|
|
62
114
|
List objects method.
|
|
115
|
+
|
|
116
|
+
Parameters
|
|
117
|
+
----------
|
|
118
|
+
api : str
|
|
119
|
+
The API endpoint to list objects.
|
|
120
|
+
**kwargs : dict
|
|
121
|
+
Additional keyword arguments.
|
|
122
|
+
|
|
123
|
+
Returns
|
|
124
|
+
-------
|
|
125
|
+
dict
|
|
126
|
+
The list of objects.
|
|
63
127
|
"""
|
|
64
128
|
|
|
65
129
|
@abstractmethod
|
|
66
130
|
def list_first_object(self, api: str, **kwargs) -> dict:
|
|
67
131
|
"""
|
|
68
132
|
Read first object method.
|
|
133
|
+
|
|
134
|
+
Parameters
|
|
135
|
+
----------
|
|
136
|
+
api : str
|
|
137
|
+
The API endpoint to read the first object.
|
|
138
|
+
**kwargs : dict
|
|
139
|
+
Additional keyword arguments.
|
|
140
|
+
|
|
141
|
+
Returns
|
|
142
|
+
-------
|
|
143
|
+
dict
|
|
144
|
+
The first object in the list.
|
|
69
145
|
"""
|
|
70
146
|
|
|
71
147
|
@abstractmethod
|
|
72
148
|
def search_objects(self, api: str, **kwargs) -> dict:
|
|
73
149
|
"""
|
|
74
150
|
Search objects method.
|
|
151
|
+
|
|
152
|
+
Parameters
|
|
153
|
+
----------
|
|
154
|
+
api : str
|
|
155
|
+
The API endpoint to search objects.
|
|
156
|
+
**kwargs : dict
|
|
157
|
+
Additional keyword arguments containing search parameters.
|
|
158
|
+
|
|
159
|
+
Returns
|
|
160
|
+
-------
|
|
161
|
+
dict
|
|
162
|
+
The search results.
|
|
75
163
|
"""
|
|
76
164
|
|
|
77
165
|
##############################
|
|
@@ -147,4 +235,9 @@ class Client:
|
|
|
147
235
|
def is_local() -> bool:
|
|
148
236
|
"""
|
|
149
237
|
Flag to check if client is local.
|
|
238
|
+
|
|
239
|
+
Returns
|
|
240
|
+
-------
|
|
241
|
+
bool
|
|
242
|
+
True if the client operates locally, False otherwise.
|
|
150
243
|
"""
|
|
@@ -40,6 +40,16 @@ class ClientKeyBuilder:
|
|
|
40
40
|
def base_entity_key(self, entity_id: str) -> str:
|
|
41
41
|
"""
|
|
42
42
|
Build for base entity key.
|
|
43
|
+
|
|
44
|
+
Parameters
|
|
45
|
+
----------
|
|
46
|
+
entity_id : str
|
|
47
|
+
The entity identifier.
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
str
|
|
52
|
+
The formatted base entity key.
|
|
43
53
|
"""
|
|
44
54
|
|
|
45
55
|
@abstractmethod
|
|
@@ -53,4 +63,22 @@ class ClientKeyBuilder:
|
|
|
53
63
|
) -> str:
|
|
54
64
|
"""
|
|
55
65
|
Build for context entity key.
|
|
66
|
+
|
|
67
|
+
Parameters
|
|
68
|
+
----------
|
|
69
|
+
project : str
|
|
70
|
+
The project name.
|
|
71
|
+
entity_type : str
|
|
72
|
+
The entity type.
|
|
73
|
+
entity_kind : str
|
|
74
|
+
The entity kind.
|
|
75
|
+
entity_name : str
|
|
76
|
+
The entity name.
|
|
77
|
+
entity_id : str, optional
|
|
78
|
+
The entity identifier. If None, key will not include version.
|
|
79
|
+
|
|
80
|
+
Returns
|
|
81
|
+
-------
|
|
82
|
+
str
|
|
83
|
+
The formatted context entity key.
|
|
56
84
|
"""
|
|
@@ -17,4 +17,18 @@ class ClientParametersBuilder:
|
|
|
17
17
|
def build_parameters(self, category: str, operation: str, **kwargs) -> dict:
|
|
18
18
|
"""
|
|
19
19
|
Build the parameters for the client call.
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
category : str
|
|
24
|
+
The API category.
|
|
25
|
+
operation : str
|
|
26
|
+
The API operation.
|
|
27
|
+
**kwargs : dict
|
|
28
|
+
Additional keyword arguments to build parameters from.
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
dict
|
|
33
|
+
The formatted parameters for the client call.
|
|
20
34
|
"""
|
digitalhub/stores/client/api.py
CHANGED
|
@@ -18,14 +18,19 @@ def get_client(local: bool = False, config: dict | None = None) -> Client:
|
|
|
18
18
|
|
|
19
19
|
Parameters
|
|
20
20
|
----------
|
|
21
|
-
local : bool
|
|
22
|
-
Whether to create a local client or not.
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
local : bool, default False
|
|
22
|
+
Whether to create a local client or not. If True, creates a
|
|
23
|
+
ClientLocal instance that operates in-memory. If False, creates
|
|
24
|
+
a ClientDHCore instance that communicates with a remote backend.
|
|
25
|
+
config : dict, optional
|
|
26
|
+
DHCore environment configuration. Only used when local=False.
|
|
27
|
+
If None, configuration will be loaded from environment variables
|
|
28
|
+
and configuration files.
|
|
25
29
|
|
|
26
30
|
Returns
|
|
27
31
|
-------
|
|
28
32
|
Client
|
|
29
|
-
The client instance.
|
|
33
|
+
The client instance. Either ClientLocal or ClientDHCore depending
|
|
34
|
+
on the local parameter.
|
|
30
35
|
"""
|
|
31
36
|
return client_builder.build(local, config)
|
|
@@ -74,6 +74,23 @@ class ClientDHCoreApiBuilder(ClientApiBuilder):
|
|
|
74
74
|
def build_api_context(self, operation: str, **kwargs) -> str:
|
|
75
75
|
"""
|
|
76
76
|
Build the context API for the client.
|
|
77
|
+
|
|
78
|
+
Parameters
|
|
79
|
+
----------
|
|
80
|
+
operation : str
|
|
81
|
+
The API operation.
|
|
82
|
+
**kwargs : dict
|
|
83
|
+
Additional parameters including project, entity_type, entity_id, etc.
|
|
84
|
+
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
str
|
|
88
|
+
The formatted context API endpoint.
|
|
89
|
+
|
|
90
|
+
Raises
|
|
91
|
+
------
|
|
92
|
+
BackendError
|
|
93
|
+
If the operation is not supported for the entity type.
|
|
77
94
|
"""
|
|
78
95
|
project = kwargs["project"]
|
|
79
96
|
if operation == BackendOperations.SEARCH.value:
|