digitalhub 0.10.0b3__py3-none-any.whl → 0.10.0b5__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/dhcore/configurator.py +4 -4
- digitalhub/configurator/configurator.py +10 -9
- digitalhub/entities/_base/entity/builder.py +5 -5
- digitalhub/entities/_base/material/entity.py +4 -17
- digitalhub/entities/_base/material/status.py +1 -1
- digitalhub/entities/_commons/models.py +7 -3
- digitalhub/entities/_commons/types.py +5 -0
- digitalhub/entities/_commons/utils.py +5 -4
- digitalhub/entities/_operations/processor.py +49 -16
- digitalhub/entities/artifact/artifact/spec.py +3 -1
- digitalhub/entities/artifact/crud.py +3 -2
- digitalhub/entities/builders.py +6 -18
- digitalhub/entities/dataitem/crud.py +3 -2
- digitalhub/entities/dataitem/table/models.py +4 -3
- digitalhub/entities/dataitem/table/utils.py +7 -7
- digitalhub/entities/dataitem/utils.py +14 -8
- digitalhub/entities/model/_base/spec.py +6 -7
- digitalhub/entities/model/crud.py +3 -2
- digitalhub/entities/model/huggingface/spec.py +4 -2
- digitalhub/entities/model/mlflow/spec.py +6 -4
- digitalhub/entities/project/_base/spec.py +8 -6
- digitalhub/entities/project/crud.py +2 -2
- digitalhub/entities/run/_base/spec.py +4 -2
- digitalhub/entities/secret/_base/spec.py +4 -2
- digitalhub/entities/secret/crud.py +2 -0
- digitalhub/entities/task/_base/models.py +41 -40
- digitalhub/entities/task/_base/utils.py +2 -2
- digitalhub/factory/utils.py +9 -9
- digitalhub/readers/data/pandas/reader.py +9 -9
- digitalhub/stores/_base/store.py +4 -3
- digitalhub/stores/local/store.py +4 -3
- digitalhub/stores/remote/store.py +4 -3
- digitalhub/stores/s3/configurator.py +1 -1
- digitalhub/stores/s3/enums.py +7 -7
- digitalhub/stores/s3/store.py +5 -4
- digitalhub/stores/sql/configurator.py +5 -5
- digitalhub/stores/sql/enums.py +6 -6
- digitalhub/stores/sql/store.py +7 -3
- digitalhub/{readers/data/pandas → utils}/enums.py +1 -1
- digitalhub/utils/file_utils.py +8 -7
- digitalhub/utils/generic_utils.py +20 -8
- digitalhub/utils/types.py +5 -0
- digitalhub/utils/uri_utils.py +1 -1
- {digitalhub-0.10.0b3.dist-info → digitalhub-0.10.0b5.dist-info}/METADATA +1 -1
- {digitalhub-0.10.0b3.dist-info → digitalhub-0.10.0b5.dist-info}/RECORD +47 -45
- {digitalhub-0.10.0b3.dist-info → digitalhub-0.10.0b5.dist-info}/WHEEL +0 -0
- {digitalhub-0.10.0b3.dist-info → digitalhub-0.10.0b5.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
3
5
|
from digitalhub.entities._base.material.spec import MaterialSpec, MaterialValidator
|
|
4
6
|
|
|
5
7
|
|
|
@@ -15,7 +17,7 @@ class ModelSpec(MaterialSpec):
|
|
|
15
17
|
algorithm: str | None = None,
|
|
16
18
|
parameters: dict | None = None,
|
|
17
19
|
) -> None:
|
|
18
|
-
|
|
20
|
+
super().__init__(path)
|
|
19
21
|
self.framework = framework
|
|
20
22
|
self.algorithm = algorithm
|
|
21
23
|
self.parameters = parameters
|
|
@@ -26,14 +28,11 @@ class ModelValidator(MaterialValidator):
|
|
|
26
28
|
ModelValidator validator.
|
|
27
29
|
"""
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
"""Path to the model."""
|
|
31
|
-
|
|
32
|
-
framework: str = None
|
|
31
|
+
framework: Optional[str] = None
|
|
33
32
|
"""Model framework (e.g. 'pytorch')."""
|
|
34
33
|
|
|
35
|
-
algorithm: str = None
|
|
34
|
+
algorithm: Optional[str] = None
|
|
36
35
|
"""Model algorithm (e.g. 'resnet')."""
|
|
37
36
|
|
|
38
|
-
parameters: dict = None
|
|
37
|
+
parameters: Optional[dict] = None
|
|
39
38
|
"""Model validator."""
|
|
@@ -5,6 +5,7 @@ import typing
|
|
|
5
5
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
6
6
|
from digitalhub.entities._operations.processor import processor
|
|
7
7
|
from digitalhub.entities.artifact.utils import eval_source, process_kwargs
|
|
8
|
+
from digitalhub.utils.types import SourcesOrListOfSources
|
|
8
9
|
|
|
9
10
|
if typing.TYPE_CHECKING:
|
|
10
11
|
from digitalhub.entities.model._base.entity import Model
|
|
@@ -77,7 +78,7 @@ def log_model(
|
|
|
77
78
|
project: str,
|
|
78
79
|
name: str,
|
|
79
80
|
kind: str,
|
|
80
|
-
source:
|
|
81
|
+
source: SourcesOrListOfSources,
|
|
81
82
|
path: str | None = None,
|
|
82
83
|
**kwargs,
|
|
83
84
|
) -> Model:
|
|
@@ -92,7 +93,7 @@ def log_model(
|
|
|
92
93
|
Object name.
|
|
93
94
|
kind : str
|
|
94
95
|
Kind the object.
|
|
95
|
-
source :
|
|
96
|
+
source : SourcesOrListOfSources
|
|
96
97
|
Model location on local path.
|
|
97
98
|
path : str
|
|
98
99
|
Destination path of the model. If not provided, it's generated.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
3
5
|
from pydantic import Field
|
|
4
6
|
|
|
5
7
|
from digitalhub.entities.model._base.spec import ModelSpec, ModelValidator
|
|
@@ -18,7 +20,7 @@ class ModelSpecHuggingface(ModelSpec):
|
|
|
18
20
|
parameters: dict | None = None,
|
|
19
21
|
base_model: str | None = None,
|
|
20
22
|
model_id: str | None = None,
|
|
21
|
-
model_revision: str = None,
|
|
23
|
+
model_revision: str | None = None,
|
|
22
24
|
) -> None:
|
|
23
25
|
super().__init__(path, framework, algorithm, parameters)
|
|
24
26
|
self.base_model = base_model
|
|
@@ -31,7 +33,7 @@ class ModelValidatorHuggingface(ModelValidator):
|
|
|
31
33
|
ModelValidatorHuggingface validator.
|
|
32
34
|
"""
|
|
33
35
|
|
|
34
|
-
base_model: str = None
|
|
36
|
+
base_model: Optional[str] = None
|
|
35
37
|
"""Base model."""
|
|
36
38
|
|
|
37
39
|
placeholder_model_id: str = Field(default=None, alias="model_id")
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
3
5
|
from pydantic import Field
|
|
4
6
|
|
|
5
7
|
from digitalhub.entities.model._base.spec import ModelSpec, ModelValidator
|
|
@@ -20,7 +22,7 @@ class ModelSpecMlflow(ModelSpec):
|
|
|
20
22
|
flavor: str | None = None,
|
|
21
23
|
model_config: dict | None = None,
|
|
22
24
|
input_datasets: list[Dataset] | None = None,
|
|
23
|
-
signature: Signature = None,
|
|
25
|
+
signature: Signature | None = None,
|
|
24
26
|
) -> None:
|
|
25
27
|
super().__init__(path, framework, algorithm, parameters)
|
|
26
28
|
self.flavor = flavor
|
|
@@ -34,14 +36,14 @@ class ModelValidatorMlflow(ModelValidator):
|
|
|
34
36
|
ModelValidatorMlflow validator.
|
|
35
37
|
"""
|
|
36
38
|
|
|
37
|
-
flavor: str = None
|
|
39
|
+
flavor: Optional[str] = None
|
|
38
40
|
"""Mlflow model flavor."""
|
|
39
41
|
|
|
40
42
|
placeholder_cfg_: dict = Field(default=None, alias="model_config")
|
|
41
43
|
"""Mlflow model config."""
|
|
42
44
|
|
|
43
|
-
input_datasets: list[Dataset] = None
|
|
45
|
+
input_datasets: Optional[list[Dataset]] = None
|
|
44
46
|
"""Mlflow input datasets."""
|
|
45
47
|
|
|
46
|
-
signature: Signature = None
|
|
48
|
+
signature: Optional[Signature] = None
|
|
47
49
|
"""Mlflow model signature."""
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
3
5
|
from digitalhub.entities._base.entity.spec import Spec, SpecValidator
|
|
4
6
|
|
|
5
7
|
|
|
@@ -31,20 +33,20 @@ class ProjectValidator(SpecValidator):
|
|
|
31
33
|
ProjectValidator validator.
|
|
32
34
|
"""
|
|
33
35
|
|
|
34
|
-
context: str = None
|
|
36
|
+
context: Optional[str] = None
|
|
35
37
|
"""The project's context."""
|
|
36
38
|
|
|
37
|
-
functions: list = None
|
|
39
|
+
functions: Optional[list] = None
|
|
38
40
|
"""List of project's functions."""
|
|
39
41
|
|
|
40
|
-
artifacts: list = None
|
|
42
|
+
artifacts: Optional[list] = None
|
|
41
43
|
"""List of project's artifacts."""
|
|
42
44
|
|
|
43
|
-
workflows: list = None
|
|
45
|
+
workflows: Optional[list] = None
|
|
44
46
|
"""List of project's workflows."""
|
|
45
47
|
|
|
46
|
-
dataitems: list = None
|
|
48
|
+
dataitems: Optional[list] = None
|
|
47
49
|
"""List of project's dataitems."""
|
|
48
50
|
|
|
49
|
-
models: list = None
|
|
51
|
+
models: Optional[list] = None
|
|
50
52
|
"""List of project's models."""
|
|
@@ -272,7 +272,7 @@ def update_project(entity: Project, **kwargs) -> Project:
|
|
|
272
272
|
entity_type=entity.ENTITY_TYPE,
|
|
273
273
|
entity_name=entity.name,
|
|
274
274
|
entity_dict=entity.to_dict(),
|
|
275
|
-
local=entity.
|
|
275
|
+
local=entity._client.is_local(),
|
|
276
276
|
**kwargs,
|
|
277
277
|
)
|
|
278
278
|
|
|
@@ -283,7 +283,7 @@ def delete_project(
|
|
|
283
283
|
clean_context: bool = True,
|
|
284
284
|
local: bool = False,
|
|
285
285
|
**kwargs,
|
|
286
|
-
) ->
|
|
286
|
+
) -> dict:
|
|
287
287
|
"""
|
|
288
288
|
Delete a project.
|
|
289
289
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
3
5
|
from digitalhub.entities._base.entity.spec import Spec, SpecValidator
|
|
4
6
|
from digitalhub.entities.task._base.models import K8s
|
|
5
7
|
|
|
@@ -47,8 +49,8 @@ class RunValidator(SpecValidator, K8s):
|
|
|
47
49
|
"""
|
|
48
50
|
|
|
49
51
|
# Task parameters
|
|
50
|
-
function: str = None
|
|
51
|
-
workflow: str = None
|
|
52
|
+
function: Optional[str] = None
|
|
53
|
+
workflow: Optional[str] = None
|
|
52
54
|
|
|
53
55
|
# Run parameters
|
|
54
56
|
task: str
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
3
5
|
from digitalhub.entities._base.entity.spec import Spec, SpecValidator
|
|
4
6
|
|
|
5
7
|
|
|
@@ -28,8 +30,8 @@ class SecretValidator(SpecValidator):
|
|
|
28
30
|
SecretValidator validator.
|
|
29
31
|
"""
|
|
30
32
|
|
|
31
|
-
path: str = None
|
|
33
|
+
path: Optional[str] = None
|
|
32
34
|
"""Path to the secret."""
|
|
33
35
|
|
|
34
|
-
provider: str = None
|
|
36
|
+
provider: Optional[str] = None
|
|
35
37
|
"""Provider of the secret."""
|
|
@@ -108,6 +108,8 @@ def get_secret(
|
|
|
108
108
|
>>> entity_id="my-secret-id")
|
|
109
109
|
"""
|
|
110
110
|
if not identifier.startswith("store://"):
|
|
111
|
+
if project is None:
|
|
112
|
+
raise ValueError("Project must be provided.")
|
|
111
113
|
secrets = list_secrets(project=project, **kwargs)
|
|
112
114
|
for secret in secrets:
|
|
113
115
|
if secret.name == identifier:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from enum import Enum
|
|
4
|
+
from typing import Optional
|
|
4
5
|
|
|
5
6
|
from pydantic import BaseModel, ConfigDict, Field
|
|
6
7
|
|
|
@@ -30,7 +31,7 @@ class Volume(BaseModel):
|
|
|
30
31
|
mount_path: str
|
|
31
32
|
"""Volume mount path inside the container."""
|
|
32
33
|
|
|
33
|
-
spec: dict[str, str] = None
|
|
34
|
+
spec: Optional[dict[str, str]] = None
|
|
34
35
|
"""Volume spec."""
|
|
35
36
|
|
|
36
37
|
|
|
@@ -63,13 +64,13 @@ class Resource(BaseModel):
|
|
|
63
64
|
Resource model.
|
|
64
65
|
"""
|
|
65
66
|
|
|
66
|
-
cpu: ResourceItem = None
|
|
67
|
+
cpu: Optional[ResourceItem] = None
|
|
67
68
|
"""CPU resource model."""
|
|
68
69
|
|
|
69
|
-
mem: ResourceItem = None
|
|
70
|
+
mem: Optional[ResourceItem] = None
|
|
70
71
|
"""Memory resource model."""
|
|
71
72
|
|
|
72
|
-
gpu: ResourceItem = None
|
|
73
|
+
gpu: Optional[ResourceItem] = None
|
|
73
74
|
"""GPU resource model."""
|
|
74
75
|
|
|
75
76
|
|
|
@@ -90,31 +91,31 @@ class Toleration(BaseModel):
|
|
|
90
91
|
Toleration model.
|
|
91
92
|
"""
|
|
92
93
|
|
|
93
|
-
key: str = None
|
|
94
|
+
key: Optional[str] = None
|
|
94
95
|
"""Toleration key."""
|
|
95
96
|
|
|
96
|
-
operator: str = None
|
|
97
|
+
operator: Optional[str] = None
|
|
97
98
|
"""Toleration operator."""
|
|
98
99
|
|
|
99
|
-
value: str = None
|
|
100
|
+
value: Optional[str] = None
|
|
100
101
|
"""Toleration value."""
|
|
101
102
|
|
|
102
|
-
effect: str = None
|
|
103
|
+
effect: Optional[str] = None
|
|
103
104
|
"""Toleration effect."""
|
|
104
105
|
|
|
105
|
-
toleration_seconds: int = None
|
|
106
|
+
toleration_seconds: Optional[int] = None
|
|
106
107
|
"""Toleration seconds."""
|
|
107
108
|
|
|
108
109
|
|
|
109
110
|
class V1NodeSelectorRequirement(BaseModel):
|
|
110
111
|
key: str
|
|
111
112
|
operator: str
|
|
112
|
-
values: list[str] = None
|
|
113
|
+
values: Optional[list[str]] = None
|
|
113
114
|
|
|
114
115
|
|
|
115
116
|
class V1NodeSelectorTerm(BaseModel):
|
|
116
|
-
match_expressions: list[V1NodeSelectorRequirement] = None
|
|
117
|
-
match_fields: list[V1NodeSelectorRequirement] = None
|
|
117
|
+
match_expressions: Optional[list[V1NodeSelectorRequirement]] = None
|
|
118
|
+
match_fields: Optional[list[V1NodeSelectorRequirement]] = None
|
|
118
119
|
|
|
119
120
|
|
|
120
121
|
class V1NodeSelector(BaseModel):
|
|
@@ -129,21 +130,21 @@ class V1PreferredSchedulingTerm(BaseModel):
|
|
|
129
130
|
class V1LabelSelectorRequirement(BaseModel):
|
|
130
131
|
key: str
|
|
131
132
|
operator: str
|
|
132
|
-
values: list[str] = None
|
|
133
|
+
values: Optional[list[str]] = None
|
|
133
134
|
|
|
134
135
|
|
|
135
136
|
class V1LabelSelector(BaseModel):
|
|
136
|
-
match_expressions: list[V1LabelSelectorRequirement] = None
|
|
137
|
-
match_labels: dict[str, str] = None
|
|
137
|
+
match_expressions: Optional[list[V1LabelSelectorRequirement]] = None
|
|
138
|
+
match_labels: Optional[dict[str, str]] = None
|
|
138
139
|
|
|
139
140
|
|
|
140
141
|
class V1PodAffinityTerm(BaseModel):
|
|
141
|
-
label_selector: V1LabelSelector = None
|
|
142
|
-
match_label_keys: list[str] = None
|
|
143
|
-
mismatch_label_keys: list[str] = None
|
|
144
|
-
namespace_selector: V1LabelSelector = None
|
|
145
|
-
namespaces: list[str] = None
|
|
146
|
-
topology_key: str
|
|
142
|
+
label_selector: Optional[V1LabelSelector] = None
|
|
143
|
+
match_label_keys: Optional[list[str]] = None
|
|
144
|
+
mismatch_label_keys: Optional[list[str]] = None
|
|
145
|
+
namespace_selector: Optional[V1LabelSelector] = None
|
|
146
|
+
namespaces: Optional[list[str]] = None
|
|
147
|
+
topology_key: Optional[str] = None
|
|
147
148
|
|
|
148
149
|
|
|
149
150
|
class V1WeightedPodAffinityTerm(BaseModel):
|
|
@@ -152,18 +153,18 @@ class V1WeightedPodAffinityTerm(BaseModel):
|
|
|
152
153
|
|
|
153
154
|
|
|
154
155
|
class V1NodeAffinity(BaseModel):
|
|
155
|
-
preferred_during_scheduling_ignored_during_execution: list[V1PreferredSchedulingTerm] = None
|
|
156
|
-
required_during_scheduling_ignored_during_execution: V1NodeSelector = None
|
|
156
|
+
preferred_during_scheduling_ignored_during_execution: Optional[list[V1PreferredSchedulingTerm]] = None
|
|
157
|
+
required_during_scheduling_ignored_during_execution: Optional[V1NodeSelector] = None
|
|
157
158
|
|
|
158
159
|
|
|
159
160
|
class V1PodAffinity(BaseModel):
|
|
160
|
-
preferred_during_scheduling_ignored_during_execution: list[V1WeightedPodAffinityTerm] = None
|
|
161
|
-
required_during_scheduling_ignored_during_execution: list[V1PodAffinityTerm] = None
|
|
161
|
+
preferred_during_scheduling_ignored_during_execution: Optional[list[V1WeightedPodAffinityTerm]] = None
|
|
162
|
+
required_during_scheduling_ignored_during_execution: Optional[list[V1PodAffinityTerm]] = None
|
|
162
163
|
|
|
163
164
|
|
|
164
165
|
class V1PodAntiAffinity(BaseModel):
|
|
165
|
-
preferred_during_scheduling_ignored_during_execution: list[V1WeightedPodAffinityTerm] = None
|
|
166
|
-
required_during_scheduling_ignored_during_execution: list[V1PodAffinityTerm] = None
|
|
166
|
+
preferred_during_scheduling_ignored_during_execution: Optional[list[V1WeightedPodAffinityTerm]] = None
|
|
167
|
+
required_during_scheduling_ignored_during_execution: Optional[list[V1PodAffinityTerm]] = None
|
|
167
168
|
|
|
168
169
|
|
|
169
170
|
class Affinity(BaseModel):
|
|
@@ -171,13 +172,13 @@ class Affinity(BaseModel):
|
|
|
171
172
|
Affinity model.
|
|
172
173
|
"""
|
|
173
174
|
|
|
174
|
-
node_affinity: V1NodeAffinity = None
|
|
175
|
+
node_affinity: Optional[V1NodeAffinity] = None
|
|
175
176
|
"""Node affinity."""
|
|
176
177
|
|
|
177
|
-
pod_affinity: V1PodAffinity = None
|
|
178
|
+
pod_affinity: Optional[V1PodAffinity] = None
|
|
178
179
|
"""Pod affinity."""
|
|
179
180
|
|
|
180
|
-
pod_anti_affinity: V1PodAntiAffinity = None
|
|
181
|
+
pod_anti_affinity: Optional[V1PodAntiAffinity] = None
|
|
181
182
|
"""Pod anti affinity."""
|
|
182
183
|
|
|
183
184
|
|
|
@@ -186,34 +187,34 @@ class K8s(BaseModel):
|
|
|
186
187
|
Kubernetes resource model.
|
|
187
188
|
"""
|
|
188
189
|
|
|
189
|
-
node_selector: list[NodeSelector] = None
|
|
190
|
+
node_selector: Optional[list[NodeSelector]] = None
|
|
190
191
|
"""Node selector."""
|
|
191
192
|
|
|
192
|
-
volumes: list[Volume] = None
|
|
193
|
+
volumes: Optional[list[Volume]] = None
|
|
193
194
|
"""List of volumes."""
|
|
194
195
|
|
|
195
|
-
resources: Resource = None
|
|
196
|
+
resources: Optional[Resource] = None
|
|
196
197
|
"""Resources restrictions."""
|
|
197
198
|
|
|
198
|
-
affinity: Affinity = None
|
|
199
|
+
affinity: Optional[Affinity] = None
|
|
199
200
|
"""Affinity."""
|
|
200
201
|
|
|
201
|
-
tolerations: list[Toleration] = None
|
|
202
|
+
tolerations: Optional[list[Toleration]] = None
|
|
202
203
|
"""Tolerations."""
|
|
203
204
|
|
|
204
|
-
envs: list[Env] = None
|
|
205
|
+
envs: Optional[list[Env]] = None
|
|
205
206
|
"""Env variables."""
|
|
206
207
|
|
|
207
|
-
secrets: list[str] = None
|
|
208
|
+
secrets: Optional[list[str]] = None
|
|
208
209
|
"""List of secret names."""
|
|
209
210
|
|
|
210
|
-
profile: str = None
|
|
211
|
+
profile: Optional[str] = None
|
|
211
212
|
"""Profile template."""
|
|
212
213
|
|
|
213
|
-
runtime_class: str = None
|
|
214
|
+
runtime_class: Optional[str] = None
|
|
214
215
|
"""Runtime class name."""
|
|
215
216
|
|
|
216
|
-
priority_class: str = None
|
|
217
|
+
priority_class: Optional[str] = None
|
|
217
218
|
"""Priority class."""
|
|
218
219
|
|
|
219
220
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
def build_task_actions(kind_action_list: list[tuple[str, str]]) -> dict[str, str]:
|
|
4
|
+
def build_task_actions(kind_action_list: list[tuple[str, str]]) -> list[dict[str, str]]:
|
|
5
5
|
"""
|
|
6
6
|
Build task actions.
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ def build_task_actions(kind_action_list: list[tuple[str, str]]) -> dict[str, str
|
|
|
12
12
|
|
|
13
13
|
Returns
|
|
14
14
|
-------
|
|
15
|
-
dict[str, str]
|
|
15
|
+
list[dict[str, str]]
|
|
16
16
|
Returns the task actions.
|
|
17
17
|
"""
|
|
18
18
|
return [{"kind": kind, "action": action} for (kind, action) in kind_action_list]
|
digitalhub/factory/utils.py
CHANGED
|
@@ -25,10 +25,10 @@ def import_module(package: str) -> ModuleType:
|
|
|
25
25
|
"""
|
|
26
26
|
try:
|
|
27
27
|
return importlib.import_module(package)
|
|
28
|
-
except ModuleNotFoundError:
|
|
29
|
-
raise ModuleNotFoundError(f"Package {package} not found.")
|
|
28
|
+
except ModuleNotFoundError as e:
|
|
29
|
+
raise ModuleNotFoundError(f"Package {package} not found.") from e
|
|
30
30
|
except Exception as e:
|
|
31
|
-
raise e
|
|
31
|
+
raise RuntimeError(f"An error occurred while importing {package}.") from e
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def list_runtimes() -> list[str]:
|
|
@@ -37,18 +37,18 @@ def list_runtimes() -> list[str]:
|
|
|
37
37
|
|
|
38
38
|
Returns
|
|
39
39
|
-------
|
|
40
|
-
list
|
|
40
|
+
list[str]
|
|
41
41
|
List of installed runtimes names.
|
|
42
42
|
"""
|
|
43
43
|
pattern = r"digitalhub_runtime_.*"
|
|
44
|
-
runtimes = []
|
|
44
|
+
runtimes: list[str] = []
|
|
45
45
|
try:
|
|
46
46
|
for _, name, _ in pkgutil.iter_modules():
|
|
47
47
|
if re.match(pattern, name):
|
|
48
48
|
runtimes.append(name)
|
|
49
49
|
return runtimes
|
|
50
|
-
except Exception:
|
|
51
|
-
raise RuntimeError("Error listing installed runtimes.")
|
|
50
|
+
except Exception as e:
|
|
51
|
+
raise RuntimeError("Error listing installed runtimes.") from e
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
def register_runtimes_entities() -> None:
|
|
@@ -86,5 +86,5 @@ def register_entities() -> None:
|
|
|
86
86
|
for entity_builder_tuple in entities_builders_list:
|
|
87
87
|
kind, builder = entity_builder_tuple
|
|
88
88
|
factory.add_entity_builder(kind, builder)
|
|
89
|
-
except Exception:
|
|
90
|
-
raise
|
|
89
|
+
except Exception as e:
|
|
90
|
+
raise RuntimeError("Error registering entities.") from e
|
|
@@ -10,7 +10,7 @@ from pandas.errors import ParserError
|
|
|
10
10
|
|
|
11
11
|
from digitalhub.entities.dataitem.table.utils import check_preview_size, finalize_preview, prepare_data, prepare_preview
|
|
12
12
|
from digitalhub.readers.data._base.reader import DataframeReader
|
|
13
|
-
from digitalhub.
|
|
13
|
+
from digitalhub.utils.enums import FileExtensions
|
|
14
14
|
from digitalhub.utils.exceptions import ReaderError
|
|
15
15
|
from digitalhub.utils.generic_utils import CustomJsonEncoder
|
|
16
16
|
|
|
@@ -42,17 +42,17 @@ class DataframeReaderPandas(DataframeReader):
|
|
|
42
42
|
pd.DataFrame
|
|
43
43
|
Pandas DataFrame.
|
|
44
44
|
"""
|
|
45
|
-
if extension ==
|
|
45
|
+
if extension == FileExtensions.CSV.value:
|
|
46
46
|
return pd.read_csv(path_or_buffer, **kwargs)
|
|
47
|
-
if extension ==
|
|
47
|
+
if extension == FileExtensions.PARQUET.value:
|
|
48
48
|
return pd.read_parquet(path_or_buffer, **kwargs)
|
|
49
|
-
if extension ==
|
|
49
|
+
if extension == FileExtensions.JSON.value:
|
|
50
50
|
return pd.read_json(path_or_buffer, **kwargs)
|
|
51
|
-
if extension in (
|
|
51
|
+
if extension in (FileExtensions.EXCEL.value, FileExtensions.EXCEL_OLD.value):
|
|
52
52
|
return pd.read_excel(path_or_buffer, **kwargs)
|
|
53
|
-
if extension in (
|
|
53
|
+
if extension in (FileExtensions.TXT.value, FileExtensions.FILE.value):
|
|
54
54
|
try:
|
|
55
|
-
return self.read_df(path_or_buffer,
|
|
55
|
+
return self.read_df(path_or_buffer, FileExtensions.CSV.value, **kwargs)
|
|
56
56
|
except ParserError:
|
|
57
57
|
raise ReaderError(f"Unable to read from {path_or_buffer}.")
|
|
58
58
|
else:
|
|
@@ -105,9 +105,9 @@ class DataframeReaderPandas(DataframeReader):
|
|
|
105
105
|
-------
|
|
106
106
|
None
|
|
107
107
|
"""
|
|
108
|
-
if extension ==
|
|
108
|
+
if extension == FileExtensions.CSV.value:
|
|
109
109
|
return self.write_csv(df, dst, **kwargs)
|
|
110
|
-
if extension ==
|
|
110
|
+
if extension == FileExtensions.PARQUET.value:
|
|
111
111
|
return self.write_parquet(df, dst, **kwargs)
|
|
112
112
|
raise ReaderError(f"Unsupported extension '{extension}' for writing.")
|
|
113
113
|
|
digitalhub/stores/_base/store.py
CHANGED
|
@@ -8,6 +8,7 @@ from typing import Any
|
|
|
8
8
|
|
|
9
9
|
from digitalhub.readers.data.api import get_reader_by_engine
|
|
10
10
|
from digitalhub.utils.exceptions import StoreError
|
|
11
|
+
from digitalhub.utils.types import SourcesOrListOfSources
|
|
11
12
|
from digitalhub.utils.uri_utils import has_local_scheme
|
|
12
13
|
|
|
13
14
|
if typing.TYPE_CHECKING:
|
|
@@ -36,7 +37,7 @@ class Store:
|
|
|
36
37
|
"""
|
|
37
38
|
|
|
38
39
|
@abstractmethod
|
|
39
|
-
def upload(self, src:
|
|
40
|
+
def upload(self, src: SourcesOrListOfSources, dst: str) -> list[tuple[str, str]]:
|
|
40
41
|
"""
|
|
41
42
|
Method to upload artifact to storage.
|
|
42
43
|
"""
|
|
@@ -58,7 +59,7 @@ class Store:
|
|
|
58
59
|
@abstractmethod
|
|
59
60
|
def read_df(
|
|
60
61
|
self,
|
|
61
|
-
path:
|
|
62
|
+
path: SourcesOrListOfSources,
|
|
62
63
|
file_format: str | None = None,
|
|
63
64
|
engine: str | None = None,
|
|
64
65
|
**kwargs,
|
|
@@ -159,7 +160,7 @@ class Store:
|
|
|
159
160
|
|
|
160
161
|
Parameters
|
|
161
162
|
----------
|
|
162
|
-
path : str
|
|
163
|
+
path : str | Path
|
|
163
164
|
The path to build.
|
|
164
165
|
|
|
165
166
|
Returns
|
digitalhub/stores/local/store.py
CHANGED
|
@@ -8,6 +8,7 @@ from digitalhub.readers.data.api import get_reader_by_object
|
|
|
8
8
|
from digitalhub.stores._base.store import Store
|
|
9
9
|
from digitalhub.utils.exceptions import StoreError
|
|
10
10
|
from digitalhub.utils.file_utils import get_file_info_from_local
|
|
11
|
+
from digitalhub.utils.types import SourcesOrListOfSources
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
class LocalStore(Store):
|
|
@@ -51,7 +52,7 @@ class LocalStore(Store):
|
|
|
51
52
|
"""
|
|
52
53
|
raise StoreError("Local store does not support download.")
|
|
53
54
|
|
|
54
|
-
def upload(self, src:
|
|
55
|
+
def upload(self, src: SourcesOrListOfSources, dst: str) -> list[tuple[str, str]]:
|
|
55
56
|
"""
|
|
56
57
|
Upload an artifact to storage.
|
|
57
58
|
|
|
@@ -88,7 +89,7 @@ class LocalStore(Store):
|
|
|
88
89
|
|
|
89
90
|
def read_df(
|
|
90
91
|
self,
|
|
91
|
-
path:
|
|
92
|
+
path: SourcesOrListOfSources,
|
|
92
93
|
file_format: str | None = None,
|
|
93
94
|
engine: str | None = None,
|
|
94
95
|
**kwargs,
|
|
@@ -98,7 +99,7 @@ class LocalStore(Store):
|
|
|
98
99
|
|
|
99
100
|
Parameters
|
|
100
101
|
----------
|
|
101
|
-
path :
|
|
102
|
+
path : SourcesOrListOfSources
|
|
102
103
|
Path(s) to read DataFrame from.
|
|
103
104
|
file_format : str
|
|
104
105
|
Extension of the file.
|
|
@@ -7,6 +7,7 @@ import requests
|
|
|
7
7
|
|
|
8
8
|
from digitalhub.stores._base.store import Store
|
|
9
9
|
from digitalhub.utils.exceptions import StoreError
|
|
10
|
+
from digitalhub.utils.types import SourcesOrListOfSources
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class RemoteStore(Store):
|
|
@@ -62,7 +63,7 @@ class RemoteStore(Store):
|
|
|
62
63
|
|
|
63
64
|
return self._download_file(root, dst, overwrite)
|
|
64
65
|
|
|
65
|
-
def upload(self, src:
|
|
66
|
+
def upload(self, src: SourcesOrListOfSources, dst: str) -> list[tuple[str, str]]:
|
|
66
67
|
"""
|
|
67
68
|
Upload an artifact to storage.
|
|
68
69
|
|
|
@@ -99,7 +100,7 @@ class RemoteStore(Store):
|
|
|
99
100
|
|
|
100
101
|
def read_df(
|
|
101
102
|
self,
|
|
102
|
-
path:
|
|
103
|
+
path: SourcesOrListOfSources,
|
|
103
104
|
file_format: str | None = None,
|
|
104
105
|
engine: str | None = None,
|
|
105
106
|
**kwargs,
|
|
@@ -109,7 +110,7 @@ class RemoteStore(Store):
|
|
|
109
110
|
|
|
110
111
|
Parameters
|
|
111
112
|
----------
|
|
112
|
-
path :
|
|
113
|
+
path : SourcesOrListOfSources
|
|
113
114
|
Path(s) to read DataFrame from.
|
|
114
115
|
file_format : str
|
|
115
116
|
Extension of the file.
|
digitalhub/stores/s3/enums.py
CHANGED
|
@@ -8,10 +8,10 @@ class S3StoreEnv(Enum):
|
|
|
8
8
|
S3Store environment
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
ENDPOINT_URL = "
|
|
12
|
-
ACCESS_KEY_ID = "
|
|
13
|
-
SECRET_ACCESS_KEY = "
|
|
14
|
-
SESSION_TOKEN = "
|
|
15
|
-
BUCKET_NAME = "
|
|
16
|
-
REGION = "
|
|
17
|
-
SIGNATURE_VERSION = "
|
|
11
|
+
ENDPOINT_URL = "DHCORE_S3_ENDPOINT_URL"
|
|
12
|
+
ACCESS_KEY_ID = "DHCORE_AWS_ACCESS_KEY_ID"
|
|
13
|
+
SECRET_ACCESS_KEY = "DHCORE_AWS_SECRET_ACCESS_KEY"
|
|
14
|
+
SESSION_TOKEN = "DHCORE_AWS_SESSION_TOKEN"
|
|
15
|
+
BUCKET_NAME = "DHCORE_S3_BUCKET"
|
|
16
|
+
REGION = "DHCORE_S3_REGION"
|
|
17
|
+
SIGNATURE_VERSION = "DHCORE_S3_SIGNATURE_VERSION"
|