digitalhub 0.13.0b3__py3-none-any.whl → 0.14.0b0__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/entities/_base/_base/entity.py +0 -11
- digitalhub/entities/_base/entity/builder.py +5 -5
- digitalhub/entities/_base/executable/entity.py +1 -1
- digitalhub/entities/_base/runtime_entity/builder.py +53 -18
- digitalhub/entities/_commons/metrics.py +64 -30
- digitalhub/entities/_commons/utils.py +100 -30
- digitalhub/entities/_processors/base.py +160 -81
- digitalhub/entities/_processors/context.py +424 -224
- digitalhub/entities/_processors/utils.py +77 -33
- digitalhub/entities/artifact/crud.py +20 -4
- digitalhub/entities/artifact/utils.py +29 -14
- digitalhub/entities/dataitem/crud.py +20 -4
- digitalhub/entities/dataitem/table/entity.py +0 -21
- digitalhub/entities/dataitem/utils.py +84 -34
- digitalhub/entities/function/_base/entity.py +1 -1
- digitalhub/entities/function/crud.py +15 -4
- digitalhub/entities/model/_base/entity.py +21 -1
- digitalhub/entities/model/crud.py +21 -5
- digitalhub/entities/model/utils.py +29 -14
- digitalhub/entities/project/_base/entity.py +65 -33
- digitalhub/entities/project/crud.py +8 -1
- digitalhub/entities/run/_base/entity.py +21 -1
- digitalhub/entities/run/crud.py +22 -5
- digitalhub/entities/secret/crud.py +22 -5
- digitalhub/entities/task/crud.py +22 -5
- digitalhub/entities/trigger/crud.py +20 -4
- digitalhub/entities/workflow/_base/entity.py +1 -1
- digitalhub/entities/workflow/crud.py +15 -4
- digitalhub/factory/enums.py +18 -0
- digitalhub/factory/factory.py +136 -57
- digitalhub/factory/utils.py +3 -54
- digitalhub/stores/client/api.py +6 -10
- digitalhub/stores/client/builder.py +3 -3
- digitalhub/stores/client/dhcore/client.py +104 -162
- digitalhub/stores/client/dhcore/configurator.py +92 -289
- digitalhub/stores/client/dhcore/enums.py +0 -16
- digitalhub/stores/client/dhcore/params_builder.py +41 -83
- digitalhub/stores/client/dhcore/utils.py +14 -22
- digitalhub/stores/client/local/client.py +77 -45
- digitalhub/stores/credentials/enums.py +1 -0
- digitalhub/stores/credentials/ini_module.py +0 -16
- digitalhub/stores/data/api.py +1 -1
- digitalhub/stores/data/builder.py +66 -4
- digitalhub/stores/data/local/store.py +0 -103
- digitalhub/stores/data/s3/configurator.py +60 -6
- digitalhub/stores/data/s3/store.py +44 -2
- digitalhub/stores/data/sql/configurator.py +57 -7
- digitalhub/stores/data/sql/store.py +184 -78
- digitalhub/utils/file_utils.py +0 -17
- digitalhub/utils/generic_utils.py +1 -2
- digitalhub/utils/store_utils.py +44 -0
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.0b0.dist-info}/METADATA +3 -2
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.0b0.dist-info}/RECORD +63 -65
- digitalhub/entities/_commons/types.py +0 -9
- digitalhub/entities/task/_base/utils.py +0 -22
- 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}/name.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.0b3.dist-info → digitalhub-0.14.0b0.dist-info}/WHEEL +0 -0
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.0b0.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.13.0b3.dist-info → digitalhub-0.14.0b0.dist-info}/licenses/LICENSE +0 -0
|
@@ -8,7 +8,7 @@ import typing
|
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
10
10
|
from digitalhub.entities._processors.context import context_processor
|
|
11
|
-
from digitalhub.entities.
|
|
11
|
+
from digitalhub.entities.model.utils import eval_source, process_kwargs
|
|
12
12
|
from digitalhub.utils.types import SourcesOrListOfSources
|
|
13
13
|
|
|
14
14
|
if typing.TYPE_CHECKING:
|
|
@@ -237,14 +237,25 @@ def list_models(project: str, **kwargs) -> list[Model]:
|
|
|
237
237
|
)
|
|
238
238
|
|
|
239
239
|
|
|
240
|
-
def import_model(
|
|
240
|
+
def import_model(
|
|
241
|
+
file: str | None = None,
|
|
242
|
+
key: str | None = None,
|
|
243
|
+
reset_id: bool = False,
|
|
244
|
+
context: str | None = None,
|
|
245
|
+
) -> Model:
|
|
241
246
|
"""
|
|
242
|
-
Import object from a YAML file
|
|
247
|
+
Import an object from a YAML file or from a storage key.
|
|
243
248
|
|
|
244
249
|
Parameters
|
|
245
250
|
----------
|
|
246
251
|
file : str
|
|
247
|
-
Path to YAML file.
|
|
252
|
+
Path to the YAML file.
|
|
253
|
+
key : str
|
|
254
|
+
Entity key (store://...).
|
|
255
|
+
reset_id : bool
|
|
256
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
257
|
+
context : str
|
|
258
|
+
Project name to use for context resolution.
|
|
248
259
|
|
|
249
260
|
Returns
|
|
250
261
|
-------
|
|
@@ -255,7 +266,12 @@ def import_model(file: str) -> Model:
|
|
|
255
266
|
--------
|
|
256
267
|
>>> obj = import_model("my-model.yaml")
|
|
257
268
|
"""
|
|
258
|
-
return context_processor.import_context_entity(
|
|
269
|
+
return context_processor.import_context_entity(
|
|
270
|
+
file,
|
|
271
|
+
key,
|
|
272
|
+
reset_id,
|
|
273
|
+
context,
|
|
274
|
+
)
|
|
259
275
|
|
|
260
276
|
|
|
261
277
|
def load_model(file: str) -> Model:
|
|
@@ -6,25 +6,32 @@ 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(
|
|
15
15
|
source: str | list[str] | None = None,
|
|
16
16
|
) -> Any:
|
|
17
17
|
"""
|
|
18
|
-
Evaluate
|
|
18
|
+
Evaluate whether the source is local or remote.
|
|
19
|
+
|
|
20
|
+
Determines if the provided source(s) reference local files or
|
|
21
|
+
remote resources. This evaluation affects how the model
|
|
22
|
+
will be processed and stored.
|
|
19
23
|
|
|
20
24
|
Parameters
|
|
21
25
|
----------
|
|
22
|
-
source : str
|
|
23
|
-
|
|
26
|
+
source : str, list[str], or None, optional
|
|
27
|
+
The source specification(s) to evaluate. Can be a single
|
|
28
|
+
source string, a list of source strings, or None.
|
|
24
29
|
|
|
25
30
|
Returns
|
|
26
31
|
-------
|
|
27
|
-
|
|
32
|
+
Any
|
|
33
|
+
The result of the local source evaluation, indicating
|
|
34
|
+
whether the source is local or remote.
|
|
28
35
|
"""
|
|
29
36
|
return eval_local_source(source)
|
|
30
37
|
|
|
@@ -37,25 +44,33 @@ def process_kwargs(
|
|
|
37
44
|
**kwargs,
|
|
38
45
|
) -> dict:
|
|
39
46
|
"""
|
|
40
|
-
Process
|
|
47
|
+
Process and enhance specification parameters for model creation.
|
|
48
|
+
|
|
49
|
+
Processes the keyword arguments for model specification, handling
|
|
50
|
+
path generation and UUID assignment. If no path is provided, generates
|
|
51
|
+
a unique path based on project, entity type, name, and source.
|
|
41
52
|
|
|
42
53
|
Parameters
|
|
43
54
|
----------
|
|
44
55
|
project : str
|
|
45
|
-
|
|
56
|
+
The name of the project containing the model.
|
|
46
57
|
name : str
|
|
47
|
-
|
|
48
|
-
source : str
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
The name of the model entity.
|
|
59
|
+
source : str or list[str]
|
|
60
|
+
The source specification(s) for the model content.
|
|
61
|
+
Can be a single source or multiple sources.
|
|
62
|
+
path : str, optional
|
|
63
|
+
The destination path for the model entity.
|
|
64
|
+
If None, a path will be automatically generated.
|
|
52
65
|
**kwargs : dict
|
|
53
|
-
|
|
66
|
+
Additional specification parameters to be processed
|
|
67
|
+
and passed to the model creation.
|
|
54
68
|
|
|
55
69
|
Returns
|
|
56
70
|
-------
|
|
57
71
|
dict
|
|
58
|
-
|
|
72
|
+
The updated kwargs dictionary with processed path
|
|
73
|
+
and UUID information included.
|
|
59
74
|
"""
|
|
60
75
|
if path is None:
|
|
61
76
|
uuid = build_uuid()
|
|
@@ -11,6 +11,7 @@ from typing import Any
|
|
|
11
11
|
from digitalhub.context.api import build_context
|
|
12
12
|
from digitalhub.entities._base.entity.entity import Entity
|
|
13
13
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
14
|
+
from digitalhub.entities._constructors.uuid import build_uuid
|
|
14
15
|
from digitalhub.entities._processors.base import base_processor
|
|
15
16
|
from digitalhub.entities._processors.context import context_processor
|
|
16
17
|
from digitalhub.entities.artifact.crud import (
|
|
@@ -290,7 +291,7 @@ class Project(Entity):
|
|
|
290
291
|
# Return updated object
|
|
291
292
|
return obj
|
|
292
293
|
|
|
293
|
-
def _import_entities(self, obj: dict) -> None:
|
|
294
|
+
def _import_entities(self, obj: dict, reset_id: bool = False) -> None:
|
|
294
295
|
"""
|
|
295
296
|
Import project entities.
|
|
296
297
|
|
|
@@ -319,11 +320,19 @@ class Project(Entity):
|
|
|
319
320
|
try:
|
|
320
321
|
# Artifacts, Dataitems and Models
|
|
321
322
|
if entity_type in entity_types[:3]:
|
|
322
|
-
context_processor.import_context_entity(
|
|
323
|
+
context_processor.import_context_entity(
|
|
324
|
+
file=ref,
|
|
325
|
+
reset_id=reset_id,
|
|
326
|
+
context=self.name,
|
|
327
|
+
)
|
|
323
328
|
|
|
324
329
|
# Functions and Workflows
|
|
325
330
|
elif entity_type in entity_types[3:]:
|
|
326
|
-
context_processor.import_executable_entity(
|
|
331
|
+
context_processor.import_executable_entity(
|
|
332
|
+
file=ref,
|
|
333
|
+
reset_id=reset_id,
|
|
334
|
+
context=self.name,
|
|
335
|
+
)
|
|
327
336
|
|
|
328
337
|
except FileNotFoundError:
|
|
329
338
|
msg = f"File not found: {ref}."
|
|
@@ -335,6 +344,11 @@ class Project(Entity):
|
|
|
335
344
|
if entity["metadata"].get("embedded") is None:
|
|
336
345
|
entity["metadata"]["embedded"] = True
|
|
337
346
|
|
|
347
|
+
if reset_id:
|
|
348
|
+
new_id = build_uuid()
|
|
349
|
+
entity["id"] = new_id
|
|
350
|
+
entity["metadata"]["version"] = new_id
|
|
351
|
+
|
|
338
352
|
try:
|
|
339
353
|
factory.build_entity_from_dict(entity).save()
|
|
340
354
|
except EntityAlreadyExistsError:
|
|
@@ -616,8 +630,9 @@ class Project(Entity):
|
|
|
616
630
|
|
|
617
631
|
def import_artifact(
|
|
618
632
|
self,
|
|
619
|
-
file: str,
|
|
620
|
-
|
|
633
|
+
file: str | None = None,
|
|
634
|
+
key: str | None = None,
|
|
635
|
+
reset_id: bool = True,
|
|
621
636
|
) -> Artifact:
|
|
622
637
|
"""
|
|
623
638
|
Import object from a YAML file and create a new object into the backend.
|
|
@@ -626,8 +641,10 @@ class Project(Entity):
|
|
|
626
641
|
----------
|
|
627
642
|
file : str
|
|
628
643
|
Path to YAML file.
|
|
629
|
-
|
|
630
|
-
|
|
644
|
+
key : str
|
|
645
|
+
Entity key (store://...).
|
|
646
|
+
reset_id : bool
|
|
647
|
+
Flag to determine if the ID of context entities should be reset.
|
|
631
648
|
|
|
632
649
|
Returns
|
|
633
650
|
-------
|
|
@@ -638,7 +655,7 @@ class Project(Entity):
|
|
|
638
655
|
--------
|
|
639
656
|
>>> obj = project.import_artifact("my-artifact.yaml")
|
|
640
657
|
"""
|
|
641
|
-
return import_artifact(file,
|
|
658
|
+
return import_artifact(file, key, reset_id, self.name)
|
|
642
659
|
|
|
643
660
|
def update_artifact(self, entity: Artifact) -> Artifact:
|
|
644
661
|
"""
|
|
@@ -919,8 +936,9 @@ class Project(Entity):
|
|
|
919
936
|
|
|
920
937
|
def import_dataitem(
|
|
921
938
|
self,
|
|
922
|
-
file: str,
|
|
923
|
-
|
|
939
|
+
file: str | None = None,
|
|
940
|
+
key: str | None = None,
|
|
941
|
+
reset_id: bool = True,
|
|
924
942
|
) -> Dataitem:
|
|
925
943
|
"""
|
|
926
944
|
Import object from a YAML file and create a new object into the backend.
|
|
@@ -929,8 +947,10 @@ class Project(Entity):
|
|
|
929
947
|
----------
|
|
930
948
|
file : str
|
|
931
949
|
Path to YAML file.
|
|
932
|
-
|
|
933
|
-
|
|
950
|
+
key : str
|
|
951
|
+
Entity key (store://...).
|
|
952
|
+
reset_id : bool
|
|
953
|
+
Flag to determine if the ID of context entities should be reset.
|
|
934
954
|
|
|
935
955
|
Returns
|
|
936
956
|
-------
|
|
@@ -941,7 +961,7 @@ class Project(Entity):
|
|
|
941
961
|
--------
|
|
942
962
|
>>> obj = project.import_dataitem("my-dataitem.yaml")
|
|
943
963
|
"""
|
|
944
|
-
return import_dataitem(file,
|
|
964
|
+
return import_dataitem(file, key, reset_id, self.name)
|
|
945
965
|
|
|
946
966
|
def update_dataitem(self, entity: Dataitem) -> Dataitem:
|
|
947
967
|
"""
|
|
@@ -1211,8 +1231,9 @@ class Project(Entity):
|
|
|
1211
1231
|
|
|
1212
1232
|
def import_model(
|
|
1213
1233
|
self,
|
|
1214
|
-
file: str,
|
|
1215
|
-
|
|
1234
|
+
file: str | None = None,
|
|
1235
|
+
key: str | None = None,
|
|
1236
|
+
reset_id: bool = True,
|
|
1216
1237
|
) -> Model:
|
|
1217
1238
|
"""
|
|
1218
1239
|
Import object from a YAML file and create a new object into the backend.
|
|
@@ -1221,8 +1242,10 @@ class Project(Entity):
|
|
|
1221
1242
|
----------
|
|
1222
1243
|
file : str
|
|
1223
1244
|
Path to YAML file.
|
|
1224
|
-
|
|
1225
|
-
|
|
1245
|
+
key : str
|
|
1246
|
+
Entity key (store://...).
|
|
1247
|
+
reset_id : bool
|
|
1248
|
+
Flag to determine if the ID of context entities should be reset.
|
|
1226
1249
|
|
|
1227
1250
|
Returns
|
|
1228
1251
|
-------
|
|
@@ -1233,7 +1256,7 @@ class Project(Entity):
|
|
|
1233
1256
|
--------
|
|
1234
1257
|
>>> obj = project.import_model("my-model.yaml")
|
|
1235
1258
|
"""
|
|
1236
|
-
return import_model(file,
|
|
1259
|
+
return import_model(file, key, reset_id, self.name)
|
|
1237
1260
|
|
|
1238
1261
|
def update_model(self, entity: Model) -> Model:
|
|
1239
1262
|
"""
|
|
@@ -1454,8 +1477,9 @@ class Project(Entity):
|
|
|
1454
1477
|
|
|
1455
1478
|
def import_function(
|
|
1456
1479
|
self,
|
|
1457
|
-
file: str,
|
|
1458
|
-
|
|
1480
|
+
file: str | None = None,
|
|
1481
|
+
key: str | None = None,
|
|
1482
|
+
reset_id: bool = True,
|
|
1459
1483
|
) -> Function:
|
|
1460
1484
|
"""
|
|
1461
1485
|
Import object from a YAML file and create a new object into the backend.
|
|
@@ -1464,8 +1488,10 @@ class Project(Entity):
|
|
|
1464
1488
|
----------
|
|
1465
1489
|
file : str
|
|
1466
1490
|
Path to YAML file.
|
|
1467
|
-
|
|
1468
|
-
|
|
1491
|
+
key : str
|
|
1492
|
+
Entity key (store://...).
|
|
1493
|
+
reset_id : bool
|
|
1494
|
+
Flag to determine if the ID of context entities should be reset.
|
|
1469
1495
|
|
|
1470
1496
|
Returns
|
|
1471
1497
|
-------
|
|
@@ -1476,7 +1502,7 @@ class Project(Entity):
|
|
|
1476
1502
|
--------
|
|
1477
1503
|
>>> obj = project.import_function("my-function.yaml")
|
|
1478
1504
|
"""
|
|
1479
|
-
return import_function(file,
|
|
1505
|
+
return import_function(file, key, reset_id, self.name)
|
|
1480
1506
|
|
|
1481
1507
|
def update_function(self, entity: Function) -> Function:
|
|
1482
1508
|
"""
|
|
@@ -1700,8 +1726,9 @@ class Project(Entity):
|
|
|
1700
1726
|
|
|
1701
1727
|
def import_workflow(
|
|
1702
1728
|
self,
|
|
1703
|
-
file: str,
|
|
1704
|
-
|
|
1729
|
+
file: str | None = None,
|
|
1730
|
+
key: str | None = None,
|
|
1731
|
+
reset_id: bool = True,
|
|
1705
1732
|
) -> Workflow:
|
|
1706
1733
|
"""
|
|
1707
1734
|
Import object from a YAML file and create a new object into the backend.
|
|
@@ -1710,8 +1737,10 @@ class Project(Entity):
|
|
|
1710
1737
|
----------
|
|
1711
1738
|
file : str
|
|
1712
1739
|
Path to YAML file.
|
|
1713
|
-
|
|
1714
|
-
|
|
1740
|
+
key : str
|
|
1741
|
+
Entity key (store://...).
|
|
1742
|
+
reset_id : bool
|
|
1743
|
+
Flag to determine if the ID of context entities should be reset.
|
|
1715
1744
|
|
|
1716
1745
|
Returns
|
|
1717
1746
|
-------
|
|
@@ -1722,7 +1751,7 @@ class Project(Entity):
|
|
|
1722
1751
|
--------
|
|
1723
1752
|
>>> obj = project.import_workflow("my-workflow.yaml")
|
|
1724
1753
|
"""
|
|
1725
|
-
return import_workflow(file,
|
|
1754
|
+
return import_workflow(file, key, reset_id, self.name)
|
|
1726
1755
|
|
|
1727
1756
|
def update_workflow(self, entity: Workflow) -> Workflow:
|
|
1728
1757
|
"""
|
|
@@ -1944,8 +1973,9 @@ class Project(Entity):
|
|
|
1944
1973
|
|
|
1945
1974
|
def import_secret(
|
|
1946
1975
|
self,
|
|
1947
|
-
file: str,
|
|
1948
|
-
|
|
1976
|
+
file: str | None = None,
|
|
1977
|
+
key: str | None = None,
|
|
1978
|
+
reset_id: bool = True,
|
|
1949
1979
|
) -> Secret:
|
|
1950
1980
|
"""
|
|
1951
1981
|
Import object from a YAML file and create a new object into the backend.
|
|
@@ -1954,8 +1984,10 @@ class Project(Entity):
|
|
|
1954
1984
|
----------
|
|
1955
1985
|
file : str
|
|
1956
1986
|
Path to YAML file.
|
|
1957
|
-
|
|
1958
|
-
|
|
1987
|
+
key : str
|
|
1988
|
+
Entity key (store://...).
|
|
1989
|
+
reset_id : bool
|
|
1990
|
+
Flag to determine if the ID of context entities should be reset.
|
|
1959
1991
|
|
|
1960
1992
|
Returns
|
|
1961
1993
|
-------
|
|
@@ -1966,7 +1998,7 @@ class Project(Entity):
|
|
|
1966
1998
|
--------
|
|
1967
1999
|
>>> obj = project.import_secret("my-secret.yaml")
|
|
1968
2000
|
"""
|
|
1969
|
-
return import_secret(file,
|
|
2001
|
+
return import_secret(file, key, reset_id, self.name)
|
|
1970
2002
|
|
|
1971
2003
|
def update_secret(self, entity: Secret) -> Secret:
|
|
1972
2004
|
"""
|
|
@@ -118,6 +118,7 @@ def import_project(
|
|
|
118
118
|
file: str,
|
|
119
119
|
local: bool = False,
|
|
120
120
|
setup_kwargs: dict | None = None,
|
|
121
|
+
reset_id: bool = False,
|
|
121
122
|
) -> Project:
|
|
122
123
|
"""
|
|
123
124
|
Import object from a YAML file and create a new object into the backend.
|
|
@@ -130,6 +131,8 @@ def import_project(
|
|
|
130
131
|
Flag to determine if backend is local.
|
|
131
132
|
setup_kwargs : dict
|
|
132
133
|
Setup keyword arguments passed to setup_project() function.
|
|
134
|
+
reset_id : bool
|
|
135
|
+
Flag to determine if the ID of project entities should be reset.
|
|
133
136
|
|
|
134
137
|
Returns
|
|
135
138
|
-------
|
|
@@ -140,7 +143,11 @@ def import_project(
|
|
|
140
143
|
--------
|
|
141
144
|
>>> obj = import_project("my-project.yaml")
|
|
142
145
|
"""
|
|
143
|
-
obj = base_processor.import_project_entity(
|
|
146
|
+
obj = base_processor.import_project_entity(
|
|
147
|
+
file=file,
|
|
148
|
+
local=local,
|
|
149
|
+
reset_id=reset_id,
|
|
150
|
+
)
|
|
144
151
|
return setup_project(obj, setup_kwargs)
|
|
145
152
|
|
|
146
153
|
|
|
@@ -228,15 +228,35 @@ class Run(UnversionedEntity):
|
|
|
228
228
|
-------
|
|
229
229
|
None
|
|
230
230
|
|
|
231
|
+
Examples
|
|
232
|
+
--------
|
|
233
|
+
Log multiple metrics at once
|
|
234
|
+
>>> entity.log_metrics({"loss": 0.002, "accuracy": 0.95})
|
|
235
|
+
|
|
236
|
+
Log metrics with lists and single values
|
|
237
|
+
>>> entity.log_metrics({"loss": [0.1, 0.05], "epoch": 10})
|
|
238
|
+
|
|
239
|
+
Append to existing metrics (default behavior)
|
|
240
|
+
>>> entity.log_metrics({"loss": 0.001, "accuracy": 0.96}) # Appends to existing
|
|
241
|
+
|
|
242
|
+
Overwrite existing metrics
|
|
243
|
+
>>> entity.log_metrics({"loss": 0.0005, "accuracy": 0.98}, overwrite=True)
|
|
244
|
+
|
|
231
245
|
See also
|
|
232
246
|
--------
|
|
233
247
|
log_metric
|
|
234
248
|
"""
|
|
235
249
|
for key, value in metrics.items():
|
|
250
|
+
# For lists, use log_metric which handles appending correctly
|
|
236
251
|
if isinstance(value, list):
|
|
237
252
|
self.log_metric(key, value, overwrite)
|
|
253
|
+
|
|
254
|
+
# For single values, check if we should append or create new
|
|
238
255
|
else:
|
|
239
|
-
|
|
256
|
+
if not overwrite and key in self.status.metrics:
|
|
257
|
+
self.log_metric(key, value)
|
|
258
|
+
else:
|
|
259
|
+
self.log_metric(key, value, overwrite, single_value=True)
|
|
240
260
|
|
|
241
261
|
##############################
|
|
242
262
|
# Helpers
|
digitalhub/entities/run/crud.py
CHANGED
|
@@ -7,6 +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._commons.utils import is_valid_key
|
|
10
11
|
from digitalhub.entities._processors.context import context_processor
|
|
11
12
|
from digitalhub.utils.exceptions import EntityError
|
|
12
13
|
|
|
@@ -135,14 +136,25 @@ def list_runs(project: str, **kwargs) -> list[Run]:
|
|
|
135
136
|
)
|
|
136
137
|
|
|
137
138
|
|
|
138
|
-
def import_run(
|
|
139
|
+
def import_run(
|
|
140
|
+
file: str | None = None,
|
|
141
|
+
key: str | None = None,
|
|
142
|
+
reset_id: bool = False,
|
|
143
|
+
context: str | None = None,
|
|
144
|
+
) -> Run:
|
|
139
145
|
"""
|
|
140
|
-
Import object from a YAML file
|
|
146
|
+
Import an object from a YAML file or from a storage key.
|
|
141
147
|
|
|
142
148
|
Parameters
|
|
143
149
|
----------
|
|
144
150
|
file : str
|
|
145
|
-
Path to YAML file.
|
|
151
|
+
Path to the YAML file.
|
|
152
|
+
key : str
|
|
153
|
+
Entity key (store://...).
|
|
154
|
+
reset_id : bool
|
|
155
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
156
|
+
context : str
|
|
157
|
+
Project name to use for context resolution.
|
|
146
158
|
|
|
147
159
|
Returns
|
|
148
160
|
-------
|
|
@@ -153,7 +165,12 @@ def import_run(file: str) -> Run:
|
|
|
153
165
|
-------
|
|
154
166
|
>>> obj = import_run("my-run.yaml")
|
|
155
167
|
"""
|
|
156
|
-
return context_processor.import_context_entity(
|
|
168
|
+
return context_processor.import_context_entity(
|
|
169
|
+
file,
|
|
170
|
+
key,
|
|
171
|
+
reset_id,
|
|
172
|
+
context,
|
|
173
|
+
)
|
|
157
174
|
|
|
158
175
|
|
|
159
176
|
def load_run(file: str) -> Run:
|
|
@@ -230,7 +247,7 @@ def delete_run(
|
|
|
230
247
|
>>> obj = delete_run("store://my-run-key")
|
|
231
248
|
>>> obj = delete_run("my-run-id", project="my-project")
|
|
232
249
|
"""
|
|
233
|
-
if not identifier
|
|
250
|
+
if not is_valid_key(identifier) and project is None:
|
|
234
251
|
raise EntityError("Specify entity key or entity ID combined with project")
|
|
235
252
|
return context_processor.delete_context_entity(
|
|
236
253
|
identifier=identifier,
|
|
@@ -7,6 +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._commons.utils import is_valid_key
|
|
10
11
|
from digitalhub.entities._processors.context import context_processor
|
|
11
12
|
from digitalhub.utils.exceptions import EntityNotExistsError
|
|
12
13
|
|
|
@@ -111,7 +112,7 @@ def get_secret(
|
|
|
111
112
|
>>> project="my-project",
|
|
112
113
|
>>> entity_id="my-secret-id")
|
|
113
114
|
"""
|
|
114
|
-
if not identifier
|
|
115
|
+
if not is_valid_key(identifier):
|
|
115
116
|
if project is None:
|
|
116
117
|
raise ValueError("Project must be provided.")
|
|
117
118
|
secrets = list_secrets(project=project, **kwargs)
|
|
@@ -195,14 +196,25 @@ def list_secrets(project: str, **kwargs) -> list[Secret]:
|
|
|
195
196
|
)
|
|
196
197
|
|
|
197
198
|
|
|
198
|
-
def import_secret(
|
|
199
|
+
def import_secret(
|
|
200
|
+
file: str | None = None,
|
|
201
|
+
key: str | None = None,
|
|
202
|
+
reset_id: bool = False,
|
|
203
|
+
context: str | None = None,
|
|
204
|
+
) -> Secret:
|
|
199
205
|
"""
|
|
200
|
-
Import object from a YAML file
|
|
206
|
+
Import an object from a YAML file or from a storage key.
|
|
201
207
|
|
|
202
208
|
Parameters
|
|
203
209
|
----------
|
|
204
210
|
file : str
|
|
205
|
-
Path to YAML file.
|
|
211
|
+
Path to the YAML file.
|
|
212
|
+
key : str
|
|
213
|
+
Entity key (store://...).
|
|
214
|
+
reset_id : bool
|
|
215
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
216
|
+
context : str
|
|
217
|
+
Project name to use for context resolution.
|
|
206
218
|
|
|
207
219
|
Returns
|
|
208
220
|
-------
|
|
@@ -213,7 +225,12 @@ def import_secret(file: str) -> Secret:
|
|
|
213
225
|
--------
|
|
214
226
|
>>> obj = import_secret("my-secret.yaml")
|
|
215
227
|
"""
|
|
216
|
-
return context_processor.import_context_entity(
|
|
228
|
+
return context_processor.import_context_entity(
|
|
229
|
+
file,
|
|
230
|
+
key,
|
|
231
|
+
reset_id,
|
|
232
|
+
context,
|
|
233
|
+
)
|
|
217
234
|
|
|
218
235
|
|
|
219
236
|
def load_secret(file: str) -> Secret:
|
digitalhub/entities/task/crud.py
CHANGED
|
@@ -7,6 +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._commons.utils import is_valid_key
|
|
10
11
|
from digitalhub.entities._processors.context import context_processor
|
|
11
12
|
from digitalhub.utils.exceptions import EntityError
|
|
12
13
|
|
|
@@ -134,14 +135,25 @@ def list_tasks(project: str, **kwargs) -> list[Task]:
|
|
|
134
135
|
)
|
|
135
136
|
|
|
136
137
|
|
|
137
|
-
def import_task(
|
|
138
|
+
def import_task(
|
|
139
|
+
file: str | None = None,
|
|
140
|
+
key: str | None = None,
|
|
141
|
+
reset_id: bool = False,
|
|
142
|
+
context: str | None = None,
|
|
143
|
+
) -> Task:
|
|
138
144
|
"""
|
|
139
|
-
Import object from a YAML file
|
|
145
|
+
Import an object from a YAML file or from a storage key.
|
|
140
146
|
|
|
141
147
|
Parameters
|
|
142
148
|
----------
|
|
143
149
|
file : str
|
|
144
|
-
Path to YAML file.
|
|
150
|
+
Path to the YAML file.
|
|
151
|
+
key : str
|
|
152
|
+
Entity key (store://...).
|
|
153
|
+
reset_id : bool
|
|
154
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
155
|
+
context : str
|
|
156
|
+
Project name to use for context resolution.
|
|
145
157
|
|
|
146
158
|
Returns
|
|
147
159
|
-------
|
|
@@ -152,7 +164,12 @@ def import_task(file: str) -> Task:
|
|
|
152
164
|
-------
|
|
153
165
|
>>> obj = import_task("my-task.yaml")
|
|
154
166
|
"""
|
|
155
|
-
return context_processor.import_context_entity(
|
|
167
|
+
return context_processor.import_context_entity(
|
|
168
|
+
file,
|
|
169
|
+
key,
|
|
170
|
+
reset_id,
|
|
171
|
+
context,
|
|
172
|
+
)
|
|
156
173
|
|
|
157
174
|
|
|
158
175
|
def load_task(file: str) -> Task:
|
|
@@ -243,7 +260,7 @@ def delete_task(
|
|
|
243
260
|
>>> project="my-project",
|
|
244
261
|
>>> delete_all_versions=True)
|
|
245
262
|
"""
|
|
246
|
-
if not identifier
|
|
263
|
+
if not is_valid_key(identifier):
|
|
247
264
|
raise EntityError("Task has no name. Use key instead.")
|
|
248
265
|
return context_processor.delete_context_entity(
|
|
249
266
|
identifier=identifier,
|
|
@@ -197,14 +197,25 @@ def list_triggers(project: str, **kwargs) -> list[Trigger]:
|
|
|
197
197
|
)
|
|
198
198
|
|
|
199
199
|
|
|
200
|
-
def import_trigger(
|
|
200
|
+
def import_trigger(
|
|
201
|
+
file: str | None = None,
|
|
202
|
+
key: str | None = None,
|
|
203
|
+
reset_id: bool = False,
|
|
204
|
+
context: str | None = None,
|
|
205
|
+
) -> Trigger:
|
|
201
206
|
"""
|
|
202
|
-
Import object from a YAML file
|
|
207
|
+
Import an object from a YAML file or from a storage key.
|
|
203
208
|
|
|
204
209
|
Parameters
|
|
205
210
|
----------
|
|
206
211
|
file : str
|
|
207
|
-
Path to YAML file.
|
|
212
|
+
Path to the YAML file.
|
|
213
|
+
key : str
|
|
214
|
+
Entity key (store://...).
|
|
215
|
+
reset_id : bool
|
|
216
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
217
|
+
context : str
|
|
218
|
+
Project name to use for context resolution.
|
|
208
219
|
|
|
209
220
|
Returns
|
|
210
221
|
-------
|
|
@@ -215,7 +226,12 @@ def import_trigger(file: str) -> Trigger:
|
|
|
215
226
|
--------
|
|
216
227
|
>>> obj = import_trigger("my-trigger.yaml")
|
|
217
228
|
"""
|
|
218
|
-
return context_processor.import_context_entity(
|
|
229
|
+
return context_processor.import_context_entity(
|
|
230
|
+
file,
|
|
231
|
+
key,
|
|
232
|
+
reset_id,
|
|
233
|
+
context,
|
|
234
|
+
)
|
|
219
235
|
|
|
220
236
|
|
|
221
237
|
def load_trigger(file: str) -> Trigger:
|
|
@@ -73,7 +73,7 @@ class Workflow(ExecutableEntity):
|
|
|
73
73
|
"""
|
|
74
74
|
# Get task and run kind
|
|
75
75
|
task_kind = factory.get_task_kind_from_action(self.kind, action)
|
|
76
|
-
run_kind = factory.
|
|
76
|
+
run_kind = factory.get_run_kind_from_action(self.kind, action)
|
|
77
77
|
|
|
78
78
|
# Create or update new task
|
|
79
79
|
task = self._get_or_create_task(task_kind)
|