digitalhub 0.8.0b12__py3-none-any.whl → 0.8.0b14__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/client.py +3 -3
- digitalhub/entities/project/_base/entity.py +51 -12
- digitalhub/entities/project/crud.py +7 -2
- digitalhub/entities/run/_base/builder.py +1 -1
- digitalhub/entities/task/_base/builder.py +1 -1
- digitalhub/utils/io_utils.py +7 -6
- {digitalhub-0.8.0b12.dist-info → digitalhub-0.8.0b14.dist-info}/METADATA +1 -1
- {digitalhub-0.8.0b12.dist-info → digitalhub-0.8.0b14.dist-info}/RECORD +11 -11
- {digitalhub-0.8.0b12.dist-info → digitalhub-0.8.0b14.dist-info}/LICENSE.txt +0 -0
- {digitalhub-0.8.0b12.dist-info → digitalhub-0.8.0b14.dist-info}/WHEEL +0 -0
- {digitalhub-0.8.0b12.dist-info → digitalhub-0.8.0b14.dist-info}/top_level.txt +0 -0
|
@@ -87,7 +87,7 @@ class ClientDHCore(Client):
|
|
|
87
87
|
"""
|
|
88
88
|
if "headers" not in kwargs:
|
|
89
89
|
kwargs["headers"] = {}
|
|
90
|
-
kwargs["headers"][
|
|
90
|
+
kwargs["headers"]["Content-Type"] = "application/json"
|
|
91
91
|
kwargs["data"] = json.dumps(obj, default=ClientDHCore._json_serialize)
|
|
92
92
|
return self._prepare_call("POST", api, **kwargs)
|
|
93
93
|
|
|
@@ -129,7 +129,7 @@ class ClientDHCore(Client):
|
|
|
129
129
|
"""
|
|
130
130
|
if "headers" not in kwargs:
|
|
131
131
|
kwargs["headers"] = {}
|
|
132
|
-
kwargs["headers"][
|
|
132
|
+
kwargs["headers"]["Content-Type"] = "application/json"
|
|
133
133
|
kwargs["data"] = json.dumps(obj, default=ClientDHCore._json_serialize)
|
|
134
134
|
return self._prepare_call("PUT", api, **kwargs)
|
|
135
135
|
|
|
@@ -234,7 +234,7 @@ class ClientDHCore(Client):
|
|
|
234
234
|
"""
|
|
235
235
|
if isinstance(obj, (datetime.datetime, datetime.date)):
|
|
236
236
|
return obj.isoformat()
|
|
237
|
-
raise TypeError
|
|
237
|
+
raise TypeError("Type %s not serializable" % type(obj))
|
|
238
238
|
|
|
239
239
|
def _prepare_call(self, call_type: str, api: str, **kwargs) -> dict:
|
|
240
240
|
"""
|
|
@@ -192,6 +192,7 @@ class Project(Entity):
|
|
|
192
192
|
filename = f"{self.kind}_{self.name}.yml"
|
|
193
193
|
pth = Path(self.spec.context) / filename
|
|
194
194
|
pth.parent.mkdir(parents=True, exist_ok=True)
|
|
195
|
+
|
|
195
196
|
obj = self._export_not_embedded(obj)
|
|
196
197
|
write_yaml(pth, obj)
|
|
197
198
|
return str(pth)
|
|
@@ -226,11 +227,13 @@ class Project(Entity):
|
|
|
226
227
|
"""
|
|
227
228
|
# Cycle over entity types
|
|
228
229
|
for entity_type in self._get_entity_types():
|
|
230
|
+
|
|
229
231
|
# Entity types are stored as a list of entities
|
|
230
232
|
for idx, entity in enumerate(obj.get("spec", {}).get(entity_type, [])):
|
|
233
|
+
|
|
231
234
|
# Export entity if not embedded is in metadata, else do nothing
|
|
232
|
-
|
|
233
|
-
|
|
235
|
+
if not self._is_embedded(entity):
|
|
236
|
+
|
|
234
237
|
# Get entity object from backend
|
|
235
238
|
obj_dict: dict = read_entity_api_ctx(entity["key"])
|
|
236
239
|
|
|
@@ -244,10 +247,15 @@ class Project(Entity):
|
|
|
244
247
|
# Return updated object
|
|
245
248
|
return obj
|
|
246
249
|
|
|
247
|
-
def _import_entities(self) -> None:
|
|
250
|
+
def _import_entities(self, obj: dict) -> None:
|
|
248
251
|
"""
|
|
249
252
|
Import project entities.
|
|
250
253
|
|
|
254
|
+
Parameters
|
|
255
|
+
----------
|
|
256
|
+
obj : dict
|
|
257
|
+
Project object in dictionary format.
|
|
258
|
+
|
|
251
259
|
Returns
|
|
252
260
|
-------
|
|
253
261
|
None
|
|
@@ -256,34 +264,62 @@ class Project(Entity):
|
|
|
256
264
|
|
|
257
265
|
# Cycle over entity types
|
|
258
266
|
for entity_type in entity_types:
|
|
267
|
+
|
|
259
268
|
# Entity types are stored as a list of entities
|
|
260
|
-
for entity in
|
|
261
|
-
|
|
262
|
-
embedded =
|
|
263
|
-
ref =
|
|
269
|
+
for entity in obj.get("spec", {}).get(entity_type, []):
|
|
270
|
+
|
|
271
|
+
embedded = self._is_embedded(entity)
|
|
272
|
+
ref = entity["metadata"].get("ref")
|
|
264
273
|
|
|
265
|
-
# Import entity if not embedded
|
|
274
|
+
# Import entity if not embedded and there is a ref
|
|
266
275
|
if not embedded and ref is not None:
|
|
276
|
+
|
|
267
277
|
# Import entity from local ref
|
|
268
278
|
if map_uri_scheme(ref) == "local":
|
|
269
279
|
try:
|
|
270
280
|
# Artifacts, Dataitems and Models
|
|
271
281
|
if entity_type in entity_types[:3]:
|
|
272
282
|
import_context_entity(ref)
|
|
283
|
+
|
|
273
284
|
# Functions and Workflows
|
|
274
285
|
elif entity_type in entity_types[3:]:
|
|
275
286
|
import_executable_entity(ref)
|
|
287
|
+
|
|
276
288
|
except FileNotFoundError:
|
|
277
289
|
msg = f"File not found: {ref}."
|
|
278
290
|
raise EntityError(msg)
|
|
279
291
|
|
|
280
292
|
# If entity is embedded, create it and try to save
|
|
281
293
|
elif embedded:
|
|
294
|
+
|
|
295
|
+
# It's possible that embedded field in metadata is not shown
|
|
296
|
+
if entity["metadata"].get("embedded") is None:
|
|
297
|
+
entity["metadata"]["embedded"] = True
|
|
298
|
+
|
|
282
299
|
try:
|
|
283
300
|
build_entity_from_dict(entity).save()
|
|
284
301
|
except EntityAlreadyExistsError:
|
|
285
302
|
pass
|
|
286
303
|
|
|
304
|
+
def _is_embedded(self, entity: dict) -> bool:
|
|
305
|
+
"""
|
|
306
|
+
Check if entity is embedded.
|
|
307
|
+
|
|
308
|
+
Parameters
|
|
309
|
+
----------
|
|
310
|
+
entity : dict
|
|
311
|
+
Entity in dictionary format.
|
|
312
|
+
|
|
313
|
+
Returns
|
|
314
|
+
-------
|
|
315
|
+
bool
|
|
316
|
+
True if entity is embedded.
|
|
317
|
+
"""
|
|
318
|
+
metadata_embedded = entity["metadata"].get("embedded", False)
|
|
319
|
+
no_status = entity.get("status", None) is None
|
|
320
|
+
no_spec = entity.get("spec", None) is None
|
|
321
|
+
return metadata_embedded or not (no_status and no_spec)
|
|
322
|
+
|
|
287
323
|
def _get_entity_types(self) -> list[str]:
|
|
288
324
|
"""
|
|
289
325
|
Get entity types.
|
|
@@ -301,7 +337,7 @@ class Project(Entity):
|
|
|
301
337
|
f"{EntityTypes.WORKFLOW.value}s",
|
|
302
338
|
]
|
|
303
339
|
|
|
304
|
-
def run(self, workflow: str | None =
|
|
340
|
+
def run(self, workflow: str | None = None, **kwargs) -> Run:
|
|
305
341
|
"""
|
|
306
342
|
Run workflow project.
|
|
307
343
|
|
|
@@ -318,15 +354,18 @@ class Project(Entity):
|
|
|
318
354
|
Run instance.
|
|
319
355
|
"""
|
|
320
356
|
self.refresh()
|
|
357
|
+
|
|
358
|
+
workflow = workflow if workflow is not None else "main"
|
|
359
|
+
|
|
321
360
|
for i in self.spec.workflows:
|
|
322
|
-
if i["name"]
|
|
323
|
-
|
|
361
|
+
if workflow in [i["name"], i["key"]]:
|
|
362
|
+
entity = self.get_workflow(i["key"])
|
|
324
363
|
break
|
|
325
364
|
else:
|
|
326
365
|
msg = f"Workflow {workflow} not found."
|
|
327
366
|
raise EntityError(msg)
|
|
328
367
|
|
|
329
|
-
return
|
|
368
|
+
return entity.run(**kwargs)
|
|
330
369
|
|
|
331
370
|
##############################
|
|
332
371
|
# Artifacts
|
|
@@ -9,7 +9,7 @@ from digitalhub.context.api import delete_context
|
|
|
9
9
|
from digitalhub.entities._base.api_utils import delete_entity_api_base, read_entity_api_base, update_entity_api_base
|
|
10
10
|
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
11
11
|
from digitalhub.factory.api import build_entity_from_dict, build_entity_from_params
|
|
12
|
-
from digitalhub.utils.exceptions import BackendError, EntityError
|
|
12
|
+
from digitalhub.utils.exceptions import BackendError, EntityAlreadyExistsError, EntityError
|
|
13
13
|
from digitalhub.utils.io_utils import read_yaml
|
|
14
14
|
|
|
15
15
|
if typing.TYPE_CHECKING:
|
|
@@ -151,8 +151,13 @@ def import_project(
|
|
|
151
151
|
obj = build_entity_from_dict(dict_obj)
|
|
152
152
|
obj = _setup_project(obj, setup_kwargs)
|
|
153
153
|
|
|
154
|
+
try:
|
|
155
|
+
obj.save()
|
|
156
|
+
except EntityAlreadyExistsError:
|
|
157
|
+
pass
|
|
158
|
+
|
|
154
159
|
# Import related entities
|
|
155
|
-
obj._import_entities()
|
|
160
|
+
obj._import_entities(dict_obj)
|
|
156
161
|
|
|
157
162
|
return obj
|
|
158
163
|
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
|
-
from digitalhub.entities._base.runtime_entity.builder import
|
|
5
|
+
from digitalhub.entities._base.runtime_entity.builder import EntityError, RuntimeEntityBuilder
|
|
6
6
|
from digitalhub.entities._base.unversioned.builder import UnversionedBuilder
|
|
7
7
|
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
|
-
from digitalhub.entities._base.runtime_entity.builder import
|
|
5
|
+
from digitalhub.entities._base.runtime_entity.builder import EntityError, RuntimeEntityBuilder
|
|
6
6
|
from digitalhub.entities._base.unversioned.builder import UnversionedBuilder
|
|
7
7
|
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
8
8
|
|
digitalhub/utils/io_utils.py
CHANGED
|
@@ -37,7 +37,6 @@ def write_yaml(filepath: str | Path, obj: dict | list[dict]) -> None:
|
|
|
37
37
|
##############################
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
|
|
41
40
|
class NoDatesSafeLoader(yaml.SafeLoader):
|
|
42
41
|
"""
|
|
43
42
|
Loader implementation to exclude implicit resolvers.
|
|
@@ -63,15 +62,17 @@ class NoDatesSafeLoader(yaml.SafeLoader):
|
|
|
63
62
|
-------
|
|
64
63
|
None
|
|
65
64
|
"""
|
|
66
|
-
if not
|
|
65
|
+
if not "yaml_implicit_resolvers" in cls.__dict__:
|
|
67
66
|
cls.yaml_implicit_resolvers = cls.yaml_implicit_resolvers.copy()
|
|
68
67
|
|
|
69
68
|
for first_letter, mappings in cls.yaml_implicit_resolvers.items():
|
|
70
|
-
cls.yaml_implicit_resolvers[first_letter] = [
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
cls.yaml_implicit_resolvers[first_letter] = [
|
|
70
|
+
(tag, regexp) for tag, regexp in mappings if tag != tag_to_remove
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
NoDatesSafeLoader.remove_implicit_resolver("tag:yaml.org,2002:timestamp")
|
|
73
75
|
|
|
74
|
-
NoDatesSafeLoader.remove_implicit_resolver('tag:yaml.org,2002:timestamp')
|
|
75
76
|
|
|
76
77
|
def read_yaml(filepath: str | Path) -> dict | list[dict]:
|
|
77
78
|
"""
|
|
@@ -5,7 +5,7 @@ digitalhub/client/builder.py,sha256=83PoMCus4s4nbkoWmvcjW2hIpXbNx74sUW93wgQgbuo,
|
|
|
5
5
|
digitalhub/client/_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
digitalhub/client/_base/client.py,sha256=HDv9Vr9DZpoaZVsAT5SSBD9j1oHoVuxA4ILGDl0mBz4,1299
|
|
7
7
|
digitalhub/client/dhcore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
digitalhub/client/dhcore/client.py,sha256=
|
|
8
|
+
digitalhub/client/dhcore/client.py,sha256=eh-IQu72Kz4K82uUlMRtatQAQNymvOCMJZZPjB9TdqQ,19169
|
|
9
9
|
digitalhub/client/dhcore/env.py,sha256=F5A5dPTliwd4UUbpw7hQQ3hoVjZYjcVF8MbniTuTFHE,563
|
|
10
10
|
digitalhub/client/dhcore/models.py,sha256=KiTg5xR8EzI7Xa1pmYmzixabLdnqlnn5kn-IILZDGIw,900
|
|
11
11
|
digitalhub/client/dhcore/utils.py,sha256=TaLjA3LT6heKpPclmufZx-kZKZNOe4OzS_Jtpj2S5wY,2990
|
|
@@ -136,16 +136,16 @@ digitalhub/entities/model/sklearn/entity.py,sha256=pPy4mOqOmbkqNkKFUnhrsIQNt2mGN
|
|
|
136
136
|
digitalhub/entities/model/sklearn/spec.py,sha256=Md0aKlfNHZ2fhZbJgp9wZxF0Hu6XIkcniQHCgwoRdkk,301
|
|
137
137
|
digitalhub/entities/model/sklearn/status.py,sha256=eqkPPtERX-6_BjPb_GD8j1FIeavpl43k-dfXZGqzGI0,187
|
|
138
138
|
digitalhub/entities/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
139
|
-
digitalhub/entities/project/crud.py,sha256=
|
|
139
|
+
digitalhub/entities/project/crud.py,sha256=P2IhKR2-YNmiNy0rpu0PG-LKD9nJGKsAahxvhsovmJA,8971
|
|
140
140
|
digitalhub/entities/project/_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
141
141
|
digitalhub/entities/project/_base/builder.py,sha256=Fx_p8M75SkE_ssVBvKGu45wwqwqAZ5N6l6UZZj9LSNc,3612
|
|
142
|
-
digitalhub/entities/project/_base/entity.py,sha256=
|
|
142
|
+
digitalhub/entities/project/_base/entity.py,sha256=OZ4vH38ORWTdYS6yE4sxc0jdIpqgKszDJp_IrpeQJMQ,53559
|
|
143
143
|
digitalhub/entities/project/_base/spec.py,sha256=zRJKFztK7z79LU4spxX7Rykv_1sK6kV9F9Qg95HBc6s,1346
|
|
144
144
|
digitalhub/entities/project/_base/status.py,sha256=w1Hj_yFwr_5X7ZH7SmtZRto4qUdCWb010viFfvbqX48,168
|
|
145
145
|
digitalhub/entities/run/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
146
146
|
digitalhub/entities/run/crud.py,sha256=F-t9pI0NPKt0430SwGMdL7ky2eprXqUf6UUz9GzCgGQ,4369
|
|
147
147
|
digitalhub/entities/run/_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
148
|
-
digitalhub/entities/run/_base/builder.py,sha256=
|
|
148
|
+
digitalhub/entities/run/_base/builder.py,sha256=T1kRlKHQlKPRepXIFr_hecaOmaS6E49L45WZvE7yCpo,2427
|
|
149
149
|
digitalhub/entities/run/_base/entity.py,sha256=H0YViqBYxLQRDnqXUNXoUrxnfxd6Q5jJJu0hCeus4ig,7894
|
|
150
150
|
digitalhub/entities/run/_base/spec.py,sha256=XXPZ5Fl5yLA74XCiuaCjdDGIqMIQ7K1a5cVnDXuohec,1388
|
|
151
151
|
digitalhub/entities/run/_base/status.py,sha256=_oqF8AM-N6XGi-xc-xgthdmCpsuI_rGgVaNKgQ4UDJQ,160
|
|
@@ -159,7 +159,7 @@ digitalhub/entities/secret/_base/status.py,sha256=TK9CUKA6eg9qegqgR9t-u1g-vEeFGB
|
|
|
159
159
|
digitalhub/entities/task/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
160
160
|
digitalhub/entities/task/crud.py,sha256=_DOnCpuBNPWgk4RP1wvgAxNiEa8Bh3MzHQpkRNyqKjk,4666
|
|
161
161
|
digitalhub/entities/task/_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
162
|
-
digitalhub/entities/task/_base/builder.py,sha256=
|
|
162
|
+
digitalhub/entities/task/_base/builder.py,sha256=8NXl9Mp3zjHd1E3mawUVjzOcccpcUE18_dkLMhehVBA,2320
|
|
163
163
|
digitalhub/entities/task/_base/entity.py,sha256=ihGyXV_MDNUnmNOj5uWSkHA2IR8UAF_jfmFQyTH1DH8,3127
|
|
164
164
|
digitalhub/entities/task/_base/models.py,sha256=Vkequ03zsI1n4L-VGO0vMYDnrhK63rB5I0NshB3s6k4,4254
|
|
165
165
|
digitalhub/entities/task/_base/spec.py,sha256=wc9-i0VguS99WG4jQhYF3s2d_mwwtg_Yrkm8RbDa_vk,1289
|
|
@@ -211,7 +211,7 @@ digitalhub/utils/exceptions.py,sha256=MjLhgaGSAe0oJXoR-dnEtAh02RYDj3wZ1ZS1SLFUD4
|
|
|
211
211
|
digitalhub/utils/file_utils.py,sha256=Qe71D2b6mOil_Y0Hy2QCJbnIaQOyXvhjFRbJoZXhsGQ,4006
|
|
212
212
|
digitalhub/utils/generic_utils.py,sha256=YHWCCF77JFqgm4TNr3_U2GbX4SjEQjUmxA6i9PkRqG8,3527
|
|
213
213
|
digitalhub/utils/git_utils.py,sha256=aFYL1cpfY-2VnlW7eHmjjjlTLECc5UUUfjb_IQPOY5k,3244
|
|
214
|
-
digitalhub/utils/io_utils.py,sha256=
|
|
214
|
+
digitalhub/utils/io_utils.py,sha256=Yg24Lt_0aAUaj4Yv5-1iy7VIA0umLxQGW6lkDRWcjrE,2997
|
|
215
215
|
digitalhub/utils/logger.py,sha256=ml3ne6D8wuRdNZ4F6ywmvWotSxjmZWnmKgNiuHb4R5M,437
|
|
216
216
|
digitalhub/utils/s3_utils.py,sha256=oXLzp4K7o45IwK0XOMt4OElDyB09fKRic5WTNA82WUA,1113
|
|
217
217
|
digitalhub/utils/uri_utils.py,sha256=wArWRQ3ygGUNHexGKP3YM-aBE7TyGxhPvfEc7R4T4p4,1144
|
|
@@ -224,8 +224,8 @@ test/local/CRUD/test_artifacts.py,sha256=Y3J_C7SDRSsQd2SGIZjPIOvyTL92B1sTFrUONG3
|
|
|
224
224
|
test/local/CRUD/test_dataitems.py,sha256=LQqTzI59uwTGy4zoq8jL0yWVe2W9vXlatkgDU9aB6xg,2968
|
|
225
225
|
test/local/CRUD/test_models.py,sha256=msosbZuRwIMbZtmi3ZaOva4TjQ4lrzkNu9AguIFhrSo,2929
|
|
226
226
|
test/local/imports/test_imports.py,sha256=W-YugO0rpJwvtWp57MXaXfEmE-f5iWuCiLY-n0ZU4z8,1271
|
|
227
|
-
digitalhub-0.8.
|
|
228
|
-
digitalhub-0.8.
|
|
229
|
-
digitalhub-0.8.
|
|
230
|
-
digitalhub-0.8.
|
|
231
|
-
digitalhub-0.8.
|
|
227
|
+
digitalhub-0.8.0b14.dist-info/LICENSE.txt,sha256=_yVOtnbW7Ss28mp058UEEc1X4Rgj8-kQBP_kj8_Sc88,11585
|
|
228
|
+
digitalhub-0.8.0b14.dist-info/METADATA,sha256=ZCqntN3pfX1zYGBO3TwzSli4gxGmsyqB8dnJZXXL8Jk,15289
|
|
229
|
+
digitalhub-0.8.0b14.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
230
|
+
digitalhub-0.8.0b14.dist-info/top_level.txt,sha256=ae9pDfCF27ZoaVAxuBKONMP0lm5P-N_I-e-no1WlvD8,16
|
|
231
|
+
digitalhub-0.8.0b14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|