digitalhub 0.13.3__py3-none-any.whl → 0.14.0__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 +3 -8
- digitalhub/context/api.py +1 -5
- digitalhub/context/builder.py +1 -5
- digitalhub/context/context.py +15 -9
- digitalhub/entities/_base/_base/entity.py +0 -15
- digitalhub/entities/_base/context/entity.py +1 -1
- digitalhub/entities/_base/entity/builder.py +5 -5
- digitalhub/entities/_base/entity/entity.py +0 -8
- digitalhub/entities/_base/executable/entity.py +169 -79
- digitalhub/entities/_base/material/entity.py +6 -22
- digitalhub/entities/_base/material/utils.py +1 -4
- digitalhub/entities/_base/runtime_entity/builder.py +53 -18
- digitalhub/entities/_base/unversioned/entity.py +1 -1
- digitalhub/entities/_base/versioned/entity.py +1 -1
- digitalhub/entities/_commons/enums.py +1 -31
- digitalhub/entities/_commons/utils.py +83 -21
- digitalhub/entities/_constructors/_resources.py +151 -0
- digitalhub/entities/{_base/entity/_constructors → _constructors}/name.py +18 -0
- digitalhub/entities/_processors/base/__init__.py +3 -0
- digitalhub/entities/_processors/{base.py → base/crud.py} +14 -226
- digitalhub/entities/_processors/base/import_export.py +123 -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 +652 -0
- digitalhub/entities/_processors/context/import_export.py +242 -0
- digitalhub/entities/_processors/context/material.py +123 -0
- digitalhub/entities/_processors/context/processor.py +400 -0
- digitalhub/entities/_processors/context/special_ops.py +476 -0
- digitalhub/entities/_processors/processors.py +12 -0
- digitalhub/entities/_processors/utils.py +12 -11
- digitalhub/entities/artifact/crud.py +58 -22
- digitalhub/entities/artifact/utils.py +3 -3
- digitalhub/entities/dataitem/crud.py +63 -20
- digitalhub/entities/dataitem/table/entity.py +24 -22
- digitalhub/entities/dataitem/utils.py +15 -15
- digitalhub/entities/function/_base/entity.py +3 -3
- digitalhub/entities/function/crud.py +55 -24
- digitalhub/entities/model/_base/entity.py +62 -20
- digitalhub/entities/model/crud.py +58 -22
- digitalhub/entities/model/utils.py +3 -3
- digitalhub/entities/project/_base/entity.py +321 -152
- digitalhub/entities/project/crud.py +15 -23
- digitalhub/entities/run/_base/builder.py +0 -4
- digitalhub/entities/run/_base/entity.py +70 -63
- digitalhub/entities/run/crud.py +79 -26
- digitalhub/entities/secret/_base/entity.py +1 -5
- digitalhub/entities/secret/crud.py +29 -26
- digitalhub/entities/task/_base/builder.py +0 -4
- digitalhub/entities/task/_base/entity.py +5 -5
- digitalhub/entities/task/_base/models.py +13 -16
- digitalhub/entities/task/crud.py +61 -29
- digitalhub/entities/trigger/_base/entity.py +1 -5
- digitalhub/entities/trigger/crud.py +64 -24
- digitalhub/entities/workflow/_base/entity.py +3 -3
- digitalhub/entities/workflow/crud.py +55 -21
- digitalhub/factory/entity.py +283 -0
- digitalhub/factory/enums.py +18 -0
- digitalhub/factory/registry.py +197 -0
- digitalhub/factory/runtime.py +44 -0
- digitalhub/factory/utils.py +3 -54
- digitalhub/runtimes/_base.py +2 -2
- digitalhub/stores/client/_base/enums.py +39 -0
- digitalhub/stores/client/_base/key_builder.py +2 -2
- digitalhub/stores/client/_base/params_builder.py +48 -0
- digitalhub/stores/client/api.py +6 -10
- digitalhub/stores/client/builder.py +4 -4
- digitalhub/stores/client/dhcore/api_builder.py +2 -1
- digitalhub/stores/client/dhcore/client.py +85 -429
- digitalhub/stores/client/dhcore/configurator.py +109 -328
- digitalhub/stores/client/dhcore/enums.py +0 -16
- digitalhub/stores/client/dhcore/error_parser.py +0 -4
- digitalhub/stores/client/dhcore/header_manager.py +61 -0
- digitalhub/stores/client/dhcore/http_handler.py +133 -0
- digitalhub/stores/client/dhcore/params_builder.py +147 -134
- digitalhub/stores/client/dhcore/response_processor.py +102 -0
- digitalhub/stores/client/dhcore/utils.py +6 -72
- digitalhub/stores/client/local/api_builder.py +1 -1
- digitalhub/stores/client/local/client.py +79 -47
- digitalhub/stores/client/local/params_builder.py +18 -41
- digitalhub/stores/credentials/api.py +0 -4
- digitalhub/stores/credentials/configurator.py +2 -28
- digitalhub/stores/credentials/enums.py +3 -0
- digitalhub/stores/credentials/handler.py +0 -12
- digitalhub/stores/credentials/ini_module.py +0 -22
- digitalhub/stores/credentials/store.py +0 -4
- digitalhub/stores/data/_base/store.py +0 -16
- digitalhub/stores/data/builder.py +1 -5
- digitalhub/stores/data/local/store.py +0 -103
- digitalhub/stores/data/remote/store.py +0 -4
- digitalhub/stores/data/s3/configurator.py +60 -14
- digitalhub/stores/data/s3/store.py +49 -16
- digitalhub/stores/data/sql/configurator.py +0 -8
- digitalhub/stores/data/sql/store.py +21 -10
- digitalhub/stores/readers/data/factory.py +0 -8
- digitalhub/stores/readers/data/pandas/reader.py +0 -16
- digitalhub/utils/file_utils.py +0 -17
- digitalhub/utils/generic_utils.py +0 -12
- digitalhub/utils/git_utils.py +0 -8
- digitalhub/utils/io_utils.py +0 -12
- digitalhub/utils/store_utils.py +44 -0
- {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/METADATA +3 -2
- {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/RECORD +111 -95
- digitalhub/entities/_processors/context.py +0 -1450
- digitalhub/entities/task/_base/utils.py +0 -22
- digitalhub/factory/factory.py +0 -381
- digitalhub/stores/client/dhcore/models.py +0 -40
- digitalhub/stores/data/s3/utils.py +0 -78
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/__init__.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/metadata.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/spec.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/status.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/uuid.py +0 -0
- {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/WHEEL +0 -0
- {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -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
|
|
|
12
12
|
if typing.TYPE_CHECKING:
|
|
13
13
|
from digitalhub.entities.function._base.entity import Function
|
|
@@ -76,7 +76,6 @@ def get_function(
|
|
|
76
76
|
identifier: str,
|
|
77
77
|
project: str | None = None,
|
|
78
78
|
entity_id: str | None = None,
|
|
79
|
-
**kwargs,
|
|
80
79
|
) -> Function:
|
|
81
80
|
"""
|
|
82
81
|
Get object from backend.
|
|
@@ -89,8 +88,6 @@ def get_function(
|
|
|
89
88
|
Project name.
|
|
90
89
|
entity_id : str
|
|
91
90
|
Entity ID.
|
|
92
|
-
**kwargs : dict
|
|
93
|
-
Parameters to pass to the API call.
|
|
94
91
|
|
|
95
92
|
Returns
|
|
96
93
|
-------
|
|
@@ -108,18 +105,16 @@ def get_function(
|
|
|
108
105
|
>>> entity_id="my-function-id")
|
|
109
106
|
"""
|
|
110
107
|
return context_processor.read_context_entity(
|
|
111
|
-
identifier,
|
|
108
|
+
identifier=identifier,
|
|
112
109
|
entity_type=ENTITY_TYPE,
|
|
113
110
|
project=project,
|
|
114
111
|
entity_id=entity_id,
|
|
115
|
-
**kwargs,
|
|
116
112
|
)
|
|
117
113
|
|
|
118
114
|
|
|
119
115
|
def get_function_versions(
|
|
120
116
|
identifier: str,
|
|
121
117
|
project: str | None = None,
|
|
122
|
-
**kwargs,
|
|
123
118
|
) -> list[Function]:
|
|
124
119
|
"""
|
|
125
120
|
Get object versions from backend.
|
|
@@ -130,8 +125,6 @@ def get_function_versions(
|
|
|
130
125
|
Entity key (store://...) or entity name.
|
|
131
126
|
project : str
|
|
132
127
|
Project name.
|
|
133
|
-
**kwargs : dict
|
|
134
|
-
Parameters to pass to the API call.
|
|
135
128
|
|
|
136
129
|
Returns
|
|
137
130
|
-------
|
|
@@ -148,14 +141,23 @@ def get_function_versions(
|
|
|
148
141
|
>>> project="my-project")
|
|
149
142
|
"""
|
|
150
143
|
return context_processor.read_context_entity_versions(
|
|
151
|
-
identifier,
|
|
144
|
+
identifier=identifier,
|
|
152
145
|
entity_type=ENTITY_TYPE,
|
|
153
146
|
project=project,
|
|
154
|
-
**kwargs,
|
|
155
147
|
)
|
|
156
148
|
|
|
157
149
|
|
|
158
|
-
def list_functions(
|
|
150
|
+
def list_functions(
|
|
151
|
+
project: str,
|
|
152
|
+
q: str | None = None,
|
|
153
|
+
name: str | None = None,
|
|
154
|
+
kind: str | None = None,
|
|
155
|
+
user: str | None = None,
|
|
156
|
+
state: str | None = None,
|
|
157
|
+
created: str | None = None,
|
|
158
|
+
updated: str | None = None,
|
|
159
|
+
version: str | None = None,
|
|
160
|
+
) -> list[Function]:
|
|
159
161
|
"""
|
|
160
162
|
List all latest version objects from backend.
|
|
161
163
|
|
|
@@ -163,8 +165,22 @@ def list_functions(project: str, **kwargs) -> list[Function]:
|
|
|
163
165
|
----------
|
|
164
166
|
project : str
|
|
165
167
|
Project name.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
q : str
|
|
169
|
+
Query string to filter objects.
|
|
170
|
+
name : str
|
|
171
|
+
Object name.
|
|
172
|
+
kind : str
|
|
173
|
+
Kind of the object.
|
|
174
|
+
user : str
|
|
175
|
+
User that created the object.
|
|
176
|
+
state : str
|
|
177
|
+
Object state.
|
|
178
|
+
created : str
|
|
179
|
+
Creation date filter.
|
|
180
|
+
updated : str
|
|
181
|
+
Update date filter.
|
|
182
|
+
version : str
|
|
183
|
+
Object version, default is latest.
|
|
168
184
|
|
|
169
185
|
Returns
|
|
170
186
|
-------
|
|
@@ -178,18 +194,36 @@ def list_functions(project: str, **kwargs) -> list[Function]:
|
|
|
178
194
|
return context_processor.list_context_entities(
|
|
179
195
|
project=project,
|
|
180
196
|
entity_type=ENTITY_TYPE,
|
|
181
|
-
|
|
197
|
+
q=q,
|
|
198
|
+
name=name,
|
|
199
|
+
kind=kind,
|
|
200
|
+
user=user,
|
|
201
|
+
state=state,
|
|
202
|
+
created=created,
|
|
203
|
+
updated=updated,
|
|
204
|
+
version=version,
|
|
182
205
|
)
|
|
183
206
|
|
|
184
207
|
|
|
185
|
-
def import_function(
|
|
208
|
+
def import_function(
|
|
209
|
+
file: str | None = None,
|
|
210
|
+
key: str | None = None,
|
|
211
|
+
reset_id: bool = False,
|
|
212
|
+
context: str | None = None,
|
|
213
|
+
) -> Function:
|
|
186
214
|
"""
|
|
187
|
-
Import object from a YAML file
|
|
215
|
+
Import an object from a YAML file or from a storage key.
|
|
188
216
|
|
|
189
217
|
Parameters
|
|
190
218
|
----------
|
|
191
219
|
file : str
|
|
192
|
-
Path to YAML file.
|
|
220
|
+
Path to the YAML file.
|
|
221
|
+
key : str
|
|
222
|
+
Entity key (store://...).
|
|
223
|
+
reset_id : bool
|
|
224
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
225
|
+
context : str
|
|
226
|
+
Project name to use for context resolution.
|
|
193
227
|
|
|
194
228
|
Returns
|
|
195
229
|
-------
|
|
@@ -200,7 +234,7 @@ def import_function(file: str) -> Function:
|
|
|
200
234
|
--------
|
|
201
235
|
>>> obj = import_function("my-function.yaml")
|
|
202
236
|
"""
|
|
203
|
-
return context_processor.import_executable_entity(file)
|
|
237
|
+
return context_processor.import_executable_entity(file, key, reset_id, context)
|
|
204
238
|
|
|
205
239
|
|
|
206
240
|
def load_function(file: str) -> Function:
|
|
@@ -256,7 +290,6 @@ def delete_function(
|
|
|
256
290
|
entity_id: str | None = None,
|
|
257
291
|
delete_all_versions: bool = False,
|
|
258
292
|
cascade: bool = True,
|
|
259
|
-
**kwargs,
|
|
260
293
|
) -> dict:
|
|
261
294
|
"""
|
|
262
295
|
Delete object from backend.
|
|
@@ -270,11 +303,10 @@ def delete_function(
|
|
|
270
303
|
entity_id : str
|
|
271
304
|
Entity ID.
|
|
272
305
|
delete_all_versions : bool
|
|
273
|
-
Delete all versions of the named entity.
|
|
306
|
+
Delete all versions of the named entity.
|
|
307
|
+
If True, use entity name instead of entity key as identifier.
|
|
274
308
|
cascade : bool
|
|
275
309
|
Cascade delete.
|
|
276
|
-
**kwargs : dict
|
|
277
|
-
Parameters to pass to the API call.
|
|
278
310
|
|
|
279
311
|
Returns
|
|
280
312
|
-------
|
|
@@ -298,5 +330,4 @@ def delete_function(
|
|
|
298
330
|
entity_id=entity_id,
|
|
299
331
|
delete_all_versions=delete_all_versions,
|
|
300
332
|
cascade=cascade,
|
|
301
|
-
**kwargs,
|
|
302
333
|
)
|
|
@@ -9,7 +9,7 @@ import typing
|
|
|
9
9
|
from digitalhub.entities._base.material.entity import MaterialEntity
|
|
10
10
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
11
11
|
from digitalhub.entities._commons.metrics import MetricType, set_metrics, validate_metric_value
|
|
12
|
-
from digitalhub.entities._processors.
|
|
12
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
13
13
|
|
|
14
14
|
if typing.TYPE_CHECKING:
|
|
15
15
|
from digitalhub.entities._base.entity.metadata import Metadata
|
|
@@ -81,10 +81,6 @@ class Model(MaterialEntity):
|
|
|
81
81
|
single_value : bool
|
|
82
82
|
If True, value is a single value.
|
|
83
83
|
|
|
84
|
-
Returns
|
|
85
|
-
-------
|
|
86
|
-
None
|
|
87
|
-
|
|
88
84
|
Examples
|
|
89
85
|
--------
|
|
90
86
|
Log a new value in a list
|
|
@@ -94,13 +90,27 @@ class Model(MaterialEntity):
|
|
|
94
90
|
>>> entity.log_metric("loss", 0.0019)
|
|
95
91
|
|
|
96
92
|
Log a list of values and append them to existing metric:
|
|
97
|
-
>>> entity.log_metric(
|
|
93
|
+
>>> entity.log_metric(
|
|
94
|
+
... "loss",
|
|
95
|
+
... [
|
|
96
|
+
... 0.0018,
|
|
97
|
+
... 0.0015,
|
|
98
|
+
... ],
|
|
99
|
+
... )
|
|
98
100
|
|
|
99
101
|
Log a single value (not represented as list):
|
|
100
|
-
>>> entity.log_metric(
|
|
102
|
+
>>> entity.log_metric(
|
|
103
|
+
... "accuracy",
|
|
104
|
+
... 0.9,
|
|
105
|
+
... single_value=True,
|
|
106
|
+
... )
|
|
101
107
|
|
|
102
108
|
Log a list of values and overwrite existing metric:
|
|
103
|
-
>>> entity.log_metric(
|
|
109
|
+
>>> entity.log_metric(
|
|
110
|
+
... "accuracy",
|
|
111
|
+
... [0.8, 0.9],
|
|
112
|
+
... overwrite=True,
|
|
113
|
+
... )
|
|
104
114
|
"""
|
|
105
115
|
self._set_metrics(key, value, overwrite, single_value)
|
|
106
116
|
context_processor.update_metric(self.project, self.ENTITY_TYPE, self.id, key, self.status.metrics[key])
|
|
@@ -121,19 +131,59 @@ class Model(MaterialEntity):
|
|
|
121
131
|
overwrite : bool
|
|
122
132
|
If True, overwrite existing metrics.
|
|
123
133
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
134
|
+
Examples
|
|
135
|
+
--------
|
|
136
|
+
Log multiple metrics at once
|
|
137
|
+
>>> entity.log_metrics(
|
|
138
|
+
... {
|
|
139
|
+
... "loss": 0.002,
|
|
140
|
+
... "accuracy": 0.95,
|
|
141
|
+
... }
|
|
142
|
+
... )
|
|
143
|
+
|
|
144
|
+
Log metrics with lists and single values
|
|
145
|
+
>>> entity.log_metrics(
|
|
146
|
+
... {
|
|
147
|
+
... "loss": [
|
|
148
|
+
... 0.1,
|
|
149
|
+
... 0.05,
|
|
150
|
+
... ],
|
|
151
|
+
... "epoch": 10,
|
|
152
|
+
... }
|
|
153
|
+
... )
|
|
154
|
+
|
|
155
|
+
Append to existing metrics (default behavior)
|
|
156
|
+
>>> entity.log_metrics(
|
|
157
|
+
... {
|
|
158
|
+
... "loss": 0.001,
|
|
159
|
+
... "accuracy": 0.96,
|
|
160
|
+
... }
|
|
161
|
+
... ) # Appends to existing
|
|
162
|
+
|
|
163
|
+
Overwrite existing metrics
|
|
164
|
+
>>> entity.log_metrics(
|
|
165
|
+
... {
|
|
166
|
+
... "loss": 0.0005,
|
|
167
|
+
... "accuracy": 0.98,
|
|
168
|
+
... },
|
|
169
|
+
... overwrite=True,
|
|
170
|
+
... )
|
|
127
171
|
|
|
128
172
|
See also
|
|
129
173
|
--------
|
|
130
174
|
log_metric
|
|
131
175
|
"""
|
|
132
176
|
for key, value in metrics.items():
|
|
177
|
+
# For lists, use log_metric which handles appending correctly
|
|
133
178
|
if isinstance(value, list):
|
|
134
179
|
self.log_metric(key, value, overwrite)
|
|
180
|
+
|
|
181
|
+
# For single values, check if we should append or create new
|
|
135
182
|
else:
|
|
136
|
-
|
|
183
|
+
if not overwrite and key in self.status.metrics:
|
|
184
|
+
self.log_metric(key, value)
|
|
185
|
+
else:
|
|
186
|
+
self.log_metric(key, value, overwrite, single_value=True)
|
|
137
187
|
|
|
138
188
|
##############################
|
|
139
189
|
# Helper methods
|
|
@@ -142,10 +192,6 @@ class Model(MaterialEntity):
|
|
|
142
192
|
def _get_metrics(self) -> None:
|
|
143
193
|
"""
|
|
144
194
|
Get model metrics from backend.
|
|
145
|
-
|
|
146
|
-
Returns
|
|
147
|
-
-------
|
|
148
|
-
None
|
|
149
195
|
"""
|
|
150
196
|
self.status.metrics = context_processor.read_metrics(
|
|
151
197
|
project=self.project,
|
|
@@ -173,10 +219,6 @@ class Model(MaterialEntity):
|
|
|
173
219
|
If True, overwrite existing metric.
|
|
174
220
|
single_value : bool
|
|
175
221
|
If True, value is a single value.
|
|
176
|
-
|
|
177
|
-
Returns
|
|
178
|
-
-------
|
|
179
|
-
None
|
|
180
222
|
"""
|
|
181
223
|
value = validate_metric_value(value)
|
|
182
224
|
self.status.metrics = set_metrics(
|
|
@@ -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.model.utils import eval_source, process_kwargs
|
|
12
12
|
from digitalhub.utils.types import SourcesOrListOfSources
|
|
13
13
|
|
|
@@ -131,7 +131,6 @@ def get_model(
|
|
|
131
131
|
identifier: str,
|
|
132
132
|
project: str | None = None,
|
|
133
133
|
entity_id: str | None = None,
|
|
134
|
-
**kwargs,
|
|
135
134
|
) -> Model:
|
|
136
135
|
"""
|
|
137
136
|
Get object from backend.
|
|
@@ -144,8 +143,6 @@ def get_model(
|
|
|
144
143
|
Project name.
|
|
145
144
|
entity_id : str
|
|
146
145
|
Entity ID.
|
|
147
|
-
**kwargs : dict
|
|
148
|
-
Parameters to pass to the API call.
|
|
149
146
|
|
|
150
147
|
Returns
|
|
151
148
|
-------
|
|
@@ -167,14 +164,12 @@ def get_model(
|
|
|
167
164
|
entity_type=ENTITY_TYPE,
|
|
168
165
|
project=project,
|
|
169
166
|
entity_id=entity_id,
|
|
170
|
-
**kwargs,
|
|
171
167
|
)
|
|
172
168
|
|
|
173
169
|
|
|
174
170
|
def get_model_versions(
|
|
175
171
|
identifier: str,
|
|
176
172
|
project: str | None = None,
|
|
177
|
-
**kwargs,
|
|
178
173
|
) -> list[Model]:
|
|
179
174
|
"""
|
|
180
175
|
Get object versions from backend.
|
|
@@ -185,8 +180,6 @@ def get_model_versions(
|
|
|
185
180
|
Entity key (store://...) or entity name.
|
|
186
181
|
project : str
|
|
187
182
|
Project name.
|
|
188
|
-
**kwargs : dict
|
|
189
|
-
Parameters to pass to the API call.
|
|
190
183
|
|
|
191
184
|
Returns
|
|
192
185
|
-------
|
|
@@ -206,11 +199,20 @@ def get_model_versions(
|
|
|
206
199
|
identifier=identifier,
|
|
207
200
|
entity_type=ENTITY_TYPE,
|
|
208
201
|
project=project,
|
|
209
|
-
**kwargs,
|
|
210
202
|
)
|
|
211
203
|
|
|
212
204
|
|
|
213
|
-
def list_models(
|
|
205
|
+
def list_models(
|
|
206
|
+
project: str,
|
|
207
|
+
q: str | None = None,
|
|
208
|
+
name: str | None = None,
|
|
209
|
+
kind: str | None = None,
|
|
210
|
+
user: str | None = None,
|
|
211
|
+
state: str | None = None,
|
|
212
|
+
created: str | None = None,
|
|
213
|
+
updated: str | None = None,
|
|
214
|
+
version: str | None = None,
|
|
215
|
+
) -> list[Model]:
|
|
214
216
|
"""
|
|
215
217
|
List all latest version objects from backend.
|
|
216
218
|
|
|
@@ -218,8 +220,22 @@ def list_models(project: str, **kwargs) -> list[Model]:
|
|
|
218
220
|
----------
|
|
219
221
|
project : str
|
|
220
222
|
Project name.
|
|
221
|
-
|
|
222
|
-
|
|
223
|
+
q : str
|
|
224
|
+
Query string to filter objects.
|
|
225
|
+
name : str
|
|
226
|
+
Object name.
|
|
227
|
+
kind : str
|
|
228
|
+
Kind of the object.
|
|
229
|
+
user : str
|
|
230
|
+
User that created the object.
|
|
231
|
+
state : str
|
|
232
|
+
Object state.
|
|
233
|
+
created : str
|
|
234
|
+
Creation date filter.
|
|
235
|
+
updated : str
|
|
236
|
+
Update date filter.
|
|
237
|
+
version : str
|
|
238
|
+
Object version, default is latest.
|
|
223
239
|
|
|
224
240
|
Returns
|
|
225
241
|
-------
|
|
@@ -233,18 +249,36 @@ def list_models(project: str, **kwargs) -> list[Model]:
|
|
|
233
249
|
return context_processor.list_context_entities(
|
|
234
250
|
project=project,
|
|
235
251
|
entity_type=ENTITY_TYPE,
|
|
236
|
-
|
|
252
|
+
q=q,
|
|
253
|
+
name=name,
|
|
254
|
+
kind=kind,
|
|
255
|
+
user=user,
|
|
256
|
+
state=state,
|
|
257
|
+
created=created,
|
|
258
|
+
updated=updated,
|
|
259
|
+
version=version,
|
|
237
260
|
)
|
|
238
261
|
|
|
239
262
|
|
|
240
|
-
def import_model(
|
|
263
|
+
def import_model(
|
|
264
|
+
file: str | None = None,
|
|
265
|
+
key: str | None = None,
|
|
266
|
+
reset_id: bool = False,
|
|
267
|
+
context: str | None = None,
|
|
268
|
+
) -> Model:
|
|
241
269
|
"""
|
|
242
|
-
Import object from a YAML file
|
|
270
|
+
Import an object from a YAML file or from a storage key.
|
|
243
271
|
|
|
244
272
|
Parameters
|
|
245
273
|
----------
|
|
246
274
|
file : str
|
|
247
|
-
Path to YAML file.
|
|
275
|
+
Path to the YAML file.
|
|
276
|
+
key : str
|
|
277
|
+
Entity key (store://...).
|
|
278
|
+
reset_id : bool
|
|
279
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
280
|
+
context : str
|
|
281
|
+
Project name to use for context resolution.
|
|
248
282
|
|
|
249
283
|
Returns
|
|
250
284
|
-------
|
|
@@ -255,7 +289,12 @@ def import_model(file: str) -> Model:
|
|
|
255
289
|
--------
|
|
256
290
|
>>> obj = import_model("my-model.yaml")
|
|
257
291
|
"""
|
|
258
|
-
return context_processor.import_context_entity(
|
|
292
|
+
return context_processor.import_context_entity(
|
|
293
|
+
file,
|
|
294
|
+
key,
|
|
295
|
+
reset_id,
|
|
296
|
+
context,
|
|
297
|
+
)
|
|
259
298
|
|
|
260
299
|
|
|
261
300
|
def load_model(file: str) -> Model:
|
|
@@ -311,7 +350,6 @@ def delete_model(
|
|
|
311
350
|
entity_id: str | None = None,
|
|
312
351
|
delete_all_versions: bool = False,
|
|
313
352
|
cascade: bool = True,
|
|
314
|
-
**kwargs,
|
|
315
353
|
) -> dict:
|
|
316
354
|
"""
|
|
317
355
|
Delete object from backend.
|
|
@@ -325,11 +363,10 @@ def delete_model(
|
|
|
325
363
|
entity_id : str
|
|
326
364
|
Entity ID.
|
|
327
365
|
delete_all_versions : bool
|
|
328
|
-
Delete all versions of the named entity.
|
|
366
|
+
Delete all versions of the named entity.
|
|
367
|
+
If True, use entity name instead of entity key as identifier.
|
|
329
368
|
cascade : bool
|
|
330
369
|
Cascade delete.
|
|
331
|
-
**kwargs : dict
|
|
332
|
-
Parameters to pass to the API call.
|
|
333
370
|
|
|
334
371
|
Returns
|
|
335
372
|
-------
|
|
@@ -353,5 +390,4 @@ def delete_model(
|
|
|
353
390
|
entity_id=entity_id,
|
|
354
391
|
delete_all_versions=delete_all_versions,
|
|
355
392
|
cascade=cascade,
|
|
356
|
-
**kwargs,
|
|
357
393
|
)
|
|
@@ -6,9 +6,9 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
from typing import Any
|
|
8
8
|
|
|
9
|
-
from digitalhub.entities._base.entity._constructors.uuid import build_uuid
|
|
10
9
|
from digitalhub.entities._base.material.utils import build_log_path_from_source, eval_local_source
|
|
11
10
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
11
|
+
from digitalhub.entities._constructors.uuid import build_uuid
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def eval_source(
|
|
@@ -23,7 +23,7 @@ def eval_source(
|
|
|
23
23
|
|
|
24
24
|
Parameters
|
|
25
25
|
----------
|
|
26
|
-
source : str, list[str], or None
|
|
26
|
+
source : str, list[str], or None
|
|
27
27
|
The source specification(s) to evaluate. Can be a single
|
|
28
28
|
source string, a list of source strings, or None.
|
|
29
29
|
|
|
@@ -59,7 +59,7 @@ def process_kwargs(
|
|
|
59
59
|
source : str or list[str]
|
|
60
60
|
The source specification(s) for the model content.
|
|
61
61
|
Can be a single source or multiple sources.
|
|
62
|
-
path : str
|
|
62
|
+
path : str
|
|
63
63
|
The destination path for the model entity.
|
|
64
64
|
If None, a path will be automatically generated.
|
|
65
65
|
**kwargs : dict
|