digitalhub 0.8.0b13__py3-none-any.whl → 0.8.0b15__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/context/api.py +2 -2
- digitalhub/entities/_base/crud.py +68 -6
- digitalhub/entities/project/_base/entity.py +12 -7
- digitalhub/utils/exceptions.py +6 -0
- digitalhub/utils/io_utils.py +1 -1
- {digitalhub-0.8.0b13.dist-info → digitalhub-0.8.0b15.dist-info}/METADATA +1 -1
- {digitalhub-0.8.0b13.dist-info → digitalhub-0.8.0b15.dist-info}/RECORD +10 -10
- {digitalhub-0.8.0b13.dist-info → digitalhub-0.8.0b15.dist-info}/LICENSE.txt +0 -0
- {digitalhub-0.8.0b13.dist-info → digitalhub-0.8.0b15.dist-info}/WHEEL +0 -0
- {digitalhub-0.8.0b13.dist-info → digitalhub-0.8.0b15.dist-info}/top_level.txt +0 -0
digitalhub/context/api.py
CHANGED
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
5
|
from digitalhub.context.builder import context_builder
|
|
6
|
+
from digitalhub.utils.exceptions import ContextError
|
|
6
7
|
|
|
7
8
|
if typing.TYPE_CHECKING:
|
|
8
9
|
from digitalhub.context.context import Context
|
|
@@ -24,8 +25,7 @@ def check_context(project: str) -> None:
|
|
|
24
25
|
True if the project is in the context, False otherwise.
|
|
25
26
|
"""
|
|
26
27
|
if project not in context_builder._instances:
|
|
27
|
-
|
|
28
|
-
raise RuntimeError(msg)
|
|
28
|
+
raise ContextError
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def set_context(project: Project) -> None:
|
|
@@ -2,15 +2,19 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
|
+
from digitalhub.client.api import build_client, get_client
|
|
5
6
|
from digitalhub.context.api import check_context
|
|
6
7
|
from digitalhub.entities._base.api_utils import (
|
|
7
8
|
delete_entity_api_ctx,
|
|
8
9
|
list_entity_api_ctx,
|
|
10
|
+
read_entity_api_base,
|
|
9
11
|
read_entity_api_ctx,
|
|
10
12
|
read_entity_api_ctx_versions,
|
|
11
13
|
)
|
|
14
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
15
|
+
from digitalhub.entities.utils.utils import parse_entity_key
|
|
12
16
|
from digitalhub.factory.api import build_entity_from_dict, build_entity_from_params
|
|
13
|
-
from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityError
|
|
17
|
+
from digitalhub.utils.exceptions import ContextError, EntityAlreadyExistsError, EntityError, EntityNotExistsError
|
|
14
18
|
from digitalhub.utils.io_utils import read_yaml
|
|
15
19
|
|
|
16
20
|
if typing.TYPE_CHECKING:
|
|
@@ -21,6 +25,58 @@ if typing.TYPE_CHECKING:
|
|
|
21
25
|
from digitalhub.entities._base.versioned.entity import VersionedEntity
|
|
22
26
|
|
|
23
27
|
|
|
28
|
+
def _check_context(project: str) -> None:
|
|
29
|
+
"""
|
|
30
|
+
Check if the given project is in the context.
|
|
31
|
+
Otherwise try to get the project from remote.
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
project : str
|
|
36
|
+
Project name.
|
|
37
|
+
|
|
38
|
+
Returns
|
|
39
|
+
-------
|
|
40
|
+
None
|
|
41
|
+
"""
|
|
42
|
+
try:
|
|
43
|
+
check_context(project)
|
|
44
|
+
except ContextError:
|
|
45
|
+
try:
|
|
46
|
+
build_client()
|
|
47
|
+
client = get_client()
|
|
48
|
+
obj = read_entity_api_base(client, EntityTypes.PROJECT.value, project)
|
|
49
|
+
build_entity_from_dict(obj)
|
|
50
|
+
except EntityNotExistsError:
|
|
51
|
+
raise ContextError(f"Project '{project}' not found.")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _check_project_from_identifier(identifier: str, project: str | None = None) -> None:
|
|
55
|
+
"""
|
|
56
|
+
Check if the given project is in the context.
|
|
57
|
+
Otherwise try to get the project from remote.
|
|
58
|
+
|
|
59
|
+
Parameters
|
|
60
|
+
----------
|
|
61
|
+
identifier : str
|
|
62
|
+
Entity key (store://...) or entity name.
|
|
63
|
+
project : str
|
|
64
|
+
Project name.
|
|
65
|
+
|
|
66
|
+
Returns
|
|
67
|
+
-------
|
|
68
|
+
None
|
|
69
|
+
"""
|
|
70
|
+
if not identifier.startswith("store://"):
|
|
71
|
+
if project is None:
|
|
72
|
+
raise EntityError("Specify project if you do not specify entity key.")
|
|
73
|
+
|
|
74
|
+
else:
|
|
75
|
+
project, _, _, _, _ = parse_entity_key(identifier)
|
|
76
|
+
|
|
77
|
+
_check_context(project)
|
|
78
|
+
|
|
79
|
+
|
|
24
80
|
def new_context_entity(**kwargs) -> ContextEntity:
|
|
25
81
|
"""
|
|
26
82
|
Create a new object.
|
|
@@ -45,7 +101,7 @@ def new_context_entity(**kwargs) -> ContextEntity:
|
|
|
45
101
|
ContextEntity
|
|
46
102
|
Object instance.
|
|
47
103
|
"""
|
|
48
|
-
|
|
104
|
+
_check_context(kwargs["project"])
|
|
49
105
|
obj = build_entity_from_params(**kwargs)
|
|
50
106
|
obj.save()
|
|
51
107
|
return obj
|
|
@@ -79,6 +135,7 @@ def get_versioned_entity(
|
|
|
79
135
|
VersionedEntity
|
|
80
136
|
Object instance.
|
|
81
137
|
"""
|
|
138
|
+
_check_project_from_identifier(identifier, project)
|
|
82
139
|
obj = read_entity_api_ctx(
|
|
83
140
|
identifier,
|
|
84
141
|
entity_type=entity_type,
|
|
@@ -116,8 +173,8 @@ def get_unversioned_entity(
|
|
|
116
173
|
UnversionedEntity
|
|
117
174
|
Object instance.
|
|
118
175
|
"""
|
|
119
|
-
|
|
120
|
-
|
|
176
|
+
_check_project_from_identifier(identifier, project)
|
|
177
|
+
|
|
121
178
|
obj = read_entity_api_ctx(
|
|
122
179
|
identifier,
|
|
123
180
|
entity_type=entity_type,
|
|
@@ -191,6 +248,7 @@ def get_context_entity_versions(
|
|
|
191
248
|
list[ContextEntity]
|
|
192
249
|
List of object instances.
|
|
193
250
|
"""
|
|
251
|
+
_check_project_from_identifier(identifier, project)
|
|
194
252
|
obj = read_entity_api_ctx_versions(
|
|
195
253
|
identifier,
|
|
196
254
|
entity_type=entity_type,
|
|
@@ -225,6 +283,7 @@ def get_material_entity_versions(
|
|
|
225
283
|
list[MaterialEntity]
|
|
226
284
|
List of object instances.
|
|
227
285
|
"""
|
|
286
|
+
_check_project_from_identifier(identifier, project)
|
|
228
287
|
objs = read_entity_api_ctx_versions(
|
|
229
288
|
identifier,
|
|
230
289
|
entity_type=entity_type,
|
|
@@ -257,6 +316,7 @@ def list_context_entities(project: str, entity_type: str, **kwargs) -> list[Cont
|
|
|
257
316
|
list[ContextEntity]
|
|
258
317
|
List of object instances.
|
|
259
318
|
"""
|
|
319
|
+
_check_context(project)
|
|
260
320
|
objs = list_entity_api_ctx(
|
|
261
321
|
project=project,
|
|
262
322
|
entity_type=entity_type,
|
|
@@ -287,6 +347,7 @@ def list_material_entities(
|
|
|
287
347
|
list[MaterialEntity]
|
|
288
348
|
List of object instances.
|
|
289
349
|
"""
|
|
350
|
+
_check_context(project)
|
|
290
351
|
objs = list_entity_api_ctx(
|
|
291
352
|
project=project,
|
|
292
353
|
entity_type=entity_type,
|
|
@@ -316,7 +377,7 @@ def import_context_entity(file: str) -> ContextEntity:
|
|
|
316
377
|
"""
|
|
317
378
|
dict_obj: dict = read_yaml(file)
|
|
318
379
|
|
|
319
|
-
|
|
380
|
+
_check_context(dict_obj["project"])
|
|
320
381
|
|
|
321
382
|
obj = build_entity_from_dict(dict_obj)
|
|
322
383
|
try:
|
|
@@ -348,7 +409,7 @@ def import_executable_entity(file: str) -> ExecutableEntity:
|
|
|
348
409
|
exec_dict = dict_obj
|
|
349
410
|
tsk_dicts = []
|
|
350
411
|
|
|
351
|
-
|
|
412
|
+
_check_context(exec_dict["project"])
|
|
352
413
|
|
|
353
414
|
obj: ExecutableEntity = build_entity_from_dict(exec_dict)
|
|
354
415
|
|
|
@@ -395,6 +456,7 @@ def delete_entity(
|
|
|
395
456
|
dict
|
|
396
457
|
Response from backend.
|
|
397
458
|
"""
|
|
459
|
+
_check_project_from_identifier(identifier, project)
|
|
398
460
|
return delete_entity_api_ctx(
|
|
399
461
|
identifier=identifier,
|
|
400
462
|
entity_type=entity_type,
|
|
@@ -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)
|
|
@@ -229,8 +230,7 @@ class Project(Entity):
|
|
|
229
230
|
# Entity types are stored as a list of entities
|
|
230
231
|
for idx, entity in enumerate(obj.get("spec", {}).get(entity_type, [])):
|
|
231
232
|
# Export entity if not embedded is in metadata, else do nothing
|
|
232
|
-
|
|
233
|
-
if not embedded:
|
|
233
|
+
if not self._is_embedded(entity):
|
|
234
234
|
# Get entity object from backend
|
|
235
235
|
obj_dict: dict = read_entity_api_ctx(entity["key"])
|
|
236
236
|
|
|
@@ -266,7 +266,7 @@ class Project(Entity):
|
|
|
266
266
|
embedded = self._is_embedded(entity)
|
|
267
267
|
ref = entity["metadata"].get("ref")
|
|
268
268
|
|
|
269
|
-
# Import entity if not embedded
|
|
269
|
+
# Import entity if not embedded and there is a ref
|
|
270
270
|
if not embedded and ref is not None:
|
|
271
271
|
# Import entity from local ref
|
|
272
272
|
if map_uri_scheme(ref) == "local":
|
|
@@ -274,9 +274,11 @@ class Project(Entity):
|
|
|
274
274
|
# Artifacts, Dataitems and Models
|
|
275
275
|
if entity_type in entity_types[:3]:
|
|
276
276
|
import_context_entity(ref)
|
|
277
|
+
|
|
277
278
|
# Functions and Workflows
|
|
278
279
|
elif entity_type in entity_types[3:]:
|
|
279
280
|
import_executable_entity(ref)
|
|
281
|
+
|
|
280
282
|
except FileNotFoundError:
|
|
281
283
|
msg = f"File not found: {ref}."
|
|
282
284
|
raise EntityError(msg)
|
|
@@ -328,7 +330,7 @@ class Project(Entity):
|
|
|
328
330
|
f"{EntityTypes.WORKFLOW.value}s",
|
|
329
331
|
]
|
|
330
332
|
|
|
331
|
-
def run(self, workflow: str | None =
|
|
333
|
+
def run(self, workflow: str | None = None, **kwargs) -> Run:
|
|
332
334
|
"""
|
|
333
335
|
Run workflow project.
|
|
334
336
|
|
|
@@ -345,15 +347,18 @@ class Project(Entity):
|
|
|
345
347
|
Run instance.
|
|
346
348
|
"""
|
|
347
349
|
self.refresh()
|
|
350
|
+
|
|
351
|
+
workflow = workflow if workflow is not None else "main"
|
|
352
|
+
|
|
348
353
|
for i in self.spec.workflows:
|
|
349
|
-
if i["name"]
|
|
350
|
-
|
|
354
|
+
if workflow in [i["name"], i["key"]]:
|
|
355
|
+
entity = self.get_workflow(i["key"])
|
|
351
356
|
break
|
|
352
357
|
else:
|
|
353
358
|
msg = f"Workflow {workflow} not found."
|
|
354
359
|
raise EntityError(msg)
|
|
355
360
|
|
|
356
|
-
return
|
|
361
|
+
return entity.run(**kwargs)
|
|
357
362
|
|
|
358
363
|
##############################
|
|
359
364
|
# Artifacts
|
digitalhub/utils/exceptions.py
CHANGED
digitalhub/utils/io_utils.py
CHANGED
|
@@ -62,7 +62,7 @@ class NoDatesSafeLoader(yaml.SafeLoader):
|
|
|
62
62
|
-------
|
|
63
63
|
None
|
|
64
64
|
"""
|
|
65
|
-
if
|
|
65
|
+
if "yaml_implicit_resolvers" not in cls.__dict__:
|
|
66
66
|
cls.yaml_implicit_resolvers = cls.yaml_implicit_resolvers.copy()
|
|
67
67
|
|
|
68
68
|
for first_letter, mappings in cls.yaml_implicit_resolvers.items():
|
|
@@ -12,7 +12,7 @@ digitalhub/client/dhcore/utils.py,sha256=TaLjA3LT6heKpPclmufZx-kZKZNOe4OzS_Jtpj2
|
|
|
12
12
|
digitalhub/client/local/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
digitalhub/client/local/client.py,sha256=VBJJVEqbFFb_fzFogoo1kVyifezt0L7d489UTZxV0x8,16780
|
|
14
14
|
digitalhub/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
digitalhub/context/api.py,sha256
|
|
15
|
+
digitalhub/context/api.py,sha256=-76HPxc7ird13HJoOl_-Z_q2l2g8Yv3rcsXjHphn2to,1729
|
|
16
16
|
digitalhub/context/builder.py,sha256=qpw8T-xho80Njf9wNPTooKkwjWuMT30BeKoQUDWm_yc,2132
|
|
17
17
|
digitalhub/context/context.py,sha256=hDZEW4riMjR5-v2zWiirt-Z5puxdc7d_Da6vFhyuRF4,3338
|
|
18
18
|
digitalhub/datastores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -32,7 +32,7 @@ digitalhub/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
|
|
|
32
32
|
digitalhub/entities/builders.py,sha256=wKNC3ly-IUrF9uaSXWQ5cMzEj7JikM467uXIOdgko2c,1951
|
|
33
33
|
digitalhub/entities/_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
34
|
digitalhub/entities/_base/api_utils.py,sha256=cxnQ8Bi1QtHi8pQi-CM8P1zOOuFZbhRf7dWOrrXPX1I,13346
|
|
35
|
-
digitalhub/entities/_base/crud.py,sha256=
|
|
35
|
+
digitalhub/entities/_base/crud.py,sha256=m5A7Fya2DmfGdBis54U5SA--6BVc6WQ3SUhg4nXjaws,10852
|
|
36
36
|
digitalhub/entities/_base/_base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
37
|
digitalhub/entities/_base/_base/entity.py,sha256=DLJHhviHVKCo26jCEYg7iXwkfS9mDBQrHxBtHF_yE-0,2180
|
|
38
38
|
digitalhub/entities/_base/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -139,7 +139,7 @@ digitalhub/entities/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
|
139
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=CA3MqkwJlvnoI0shUIqsf-SsOoTZUA4Z41wnn0jbT5c,53552
|
|
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
|
|
@@ -207,11 +207,11 @@ digitalhub/stores/sql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
|
207
207
|
digitalhub/stores/sql/store.py,sha256=NdELCkP2Rl5ewiRuI4J9eRvTiBzVmpF0cMowZ1NME_8,8654
|
|
208
208
|
digitalhub/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
209
209
|
digitalhub/utils/data_utils.py,sha256=2eETyxml610Ij7uyDnNc3YiELl2WFLIkj3FL4y6EPk8,2733
|
|
210
|
-
digitalhub/utils/exceptions.py,sha256=
|
|
210
|
+
digitalhub/utils/exceptions.py,sha256=4jiWXyt4wNtFGRbcEm17hc7EQmwE8D0RhaeNW1z3EtA,1045
|
|
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=7pe0LwLPblx9Lx5_lugALZ84_eHGDifJ0RchK5fU1io,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.0b15.dist-info/LICENSE.txt,sha256=_yVOtnbW7Ss28mp058UEEc1X4Rgj8-kQBP_kj8_Sc88,11585
|
|
228
|
+
digitalhub-0.8.0b15.dist-info/METADATA,sha256=nv71Q9Q1Ni-cZ3_fVQ4_T1q29zC0nvaOaViNCL19Xes,15289
|
|
229
|
+
digitalhub-0.8.0b15.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
230
|
+
digitalhub-0.8.0b15.dist-info/top_level.txt,sha256=ae9pDfCF27ZoaVAxuBKONMP0lm5P-N_I-e-no1WlvD8,16
|
|
231
|
+
digitalhub-0.8.0b15.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|