digitalhub 0.10.0b4__py3-none-any.whl → 0.10.0b6__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/client/_base/api_builder.py +1 -1
- digitalhub/client/_base/client.py +22 -0
- digitalhub/client/_base/params_builder.py +16 -0
- digitalhub/client/dhcore/api_builder.py +4 -3
- digitalhub/client/dhcore/client.py +4 -0
- digitalhub/client/dhcore/configurator.py +26 -4
- digitalhub/client/dhcore/params_builder.py +174 -0
- digitalhub/client/local/api_builder.py +4 -1
- digitalhub/client/local/client.py +6 -0
- digitalhub/client/local/params_builder.py +116 -0
- digitalhub/configurator/configurator.py +10 -9
- digitalhub/entities/_base/context/entity.py +4 -4
- digitalhub/entities/_base/executable/entity.py +2 -2
- digitalhub/entities/_base/material/entity.py +3 -3
- digitalhub/entities/_base/unversioned/entity.py +2 -2
- digitalhub/entities/_base/versioned/entity.py +2 -2
- digitalhub/entities/_commons/enums.py +1 -0
- digitalhub/entities/_commons/metrics.py +164 -0
- digitalhub/entities/_commons/types.py +5 -0
- digitalhub/entities/_commons/utils.py +0 -26
- digitalhub/entities/_processors/base.py +527 -0
- digitalhub/entities/{_operations/processor.py → _processors/context.py} +94 -716
- digitalhub/entities/_processors/utils.py +158 -0
- digitalhub/entities/artifact/crud.py +10 -10
- digitalhub/entities/dataitem/crud.py +10 -10
- digitalhub/entities/dataitem/utils.py +2 -1
- digitalhub/entities/function/crud.py +9 -9
- digitalhub/entities/model/_base/entity.py +26 -78
- digitalhub/entities/model/_base/status.py +1 -1
- digitalhub/entities/model/crud.py +10 -10
- digitalhub/entities/project/_base/entity.py +317 -9
- digitalhub/entities/project/crud.py +10 -9
- digitalhub/entities/run/_base/entity.py +32 -84
- digitalhub/entities/run/_base/status.py +1 -1
- digitalhub/entities/run/crud.py +8 -8
- digitalhub/entities/secret/_base/entity.py +3 -3
- digitalhub/entities/secret/crud.py +9 -9
- digitalhub/entities/task/_base/entity.py +4 -4
- digitalhub/entities/task/_base/models.py +10 -0
- digitalhub/entities/task/crud.py +8 -8
- digitalhub/entities/workflow/crud.py +9 -9
- digitalhub/factory/utils.py +9 -9
- digitalhub/readers/data/pandas/reader.py +9 -9
- digitalhub/stores/s3/configurator.py +1 -1
- digitalhub/stores/sql/configurator.py +1 -1
- digitalhub/{readers/data/pandas → utils}/enums.py +1 -1
- digitalhub/utils/git_utils.py +16 -9
- digitalhub/utils/types.py +0 -1
- {digitalhub-0.10.0b4.dist-info → digitalhub-0.10.0b6.dist-info}/METADATA +1 -4
- {digitalhub-0.10.0b4.dist-info → digitalhub-0.10.0b6.dist-info}/RECORD +53 -49
- digitalhub/entities/_base/project/entity.py +0 -341
- digitalhub/entities/_commons/models.py +0 -13
- digitalhub/entities/_operations/__init__.py +0 -0
- /digitalhub/entities/{_base/project → _processors}/__init__.py +0 -0
- {digitalhub-0.10.0b4.dist-info → digitalhub-0.10.0b6.dist-info}/WHEEL +0 -0
- {digitalhub-0.10.0b4.dist-info → digitalhub-0.10.0b6.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
5
|
from digitalhub.entities._base.context.entity import ContextEntity
|
|
6
|
-
from digitalhub.entities.
|
|
6
|
+
from digitalhub.entities._processors.context import context_processor
|
|
7
7
|
|
|
8
8
|
if typing.TYPE_CHECKING:
|
|
9
9
|
from digitalhub.entities._base.entity.metadata import Metadata
|
|
@@ -25,4 +25,4 @@ class UnversionedEntity(ContextEntity):
|
|
|
25
25
|
super().__init__(project, kind, metadata, spec, status, user)
|
|
26
26
|
self.id = uuid
|
|
27
27
|
self.name = uuid
|
|
28
|
-
self.key =
|
|
28
|
+
self.key = context_processor.build_context_entity_key(project, self.ENTITY_TYPE, kind, uuid)
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
5
|
from digitalhub.entities._base.context.entity import ContextEntity
|
|
6
|
-
from digitalhub.entities.
|
|
6
|
+
from digitalhub.entities._processors.context import context_processor
|
|
7
7
|
|
|
8
8
|
if typing.TYPE_CHECKING:
|
|
9
9
|
from digitalhub.entities._base.entity.metadata import Metadata
|
|
@@ -26,4 +26,4 @@ class VersionedEntity(ContextEntity):
|
|
|
26
26
|
super().__init__(project, kind, metadata, spec, status, user)
|
|
27
27
|
self.name = name
|
|
28
28
|
self.id = uuid
|
|
29
|
-
self.key =
|
|
29
|
+
self.key = context_processor.build_context_entity_key(project, self.ENTITY_TYPE, kind, name, uuid)
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, Union
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, ValidationError
|
|
6
|
+
|
|
7
|
+
MetricType = Union[float, int, list[Union[float, int]]]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Metric(BaseModel):
|
|
11
|
+
"""
|
|
12
|
+
Metric.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
value: MetricType
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def validate_metric_value(value: Any) -> MetricType:
|
|
19
|
+
"""
|
|
20
|
+
Validate metric value.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
value : Any
|
|
25
|
+
The value to validate.
|
|
26
|
+
|
|
27
|
+
Returns
|
|
28
|
+
-------
|
|
29
|
+
MetricType
|
|
30
|
+
The validated value.
|
|
31
|
+
"""
|
|
32
|
+
try:
|
|
33
|
+
return Metric(value=value).value
|
|
34
|
+
except ValidationError as e:
|
|
35
|
+
raise ValueError("Invalid metric value. Must be a list of floats or ints or a float or an int.") from e
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def set_metrics(
|
|
39
|
+
metrics: dict[str, MetricType],
|
|
40
|
+
key: str,
|
|
41
|
+
value: Any,
|
|
42
|
+
overwrite: bool,
|
|
43
|
+
single_value: bool,
|
|
44
|
+
) -> dict[str, MetricType]:
|
|
45
|
+
"""
|
|
46
|
+
Set metric value.
|
|
47
|
+
|
|
48
|
+
Parameters
|
|
49
|
+
----------
|
|
50
|
+
metrics : dict[str, MetricType]
|
|
51
|
+
The metrics dictionary.
|
|
52
|
+
key : str
|
|
53
|
+
The key of the entity.
|
|
54
|
+
value : Any
|
|
55
|
+
The value to set.
|
|
56
|
+
overwrite : bool
|
|
57
|
+
Whether to overwrite the metric.
|
|
58
|
+
|
|
59
|
+
Returns
|
|
60
|
+
-------
|
|
61
|
+
dict[str, MetricType]
|
|
62
|
+
The metrics dictionary.
|
|
63
|
+
"""
|
|
64
|
+
if isinstance(value, list):
|
|
65
|
+
return handle_metric_list(metrics, key, value, overwrite)
|
|
66
|
+
elif single_value:
|
|
67
|
+
return handle_metric_single(metrics, key, value, overwrite)
|
|
68
|
+
return handle_metric_list_append(metrics, key, value, overwrite)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def handle_metric_single(
|
|
72
|
+
metrics: dict[str, MetricType],
|
|
73
|
+
key: str,
|
|
74
|
+
value: float | int,
|
|
75
|
+
overwrite: bool,
|
|
76
|
+
) -> dict:
|
|
77
|
+
"""
|
|
78
|
+
Handle metric single value.
|
|
79
|
+
|
|
80
|
+
Parameters
|
|
81
|
+
----------
|
|
82
|
+
metrics : dict[str, MetricType]
|
|
83
|
+
Metrics dictionary.
|
|
84
|
+
key : str
|
|
85
|
+
Key of the metric.
|
|
86
|
+
value : float
|
|
87
|
+
Value of the metric.
|
|
88
|
+
overwrite : bool
|
|
89
|
+
If True, overwrite existing metric.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
dict
|
|
94
|
+
Metrics dictionary.
|
|
95
|
+
"""
|
|
96
|
+
if key not in metrics or overwrite:
|
|
97
|
+
metrics[key] = value
|
|
98
|
+
return metrics
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def handle_metric_list_append(
|
|
102
|
+
metrics: dict[str, MetricType],
|
|
103
|
+
key: str,
|
|
104
|
+
value: float | int,
|
|
105
|
+
overwrite: bool,
|
|
106
|
+
) -> dict:
|
|
107
|
+
"""
|
|
108
|
+
Handle metric list append.
|
|
109
|
+
|
|
110
|
+
Parameters
|
|
111
|
+
----------
|
|
112
|
+
metrics : dict[str, MetricType]
|
|
113
|
+
Metrics dictionary.
|
|
114
|
+
key : str
|
|
115
|
+
Key of the metric.
|
|
116
|
+
value : float
|
|
117
|
+
Value of the metric.
|
|
118
|
+
overwrite : bool
|
|
119
|
+
If True, overwrite existing metric.
|
|
120
|
+
|
|
121
|
+
Returns
|
|
122
|
+
-------
|
|
123
|
+
dict
|
|
124
|
+
Metrics dictionary.
|
|
125
|
+
"""
|
|
126
|
+
if key not in metrics or overwrite:
|
|
127
|
+
metrics[key] = [value]
|
|
128
|
+
elif isinstance(metrics[key], list):
|
|
129
|
+
metrics[key].append(value)
|
|
130
|
+
else:
|
|
131
|
+
metrics[key] = [metrics[key], value]
|
|
132
|
+
return metrics
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def handle_metric_list(
|
|
136
|
+
metrics: dict[str, MetricType],
|
|
137
|
+
key: str,
|
|
138
|
+
value: list[int | float],
|
|
139
|
+
overwrite: bool,
|
|
140
|
+
) -> dict:
|
|
141
|
+
"""
|
|
142
|
+
Handle metric list.
|
|
143
|
+
|
|
144
|
+
Parameters
|
|
145
|
+
----------
|
|
146
|
+
metrics : dict[str, MetricType]
|
|
147
|
+
Metrics dictionary.
|
|
148
|
+
key : str
|
|
149
|
+
Key of the metric.
|
|
150
|
+
value : list[int | float]
|
|
151
|
+
Value of the metric.
|
|
152
|
+
overwrite : bool
|
|
153
|
+
If True, overwrite existing metric.
|
|
154
|
+
|
|
155
|
+
Returns
|
|
156
|
+
-------
|
|
157
|
+
dict
|
|
158
|
+
Metrics dictionary.
|
|
159
|
+
"""
|
|
160
|
+
if key not in metrics or overwrite:
|
|
161
|
+
metrics[key] = value
|
|
162
|
+
else:
|
|
163
|
+
metrics[key].extend(value)
|
|
164
|
+
return metrics
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
from pydantic import ValidationError
|
|
6
|
-
|
|
7
3
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
8
|
-
from digitalhub.entities._commons.models import Metric
|
|
9
|
-
from digitalhub.utils.types import MetricType
|
|
10
4
|
|
|
11
5
|
|
|
12
6
|
def parse_entity_key(key: str) -> tuple[str, str, str, str | None, str]:
|
|
@@ -87,23 +81,3 @@ def get_project_from_key(key: str) -> str:
|
|
|
87
81
|
"""
|
|
88
82
|
project, _, _, _, _ = parse_entity_key(key)
|
|
89
83
|
return project
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def validate_metric_value(value: Any) -> MetricType:
|
|
93
|
-
"""
|
|
94
|
-
Validate metric value.
|
|
95
|
-
|
|
96
|
-
Parameters
|
|
97
|
-
----------
|
|
98
|
-
value : Any
|
|
99
|
-
The value to validate.
|
|
100
|
-
|
|
101
|
-
Returns
|
|
102
|
-
-------
|
|
103
|
-
MetricType
|
|
104
|
-
The validated value.
|
|
105
|
-
"""
|
|
106
|
-
try:
|
|
107
|
-
return Metric(value=value).value
|
|
108
|
-
except ValidationError as e:
|
|
109
|
-
raise ValueError("Invalid metric value. Must be a list of floats or ints or a float or an int.") from e
|