digitalhub 0.8.0b6__py3-none-any.whl → 0.8.0b7__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.

@@ -10,9 +10,20 @@ class Status(Base):
10
10
  for example, the state of a RUNNING run, and eventual error message.
11
11
  """
12
12
 
13
- def __init__(self, state: str, message: str | None = None) -> None:
13
+ def __init__(
14
+ self,
15
+ state: str,
16
+ message: str | None = None,
17
+ transitions: list[dict] | None = None,
18
+ k8s: dict | None = None,
19
+ **kwargs,
20
+ ) -> None:
14
21
  self.state = state
15
22
  self.message = message
23
+ self.transitions = transitions
24
+ self.k8s = k8s
25
+
26
+ self._any_setter(**kwargs)
16
27
 
17
28
  @classmethod
18
29
  def from_dict(cls, obj: dict) -> Status:
@@ -165,11 +165,6 @@ class Run(UnversionedEntity):
165
165
  """
166
166
  if not self._context().local and not self.spec.local_execution:
167
167
  return stop_api(self.project, self.ENTITY_TYPE, self.id)
168
- try:
169
- self.status.stop()
170
- except AttributeError:
171
- raise EntityError("Stop is not supported in local execution.")
172
- return
173
168
 
174
169
  def resume(self) -> None:
175
170
  """
@@ -181,14 +176,6 @@ class Run(UnversionedEntity):
181
176
  """
182
177
  if not self._context().local and not self.spec.local_execution:
183
178
  return resume_api(self.project, self.ENTITY_TYPE, self.id)
184
-
185
- try:
186
- self.status.resume()
187
- except AttributeError:
188
- raise EntityError("Resume is not supported in local execution.")
189
- return
190
- # re-run
191
- # TODO verify the logic and order
192
179
  self.run()
193
180
 
194
181
  ##############################
@@ -1,24 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
- import typing
4
-
5
3
  from digitalhub.entities._base.entity.spec import Spec, SpecValidator
6
- from digitalhub.entities.artifact.crud import get_artifact
7
- from digitalhub.entities.dataitem.crud import get_dataitem
8
- from digitalhub.entities.model.crud import get_model
9
4
  from digitalhub.entities.task._base.models import K8s
10
- from digitalhub.entities.utils.entity_types import EntityTypes
11
- from digitalhub.entities.utils.utils import parse_entity_key
12
-
13
- if typing.TYPE_CHECKING:
14
- from digitalhub.entities._base.entity.entity import Entity
15
-
16
-
17
- ENTITY_FUNC = {
18
- EntityTypes.ARTIFACT.value: get_artifact,
19
- EntityTypes.DATAITEM.value: get_dataitem,
20
- EntityTypes.MODEL.value: get_model,
21
- }
22
5
 
23
6
 
24
7
  class RunSpec(Spec):
@@ -51,92 +34,6 @@ class RunSpec(Spec):
51
34
  self.secrets = secrets
52
35
  self.profile = profile
53
36
 
54
- def get_inputs(self, as_dict: bool = False) -> dict:
55
- """
56
- Get inputs.
57
-
58
- Returns
59
- -------
60
- dict
61
- The inputs.
62
- """
63
- inputs = {}
64
- if not hasattr(self, "inputs") or self.inputs is None:
65
- return inputs
66
-
67
- for parameter, item in self.inputs.items():
68
- parameter_type = self._parse_parameter(parameter)
69
-
70
- # Get entity from key
71
- if parameter_type == "key":
72
- key = self._collect_key(item)
73
- entity = self._collect_entity(key)
74
- if as_dict:
75
- entity = entity.to_dict()
76
- inputs[parameter] = entity
77
-
78
- # Create entity from parameter
79
- elif parameter_type == "create":
80
- raise NotImplementedError
81
-
82
- return inputs
83
-
84
- @staticmethod
85
- def _parse_parameter(parameter: str) -> str:
86
- """
87
- Parse parameter.
88
-
89
- Parameters
90
- ----------
91
- parameter : str
92
- Parameter.
93
-
94
- Returns
95
- -------
96
- str
97
- The parsed parameter.
98
- """
99
- if len(parameter.split(":")) == 1:
100
- return "key"
101
- return "create"
102
-
103
- @staticmethod
104
- def _collect_key(item: str | dict) -> str:
105
- """
106
- Collect key from item.
107
-
108
- Parameters
109
- ----------
110
- item : str | dict
111
- Key or dict representation of the entity.
112
-
113
- Returns
114
- -------
115
- str
116
- The key.
117
- """
118
- if isinstance(item, str):
119
- return item
120
- return item.get("key")
121
-
122
- @staticmethod
123
- def _collect_entity(key: str) -> Entity:
124
- """
125
- Collect entity from key.
126
-
127
- Parameters
128
- ----------
129
- key : str
130
- Key of the entity.
131
-
132
- Returns
133
- -------
134
- Entity
135
- The entity.
136
- """
137
- _, entity_type, _, _, _ = parse_entity_key(key)
138
- return ENTITY_FUNC[entity_type](key)
139
-
140
37
 
141
38
  class RunValidator(SpecValidator, K8s):
142
39
  """
@@ -1,114 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from digitalhub.entities._base.entity.status import Status
4
- from digitalhub.entities.artifact.crud import get_artifact
5
- from digitalhub.entities.dataitem.crud import get_dataitem
6
- from digitalhub.entities.model.crud import get_model
7
- from digitalhub.entities.utils.entity_types import EntityTypes
8
- from digitalhub.entities.utils.utils import parse_entity_key
9
-
10
- ENTITY_FUNC = {
11
- EntityTypes.ARTIFACT.value: get_artifact,
12
- EntityTypes.DATAITEM.value: get_dataitem,
13
- EntityTypes.MODEL.value: get_model,
14
- }
15
4
 
16
5
 
17
6
  class RunStatus(Status):
18
7
  """
19
8
  RunStatus status.
20
9
  """
21
-
22
- def __init__(
23
- self,
24
- state: str,
25
- message: str | None = None,
26
- outputs: list | None = None,
27
- results: dict | None = None,
28
- **kwargs,
29
- ) -> None:
30
- super().__init__(state, message)
31
- self.outputs = outputs
32
- self.results = results
33
-
34
- self._any_setter(**kwargs)
35
-
36
- def get_results(self) -> dict:
37
- """
38
- Get results.
39
-
40
- Returns
41
- -------
42
- dict
43
- The results.
44
- """
45
- if not hasattr(self, "results") or self.results is None:
46
- return {}
47
- return self.results
48
-
49
- def get_outputs(self, as_key: bool = False, as_dict: bool = False) -> dict:
50
- """
51
- Get outputs.
52
-
53
- Parameters
54
- ----------
55
- as_key : bool
56
- If True, return outputs as keys.
57
- as_dict : bool
58
- If True, return outputs as dictionaries.
59
-
60
- Returns
61
- -------
62
- dict
63
- The outputs.
64
- """
65
- outputs = {}
66
- if not hasattr(self, "outputs") or self.outputs is None:
67
- return outputs
68
-
69
- for parameter, key in self.outputs.items():
70
- entity_type = self._get_entity_type(key)
71
- entity = ENTITY_FUNC[entity_type](key)
72
- if as_key:
73
- entity = entity.key
74
- if as_dict:
75
- entity = entity.to_dict()
76
- outputs[parameter] = entity
77
-
78
- return outputs
79
-
80
- @staticmethod
81
- def _get_entity_type(key: str) -> str:
82
- """
83
- Get entity type.
84
-
85
- Parameters
86
- ----------
87
- key : str
88
- The key of the entity.
89
-
90
- Returns
91
- -------
92
- str
93
- The entity type.
94
- """
95
- _, entity_type, _, _, _ = parse_entity_key(key)
96
- return entity_type
97
-
98
- def get_values(self, values_list: list) -> dict:
99
- """
100
- Get values.
101
-
102
- Parameters
103
- ----------
104
- values_list : list
105
- The values list to search in.
106
-
107
- Returns
108
- -------
109
- dict
110
- The values.
111
- """
112
- if not hasattr(self, "results") or self.results is None:
113
- return {}
114
- return {k: v for k, v in self.get_results().items() if k in values_list}
@@ -62,7 +62,7 @@ class SecretSecretBuilder(VersionedBuilder):
62
62
  description=description,
63
63
  labels=labels,
64
64
  )
65
- path = f"kubernetes://dhcore-proj-secrets-{project}/{name}"
65
+ path = f"secret://{name}"
66
66
  provider = "kubernetes"
67
67
  spec = self.build_spec(
68
68
  path=path,
@@ -182,3 +182,21 @@ def build_log_path_from_source(
182
182
  path += f"/{Path(source).name}"
183
183
 
184
184
  return path
185
+
186
+
187
+ def get_entity_type_from_key(key: str) -> str:
188
+ """
189
+ Get entity type.
190
+
191
+ Parameters
192
+ ----------
193
+ key : str
194
+ The key of the entity.
195
+
196
+ Returns
197
+ -------
198
+ str
199
+ The entity type.
200
+ """
201
+ _, entity_type, _, _, _ = parse_entity_key(key)
202
+ return entity_type
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: digitalhub
3
- Version: 0.8.0b6
3
+ Version: 0.8.0b7
4
4
  Summary: Python SDK for Digitalhub
5
5
  Author-email: Fondazione Bruno Kessler <dslab@fbk.eu>, Matteo Martini <mmartini@fbk.eu>
6
6
  License: Apache License
@@ -38,7 +38,7 @@ digitalhub/entities/_base/entity/builder.py,sha256=ZuccRGQaLYyjlDPNR3wi6_9YB4DHE
38
38
  digitalhub/entities/_base/entity/entity.py,sha256=273GKmR7dlckvTSHPTFAhvhd-VhHJy2116iooPI_8ug,2744
39
39
  digitalhub/entities/_base/entity/metadata.py,sha256=ew0pFBH0u8m5QjkcL21KboRhBkJAJQDl6EjCeiegyEc,1690
40
40
  digitalhub/entities/_base/entity/spec.py,sha256=yY6ScqZGRb-Sbw97g-OQ0GPHmmOX6HGYBDkvax6PKkc,1338
41
- digitalhub/entities/_base/entity/status.py,sha256=UFr-9c1t--3PJDWTYmgsPhuaV0IeHGiUDN0-P_e8JE4,817
41
+ digitalhub/entities/_base/entity/status.py,sha256=NHB1kLHefoMhhkt_2BFPNojbWMW_Nc8TTGFQNOiyOt0,1044
42
42
  digitalhub/entities/_base/entity/_constructors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  digitalhub/entities/_base/entity/_constructors/metadata.py,sha256=IGB1l6EJ1xlnGMdeL-b04kT4tFd_h5lJgo5MXzv3h9o,1058
44
44
  digitalhub/entities/_base/entity/_constructors/name.py,sha256=sNU54TzzdYug5sqio8uaus6pP5RkEJYIEl6j0fwR4ho,485
@@ -148,14 +148,14 @@ digitalhub/entities/run/builder.py,sha256=Cx8dg_hytb3E0cGhqlpVUNHlQtydXmzP5AT-oq
148
148
  digitalhub/entities/run/crud.py,sha256=TE8xbcA8VmUO0Po89yafdIpXNRKM-ZS6mYbRNjPUS4A,5017
149
149
  digitalhub/entities/run/_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
150
150
  digitalhub/entities/run/_base/builder.py,sha256=UVWaCiI-dXw0YB5_R2hko1FIa4y7qi8t2HkxEs0-peE,1867
151
- digitalhub/entities/run/_base/entity.py,sha256=O3pX_18Og5YcCQTGT1Y60JTcfpLvmwx1Q7dXsR2DWuY,8291
152
- digitalhub/entities/run/_base/spec.py,sha256=KKIwKBe2asOQq-CKI7NbveGUvYnQfaVrnS92IEJ-e0s,3929
153
- digitalhub/entities/run/_base/status.py,sha256=be2TK_KcLwEA5uhpkQXBQHDTc6bPaaIz3e9UZuVhXq4,2850
151
+ digitalhub/entities/run/_base/entity.py,sha256=VjjJhoWuDwH1cPTLm1OY9BbS1KeD8x4TaNkaOW9w_q4,7889
152
+ digitalhub/entities/run/_base/spec.py,sha256=XXPZ5Fl5yLA74XCiuaCjdDGIqMIQ7K1a5cVnDXuohec,1388
153
+ digitalhub/entities/run/_base/status.py,sha256=_oqF8AM-N6XGi-xc-xgthdmCpsuI_rGgVaNKgQ4UDJQ,160
154
154
  digitalhub/entities/secret/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
155
155
  digitalhub/entities/secret/builder.py,sha256=dfSW5dTwiIJJL4w3cIYUJ8f2TPZadX2Qu95xMEyIuVg,1056
156
156
  digitalhub/entities/secret/crud.py,sha256=ACtzUUBDOffxCociSprPqOw7Rq0vnCSQOFop_jq-Qb8,6782
157
157
  digitalhub/entities/secret/_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
158
- digitalhub/entities/secret/_base/builder.py,sha256=dQsUDqTQsTmcDOtkMRHlQNwwxcmPMkB_aT2WWmNnOWM,2197
158
+ digitalhub/entities/secret/_base/builder.py,sha256=Y3mJIVqWezwPgwQX1XABlnazdj7VnUYTND8yHoga0Lw,2163
159
159
  digitalhub/entities/secret/_base/entity.py,sha256=UF-ibEcnrcaNy_nGCrxxyoJqVrcAfyq3ZFUP-sTiEgw,2035
160
160
  digitalhub/entities/secret/_base/spec.py,sha256=Ol4bDVd2lR6uUUtFj80YNSgtRsnfYGE3C7UN2c_LUsc,727
161
161
  digitalhub/entities/secret/_base/status.py,sha256=TK9CUKA6eg9qegqgR9t-u1g-vEeFGB6v5dN9YJNukw8,166
@@ -172,7 +172,7 @@ digitalhub/entities/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
172
172
  digitalhub/entities/utils/api.py,sha256=jSNYoLzoYSvu2wI-fs6u87AFYGAaboPCX4y6f2LqJ5A,6597
173
173
  digitalhub/entities/utils/entity_types.py,sha256=PcAh78WAC9DgwSU6LxGncn0g7Wzb0iZXc-3Ooik8-ks,324
174
174
  digitalhub/entities/utils/state.py,sha256=gKxDy__MEHlz-1SrwICZnFOIqDoI-CBo4ylIBM9TaoQ,609
175
- digitalhub/entities/utils/utils.py,sha256=HD4tQcx8MQ8YVjz9aIgUHgYIk1t4Q9AlkhaY0NgN8Mg,4193
175
+ digitalhub/entities/utils/utils.py,sha256=_ZGe4xAO8uSwb2EZqH0nhA3nasaLOzj3x4vw8MvoAU0,4488
176
176
  digitalhub/entities/workflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
177
177
  digitalhub/entities/workflow/builder.py,sha256=mNQ49ziCx6mOqRsn_m9WUbD5kApi93b67uTqAO5zsts,1072
178
178
  digitalhub/entities/workflow/crud.py,sha256=071LtHfFt6W08ScFKuulzHglQlEUB0wIdCN56jq_1-g,6792
@@ -226,8 +226,8 @@ test/local/CRUD/test_artifacts.py,sha256=Y3J_C7SDRSsQd2SGIZjPIOvyTL92B1sTFrUONG3
226
226
  test/local/CRUD/test_dataitems.py,sha256=LQqTzI59uwTGy4zoq8jL0yWVe2W9vXlatkgDU9aB6xg,2968
227
227
  test/local/CRUD/test_models.py,sha256=msosbZuRwIMbZtmi3ZaOva4TjQ4lrzkNu9AguIFhrSo,2929
228
228
  test/local/imports/test_imports.py,sha256=W-YugO0rpJwvtWp57MXaXfEmE-f5iWuCiLY-n0ZU4z8,1271
229
- digitalhub-0.8.0b6.dist-info/LICENSE.txt,sha256=_yVOtnbW7Ss28mp058UEEc1X4Rgj8-kQBP_kj8_Sc88,11585
230
- digitalhub-0.8.0b6.dist-info/METADATA,sha256=x3PXhMDTlwLKyHd6Zx0nStqBQ5EdFP3VYJxdv2_CC7c,15288
231
- digitalhub-0.8.0b6.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
232
- digitalhub-0.8.0b6.dist-info/top_level.txt,sha256=ae9pDfCF27ZoaVAxuBKONMP0lm5P-N_I-e-no1WlvD8,16
233
- digitalhub-0.8.0b6.dist-info/RECORD,,
229
+ digitalhub-0.8.0b7.dist-info/LICENSE.txt,sha256=_yVOtnbW7Ss28mp058UEEc1X4Rgj8-kQBP_kj8_Sc88,11585
230
+ digitalhub-0.8.0b7.dist-info/METADATA,sha256=bfLOdtv673n9rN-LCUjKFgwKwj_ZhQdTDrL0xQMrj-s,15288
231
+ digitalhub-0.8.0b7.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
232
+ digitalhub-0.8.0b7.dist-info/top_level.txt,sha256=ae9pDfCF27ZoaVAxuBKONMP0lm5P-N_I-e-no1WlvD8,16
233
+ digitalhub-0.8.0b7.dist-info/RECORD,,