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.

Files changed (56) hide show
  1. digitalhub/client/_base/api_builder.py +1 -1
  2. digitalhub/client/_base/client.py +22 -0
  3. digitalhub/client/_base/params_builder.py +16 -0
  4. digitalhub/client/dhcore/api_builder.py +4 -3
  5. digitalhub/client/dhcore/client.py +4 -0
  6. digitalhub/client/dhcore/configurator.py +26 -4
  7. digitalhub/client/dhcore/params_builder.py +174 -0
  8. digitalhub/client/local/api_builder.py +4 -1
  9. digitalhub/client/local/client.py +6 -0
  10. digitalhub/client/local/params_builder.py +116 -0
  11. digitalhub/configurator/configurator.py +10 -9
  12. digitalhub/entities/_base/context/entity.py +4 -4
  13. digitalhub/entities/_base/executable/entity.py +2 -2
  14. digitalhub/entities/_base/material/entity.py +3 -3
  15. digitalhub/entities/_base/unversioned/entity.py +2 -2
  16. digitalhub/entities/_base/versioned/entity.py +2 -2
  17. digitalhub/entities/_commons/enums.py +1 -0
  18. digitalhub/entities/_commons/metrics.py +164 -0
  19. digitalhub/entities/_commons/types.py +5 -0
  20. digitalhub/entities/_commons/utils.py +0 -26
  21. digitalhub/entities/_processors/base.py +527 -0
  22. digitalhub/entities/{_operations/processor.py → _processors/context.py} +94 -716
  23. digitalhub/entities/_processors/utils.py +158 -0
  24. digitalhub/entities/artifact/crud.py +10 -10
  25. digitalhub/entities/dataitem/crud.py +10 -10
  26. digitalhub/entities/dataitem/utils.py +2 -1
  27. digitalhub/entities/function/crud.py +9 -9
  28. digitalhub/entities/model/_base/entity.py +26 -78
  29. digitalhub/entities/model/_base/status.py +1 -1
  30. digitalhub/entities/model/crud.py +10 -10
  31. digitalhub/entities/project/_base/entity.py +317 -9
  32. digitalhub/entities/project/crud.py +10 -9
  33. digitalhub/entities/run/_base/entity.py +32 -84
  34. digitalhub/entities/run/_base/status.py +1 -1
  35. digitalhub/entities/run/crud.py +8 -8
  36. digitalhub/entities/secret/_base/entity.py +3 -3
  37. digitalhub/entities/secret/crud.py +9 -9
  38. digitalhub/entities/task/_base/entity.py +4 -4
  39. digitalhub/entities/task/_base/models.py +10 -0
  40. digitalhub/entities/task/crud.py +8 -8
  41. digitalhub/entities/workflow/crud.py +9 -9
  42. digitalhub/factory/utils.py +9 -9
  43. digitalhub/readers/data/pandas/reader.py +9 -9
  44. digitalhub/stores/s3/configurator.py +1 -1
  45. digitalhub/stores/sql/configurator.py +1 -1
  46. digitalhub/{readers/data/pandas → utils}/enums.py +1 -1
  47. digitalhub/utils/git_utils.py +16 -9
  48. digitalhub/utils/types.py +0 -1
  49. {digitalhub-0.10.0b4.dist-info → digitalhub-0.10.0b6.dist-info}/METADATA +1 -4
  50. {digitalhub-0.10.0b4.dist-info → digitalhub-0.10.0b6.dist-info}/RECORD +53 -49
  51. digitalhub/entities/_base/project/entity.py +0 -341
  52. digitalhub/entities/_commons/models.py +0 -13
  53. digitalhub/entities/_operations/__init__.py +0 -0
  54. /digitalhub/entities/{_base/project → _processors}/__init__.py +0 -0
  55. {digitalhub-0.10.0b4.dist-info → digitalhub-0.10.0b6.dist-info}/WHEEL +0 -0
  56. {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._operations.processor import processor
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 = processor.build_context_entity_key(project, self.ENTITY_TYPE, kind, uuid)
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._operations.processor import processor
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 = processor.build_context_entity_key(project, self.ENTITY_TYPE, kind, name, uuid)
29
+ self.key = context_processor.build_context_entity_key(project, self.ENTITY_TYPE, kind, name, uuid)
@@ -73,6 +73,7 @@ class BackendOperations(Enum):
73
73
 
74
74
  CREATE = "create"
75
75
  READ = "read"
76
+ READ_ALL_VERSIONS = "read_all_versions"
76
77
  UPDATE = "update"
77
78
  DELETE = "delete"
78
79
  LIST = "list"
@@ -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
@@ -0,0 +1,5 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Union
4
+
5
+ MetricType = Union[float, int, list[Union[float, int]]]
@@ -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