digitalhub 0.8.0b2__py3-none-any.whl → 0.8.0b4__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/__init__.py +5 -4
- digitalhub/client/builder.py +3 -3
- digitalhub/client/{objects/dhcore.py → dhcore/client.py} +9 -49
- digitalhub/client/dhcore/env.py +21 -0
- digitalhub/client/dhcore/models.py +46 -0
- digitalhub/{utils/env_utils.py → client/dhcore/utils.py} +1 -13
- digitalhub/client/{objects/local.py → local/client.py} +1 -1
- digitalhub/context/builder.py +1 -1
- digitalhub/context/context.py +1 -1
- digitalhub/datastores/{objects/base.py → _base/datastore.py} +1 -1
- digitalhub/datastores/builder.py +6 -6
- digitalhub/datastores/{objects/local.py → local/datastore.py} +1 -1
- digitalhub/datastores/{objects/remote.py → remote/datastore.py} +1 -1
- digitalhub/datastores/{objects/s3.py → s3/datastore.py} +1 -1
- digitalhub/datastores/{objects/sql.py → sql/datastore.py} +1 -1
- digitalhub/entities/_base/{base.py → _base/entity.py} +1 -1
- digitalhub/entities/_base/{entity/context.py → context/entity.py} +4 -4
- digitalhub/entities/_base/crud.py +3 -3
- digitalhub/entities/_base/entity/{base.py → entity.py} +8 -34
- digitalhub/entities/_base/{metadata.py → entity/metadata.py} +2 -2
- digitalhub/entities/_base/{spec/base.py → entity/spec.py} +11 -11
- digitalhub/entities/_base/{status/base.py → entity/status.py} +2 -2
- digitalhub/entities/_base/executable/__init__.py +0 -0
- digitalhub/entities/_base/{entity/executable.py → executable/entity.py} +55 -31
- digitalhub/entities/_base/material/__init__.py +0 -0
- digitalhub/entities/_base/{entity/material.py → material/entity.py} +4 -4
- digitalhub/entities/_base/{spec/material.py → material/spec.py} +3 -3
- digitalhub/entities/_base/{status/material.py → material/status.py} +1 -1
- digitalhub/entities/_base/unversioned/__init__.py +0 -0
- digitalhub/entities/_base/unversioned/builder.py +66 -0
- digitalhub/entities/_base/unversioned/entity.py +49 -0
- digitalhub/entities/_base/versioned/__init__.py +0 -0
- digitalhub/entities/_base/versioned/builder.py +68 -0
- digitalhub/entities/_base/versioned/entity.py +53 -0
- digitalhub/entities/_builders/entity.py +153 -0
- digitalhub/entities/_builders/metadata.py +5 -21
- digitalhub/entities/_builders/spec.py +11 -21
- digitalhub/entities/_builders/status.py +10 -20
- digitalhub/entities/_builders/uuid.py +4 -11
- digitalhub/entities/artifact/_base/__init__.py +0 -0
- digitalhub/entities/artifact/_base/builder.py +86 -0
- digitalhub/entities/artifact/{entity/_base.py → _base/entity.py} +5 -5
- digitalhub/entities/artifact/_base/spec.py +15 -0
- digitalhub/entities/artifact/_base/status.py +9 -0
- digitalhub/entities/artifact/artifact/__init__.py +0 -0
- digitalhub/entities/artifact/artifact/builder.py +18 -0
- digitalhub/entities/artifact/artifact/entity.py +32 -0
- digitalhub/entities/artifact/{spec.py → artifact/spec.py} +4 -16
- digitalhub/entities/artifact/{status.py → artifact/status.py} +1 -1
- digitalhub/entities/artifact/builder.py +16 -98
- digitalhub/entities/artifact/crud.py +4 -4
- digitalhub/entities/builders.py +63 -0
- digitalhub/entities/dataitem/_base/__init__.py +0 -0
- digitalhub/entities/dataitem/_base/builder.py +86 -0
- digitalhub/entities/dataitem/{entity/_base.py → _base/entity.py} +5 -5
- digitalhub/entities/dataitem/_base/spec.py +15 -0
- digitalhub/entities/dataitem/_base/status.py +20 -0
- digitalhub/entities/dataitem/builder.py +16 -109
- digitalhub/entities/dataitem/crud.py +8 -5
- digitalhub/entities/dataitem/dataitem/__init__.py +0 -0
- digitalhub/entities/dataitem/dataitem/builder.py +18 -0
- digitalhub/entities/dataitem/dataitem/entity.py +32 -0
- digitalhub/entities/dataitem/dataitem/spec.py +15 -0
- digitalhub/entities/dataitem/dataitem/status.py +9 -0
- digitalhub/entities/dataitem/iceberg/__init__.py +0 -0
- digitalhub/entities/dataitem/iceberg/builder.py +18 -0
- digitalhub/entities/dataitem/iceberg/entity.py +32 -0
- digitalhub/entities/dataitem/iceberg/spec.py +15 -0
- digitalhub/entities/dataitem/iceberg/status.py +9 -0
- digitalhub/entities/dataitem/table/__init__.py +0 -0
- digitalhub/entities/dataitem/table/builder.py +18 -0
- digitalhub/entities/dataitem/{entity/table.py → table/entity.py} +24 -3
- digitalhub/entities/dataitem/table/spec.py +25 -0
- digitalhub/entities/dataitem/table/status.py +9 -0
- digitalhub/entities/function/_base/__init__.py +0 -0
- digitalhub/entities/function/_base/builder.py +78 -0
- digitalhub/entities/function/{entity.py → _base/entity.py} +8 -8
- digitalhub/entities/function/{models.py → _base/models.py} +1 -1
- digitalhub/entities/function/_base/spec.py +15 -0
- digitalhub/entities/function/_base/status.py +9 -0
- digitalhub/entities/function/builder.py +22 -57
- digitalhub/entities/function/crud.py +3 -3
- digitalhub/entities/model/_base/__init__.py +0 -0
- digitalhub/entities/model/_base/builder.py +86 -0
- digitalhub/entities/model/{entity/_base.py → _base/entity.py} +5 -5
- digitalhub/entities/model/_base/spec.py +49 -0
- digitalhub/entities/model/_base/status.py +9 -0
- digitalhub/entities/model/builder.py +16 -117
- digitalhub/entities/model/crud.py +4 -4
- digitalhub/entities/model/huggingface/__init__.py +0 -0
- digitalhub/entities/model/huggingface/builder.py +18 -0
- digitalhub/entities/model/huggingface/entity.py +32 -0
- digitalhub/entities/model/huggingface/spec.py +36 -0
- digitalhub/entities/model/huggingface/status.py +9 -0
- digitalhub/entities/model/mlflow/__init__.py +0 -0
- digitalhub/entities/model/mlflow/builder.py +18 -0
- digitalhub/entities/model/mlflow/entity.py +32 -0
- digitalhub/entities/model/mlflow/spec.py +44 -0
- digitalhub/entities/model/mlflow/status.py +9 -0
- digitalhub/entities/model/{entity/mlflow.py → mlflow/utils.py} +1 -10
- digitalhub/entities/model/model/__init__.py +0 -0
- digitalhub/entities/model/model/builder.py +18 -0
- digitalhub/entities/model/model/entity.py +32 -0
- digitalhub/entities/model/model/spec.py +15 -0
- digitalhub/entities/model/model/status.py +9 -0
- digitalhub/entities/model/sklearn/__init__.py +0 -0
- digitalhub/entities/model/sklearn/builder.py +18 -0
- digitalhub/entities/model/sklearn/entity.py +32 -0
- digitalhub/entities/model/sklearn/spec.py +15 -0
- digitalhub/entities/model/sklearn/status.py +9 -0
- digitalhub/entities/project/_base/__init__.py +0 -0
- digitalhub/entities/project/_base/builder.py +128 -0
- digitalhub/entities/project/{entity.py → _base/entity.py} +18 -60
- digitalhub/entities/project/{spec.py → _base/spec.py} +4 -4
- digitalhub/entities/project/_base/status.py +9 -0
- digitalhub/entities/project/builder.py +20 -51
- digitalhub/entities/project/crud.py +2 -2
- digitalhub/entities/run/_base/__init__.py +0 -0
- digitalhub/entities/run/_base/builder.py +73 -0
- digitalhub/entities/run/{entity.py → _base/entity.py} +12 -155
- digitalhub/entities/run/{spec.py → _base/spec.py} +8 -8
- digitalhub/entities/run/{status.py → _base/status.py} +4 -4
- digitalhub/entities/run/builder.py +21 -47
- digitalhub/entities/run/crud.py +3 -3
- digitalhub/entities/secret/_base/__init__.py +0 -0
- digitalhub/entities/secret/_base/builder.py +81 -0
- digitalhub/entities/secret/{entity.py → _base/entity.py} +7 -6
- digitalhub/entities/secret/{spec.py → _base/spec.py} +4 -4
- digitalhub/entities/secret/_base/status.py +9 -0
- digitalhub/entities/secret/builder.py +20 -62
- digitalhub/entities/secret/crud.py +12 -4
- digitalhub/entities/task/_base/__init__.py +0 -0
- digitalhub/entities/task/_base/builder.py +76 -0
- digitalhub/entities/task/{entity.py → _base/entity.py} +6 -6
- digitalhub/entities/task/{models.py → _base/models.py} +9 -0
- digitalhub/entities/task/{spec.py → _base/spec.py} +9 -7
- digitalhub/entities/task/_base/status.py +9 -0
- digitalhub/entities/task/builder.py +21 -44
- digitalhub/entities/task/crud.py +3 -3
- digitalhub/entities/utils/__init__.py +0 -0
- digitalhub/entities/{utils.py → utils/utils.py} +2 -2
- digitalhub/entities/workflow/_base/__init__.py +0 -0
- digitalhub/entities/workflow/_base/builder.py +78 -0
- digitalhub/entities/workflow/{entity.py → _base/entity.py} +8 -8
- digitalhub/entities/workflow/_base/spec.py +15 -0
- digitalhub/entities/workflow/_base/status.py +9 -0
- digitalhub/entities/workflow/builder.py +20 -60
- digitalhub/entities/workflow/crud.py +3 -3
- digitalhub/factory/__init__.py +0 -0
- digitalhub/factory/factory.py +204 -0
- digitalhub/factory/utils.py +90 -0
- digitalhub/readers/_base/__init__.py +0 -0
- digitalhub/readers/builder.py +1 -1
- digitalhub/readers/pandas/__init__.py +0 -0
- digitalhub/readers/{objects/pandas.py → pandas/readers.py} +1 -1
- digitalhub/readers/registry.py +1 -1
- digitalhub/runtimes/builder.py +24 -41
- digitalhub/runtimes/kind_registry.py +14 -0
- digitalhub/runtimes/utils.py +28 -0
- digitalhub/stores/_base/__init__.py +0 -0
- digitalhub/stores/builder.py +6 -6
- digitalhub/stores/local/__init__.py +0 -0
- digitalhub/stores/{objects/local.py → local/store.py} +1 -1
- digitalhub/stores/remote/__init__.py +0 -0
- digitalhub/stores/{objects/remote.py → remote/store.py} +1 -1
- digitalhub/stores/s3/__init__.py +0 -0
- digitalhub/stores/{objects/s3.py → s3/store.py} +1 -1
- digitalhub/stores/sql/__init__.py +0 -0
- digitalhub/stores/{objects/sql.py → sql/store.py} +1 -1
- digitalhub/utils/exceptions.py +6 -0
- digitalhub/utils/generic_utils.py +18 -42
- digitalhub/utils/s3_utils.py +58 -0
- {digitalhub-0.8.0b2.dist-info → digitalhub-0.8.0b4.dist-info}/METADATA +3 -2
- digitalhub-0.8.0b4.dist-info/RECORD +232 -0
- {digitalhub-0.8.0b2.dist-info → digitalhub-0.8.0b4.dist-info}/WHEEL +1 -1
- test/local/CRUD/test_artifacts.py +96 -0
- test/local/CRUD/test_dataitems.py +96 -0
- test/local/CRUD/test_models.py +95 -0
- test/test_crud_functions.py +1 -1
- test/test_crud_runs.py +1 -1
- test/test_crud_tasks.py +1 -1
- digitalhub/entities/_base/entity/unversioned.py +0 -87
- digitalhub/entities/_base/entity/versioned.py +0 -94
- digitalhub/entities/artifact/entity/artifact.py +0 -9
- digitalhub/entities/dataitem/entity/dataitem.py +0 -9
- digitalhub/entities/dataitem/entity/iceberg.py +0 -7
- digitalhub/entities/dataitem/spec.py +0 -61
- digitalhub/entities/dataitem/status.py +0 -38
- digitalhub/entities/function/spec.py +0 -81
- digitalhub/entities/function/status.py +0 -9
- digitalhub/entities/model/entity/huggingface.py +0 -9
- digitalhub/entities/model/entity/model.py +0 -9
- digitalhub/entities/model/entity/sklearn.py +0 -9
- digitalhub/entities/model/spec.py +0 -146
- digitalhub/entities/model/status.py +0 -33
- digitalhub/entities/project/status.py +0 -9
- digitalhub/entities/registries.py +0 -48
- digitalhub/entities/secret/status.py +0 -9
- digitalhub/entities/task/status.py +0 -9
- digitalhub/entities/workflow/spec.py +0 -15
- digitalhub/entities/workflow/status.py +0 -9
- digitalhub/registry/models.py +0 -87
- digitalhub/registry/registry.py +0 -74
- digitalhub/registry/utils.py +0 -150
- digitalhub-0.8.0b2.dist-info/RECORD +0 -161
- test/test_crud_artifacts.py +0 -96
- test/test_crud_dataitems.py +0 -96
- /digitalhub/client/{objects → _base}/__init__.py +0 -0
- /digitalhub/client/{objects/base.py → _base/client.py} +0 -0
- /digitalhub/{datastores/objects → client/dhcore}/__init__.py +0 -0
- /digitalhub/{entities/_base/spec → client/local}/__init__.py +0 -0
- /digitalhub/{entities/_base/status → datastores/_base}/__init__.py +0 -0
- /digitalhub/{entities/artifact/entity → datastores/local}/__init__.py +0 -0
- /digitalhub/{entities/dataitem/entity → datastores/remote}/__init__.py +0 -0
- /digitalhub/{entities/model/entity → datastores/s3}/__init__.py +0 -0
- /digitalhub/{readers/objects → datastores/sql}/__init__.py +0 -0
- /digitalhub/{registry → entities/_base/_base}/__init__.py +0 -0
- /digitalhub/{stores/objects → entities/_base/context}/__init__.py +0 -0
- /digitalhub/entities/dataitem/{models.py → table/models.py} +0 -0
- /digitalhub/entities/model/{models.py → mlflow/models.py} +0 -0
- /digitalhub/entities/{_base → utils}/api.py +0 -0
- /digitalhub/entities/{entity_types.py → utils/entity_types.py} +0 -0
- /digitalhub/entities/{_base → utils}/state.py +0 -0
- /digitalhub/readers/{objects/base.py → _base/readers.py} +0 -0
- /digitalhub/runtimes/{base.py → _base.py} +0 -0
- /digitalhub/stores/{objects/base.py → _base/store.py} +0 -0
- {digitalhub-0.8.0b2.dist-info → digitalhub-0.8.0b4.dist-info}/LICENSE.txt +0 -0
- {digitalhub-0.8.0b2.dist-info → digitalhub-0.8.0b4.dist-info}/top_level.txt +0 -0
- /test/{test_imports.py → local/imports/test_imports.py} +0 -0
|
@@ -1,68 +1,33 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
from digitalhub.entities._builders.name import build_name
|
|
5
|
-
from digitalhub.entities._builders.spec import build_spec
|
|
6
|
-
from digitalhub.entities._builders.status import build_status
|
|
7
|
-
from digitalhub.entities.project.entity import Project
|
|
3
|
+
import typing
|
|
8
4
|
|
|
5
|
+
from digitalhub.factory.factory import factory
|
|
6
|
+
from digitalhub.utils.exceptions import BuilderError
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
local: bool = False,
|
|
16
|
-
context: str | None = None,
|
|
17
|
-
**kwargs,
|
|
18
|
-
) -> Project:
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from digitalhub.entities.project._base.entity import Project
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def project_from_parameters(**kwargs) -> Project:
|
|
19
13
|
"""
|
|
20
14
|
Create a new object.
|
|
21
15
|
|
|
22
16
|
Parameters
|
|
23
17
|
----------
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
kind : str
|
|
27
|
-
Kind the object.
|
|
28
|
-
description : str
|
|
29
|
-
Description of the object (human readable).
|
|
30
|
-
labels : list[str]
|
|
31
|
-
List of labels.
|
|
32
|
-
local : bool
|
|
33
|
-
If True, use local backend, if False use DHCore backend. Default to False.
|
|
34
|
-
context : str
|
|
35
|
-
The context local folder of the project.
|
|
36
|
-
**kwargs : dict
|
|
37
|
-
Spec keyword arguments.
|
|
18
|
+
**kwargs
|
|
19
|
+
Keyword arguments.
|
|
38
20
|
|
|
39
21
|
Returns
|
|
40
22
|
-------
|
|
41
23
|
Project
|
|
42
24
|
Object instance.
|
|
43
25
|
"""
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)
|
|
50
|
-
metadata = build_metadata(
|
|
51
|
-
kind,
|
|
52
|
-
project=name,
|
|
53
|
-
name=name,
|
|
54
|
-
description=description,
|
|
55
|
-
labels=labels,
|
|
56
|
-
)
|
|
57
|
-
status = build_status(kind)
|
|
58
|
-
return Project(
|
|
59
|
-
name=name,
|
|
60
|
-
kind=kind,
|
|
61
|
-
metadata=metadata,
|
|
62
|
-
spec=spec,
|
|
63
|
-
status=status,
|
|
64
|
-
local=local,
|
|
65
|
-
)
|
|
26
|
+
try:
|
|
27
|
+
kind = kwargs["kind"]
|
|
28
|
+
except KeyError:
|
|
29
|
+
raise BuilderError("Missing 'kind' parameter.")
|
|
30
|
+
return factory.build_entity_from_params(kind, **kwargs)
|
|
66
31
|
|
|
67
32
|
|
|
68
33
|
def project_from_dict(obj: dict) -> Project:
|
|
@@ -79,4 +44,8 @@ def project_from_dict(obj: dict) -> Project:
|
|
|
79
44
|
Project
|
|
80
45
|
Object instance.
|
|
81
46
|
"""
|
|
82
|
-
|
|
47
|
+
try:
|
|
48
|
+
kind = obj["kind"]
|
|
49
|
+
except KeyError:
|
|
50
|
+
raise BuilderError("Missing 'kind' parameter.")
|
|
51
|
+
return factory.build_entity_from_dict(kind, obj)
|
|
@@ -7,13 +7,13 @@ from pathlib import Path
|
|
|
7
7
|
from digitalhub.client.builder import build_client, get_client
|
|
8
8
|
from digitalhub.context.builder import delete_context
|
|
9
9
|
from digitalhub.entities._base.crud import delete_entity_api_base, read_entity_api_base, update_entity_api_base
|
|
10
|
-
from digitalhub.entities.entity_types import EntityTypes
|
|
11
10
|
from digitalhub.entities.project.builder import project_from_dict, project_from_parameters
|
|
11
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
12
12
|
from digitalhub.utils.exceptions import BackendError, EntityError
|
|
13
13
|
from digitalhub.utils.io_utils import read_yaml
|
|
14
14
|
|
|
15
15
|
if typing.TYPE_CHECKING:
|
|
16
|
-
from digitalhub.entities.project.entity import Project
|
|
16
|
+
from digitalhub.entities.project._base.entity import Project
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
ENTITY_TYPE = EntityTypes.PROJECT.value
|
|
File without changes
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from digitalhub.entities._base.unversioned.builder import UnversionedBuilder
|
|
6
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from digitalhub.entities.run._base.entity import Run
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class RunBuilder(UnversionedBuilder):
|
|
13
|
+
"""
|
|
14
|
+
Run builder.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
ENTITY_TYPE = EntityTypes.RUN.value
|
|
18
|
+
|
|
19
|
+
def build(
|
|
20
|
+
self,
|
|
21
|
+
project: str,
|
|
22
|
+
kind: str,
|
|
23
|
+
uuid: str | None = None,
|
|
24
|
+
labels: list[str] | None = None,
|
|
25
|
+
task: str | None = None,
|
|
26
|
+
local_execution: bool = False,
|
|
27
|
+
**kwargs,
|
|
28
|
+
) -> Run:
|
|
29
|
+
"""
|
|
30
|
+
Create a new object.
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
project : str
|
|
35
|
+
Project name.
|
|
36
|
+
kind : str
|
|
37
|
+
Kind the object.
|
|
38
|
+
uuid : str
|
|
39
|
+
ID of the object.
|
|
40
|
+
labels : list[str]
|
|
41
|
+
List of labels.
|
|
42
|
+
task : str
|
|
43
|
+
Name of the task associated with the run.
|
|
44
|
+
local_execution : bool
|
|
45
|
+
Flag to determine if object has local execution.
|
|
46
|
+
**kwargs : dict
|
|
47
|
+
Spec keyword arguments.
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
Run
|
|
52
|
+
Object instance.
|
|
53
|
+
"""
|
|
54
|
+
uuid = self.build_uuid(uuid)
|
|
55
|
+
metadata = self.build_metadata(
|
|
56
|
+
project=project,
|
|
57
|
+
name=uuid,
|
|
58
|
+
labels=labels,
|
|
59
|
+
)
|
|
60
|
+
spec = self.build_spec(
|
|
61
|
+
task=task,
|
|
62
|
+
local_execution=local_execution,
|
|
63
|
+
**kwargs,
|
|
64
|
+
)
|
|
65
|
+
status = self.build_status()
|
|
66
|
+
return self.build_entity(
|
|
67
|
+
project=project,
|
|
68
|
+
uuid=uuid,
|
|
69
|
+
kind=kind,
|
|
70
|
+
metadata=metadata,
|
|
71
|
+
spec=spec,
|
|
72
|
+
status=status,
|
|
73
|
+
)
|
|
@@ -2,9 +2,6 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import time
|
|
4
4
|
import typing
|
|
5
|
-
from typing import Any
|
|
6
|
-
|
|
7
|
-
import requests
|
|
8
5
|
|
|
9
6
|
from digitalhub.entities._base.crud import (
|
|
10
7
|
list_entity_api_base,
|
|
@@ -14,22 +11,18 @@ from digitalhub.entities._base.crud import (
|
|
|
14
11
|
resume_api,
|
|
15
12
|
stop_api,
|
|
16
13
|
)
|
|
17
|
-
from digitalhub.entities._base.entity
|
|
18
|
-
from digitalhub.entities.
|
|
19
|
-
from digitalhub.entities.
|
|
20
|
-
from digitalhub.
|
|
21
|
-
from digitalhub.entities.entity_types import EntityTypes
|
|
22
|
-
from digitalhub.registry.registry import registry
|
|
23
|
-
from digitalhub.runtimes.builder import build_runtime
|
|
14
|
+
from digitalhub.entities._base.unversioned.entity import UnversionedEntity
|
|
15
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
16
|
+
from digitalhub.entities.utils.state import State
|
|
17
|
+
from digitalhub.factory.factory import factory
|
|
24
18
|
from digitalhub.utils.exceptions import EntityError
|
|
25
19
|
from digitalhub.utils.logger import LOGGER
|
|
26
20
|
|
|
27
21
|
if typing.TYPE_CHECKING:
|
|
28
|
-
from digitalhub.entities._base.entity.
|
|
29
|
-
from digitalhub.entities._base.
|
|
30
|
-
from digitalhub.entities.run.
|
|
31
|
-
from digitalhub.
|
|
32
|
-
from digitalhub.runtimes.base import Runtime
|
|
22
|
+
from digitalhub.entities._base.entity.metadata import Metadata
|
|
23
|
+
from digitalhub.entities.run._base.spec import RunSpec
|
|
24
|
+
from digitalhub.entities.run._base.status import RunStatus
|
|
25
|
+
from digitalhub.runtimes._base import Runtime
|
|
33
26
|
|
|
34
27
|
|
|
35
28
|
class Run(UnversionedEntity):
|
|
@@ -70,7 +63,7 @@ class Run(UnversionedEntity):
|
|
|
70
63
|
executable = self._get_executable(runtime)
|
|
71
64
|
task = self._get_task(runtime)
|
|
72
65
|
new_spec = runtime.build(executable, task, self.to_dict())
|
|
73
|
-
self.spec = build_spec(
|
|
66
|
+
self.spec = factory.build_spec(
|
|
74
67
|
self.kind,
|
|
75
68
|
**new_spec,
|
|
76
69
|
)
|
|
@@ -147,116 +140,6 @@ class Run(UnversionedEntity):
|
|
|
147
140
|
LOGGER.info(f"Run {self.id} finished in {current:.2f} seconds.")
|
|
148
141
|
return self
|
|
149
142
|
|
|
150
|
-
def inputs(self, as_dict: bool = False) -> list[dict]:
|
|
151
|
-
"""
|
|
152
|
-
Get inputs passed in spec as objects or as dictionaries.
|
|
153
|
-
|
|
154
|
-
Parameters
|
|
155
|
-
----------
|
|
156
|
-
as_dict : bool
|
|
157
|
-
If True, return inputs as dictionaries.
|
|
158
|
-
|
|
159
|
-
Returns
|
|
160
|
-
-------
|
|
161
|
-
list[dict]
|
|
162
|
-
List of input objects.
|
|
163
|
-
"""
|
|
164
|
-
try:
|
|
165
|
-
return self.spec.get_inputs(as_dict=as_dict)
|
|
166
|
-
except AttributeError:
|
|
167
|
-
msg = f"Run of type {self.kind} has no inputs."
|
|
168
|
-
raise EntityError(msg)
|
|
169
|
-
|
|
170
|
-
def results(self) -> dict:
|
|
171
|
-
"""
|
|
172
|
-
Get results from runtime execution.
|
|
173
|
-
|
|
174
|
-
Returns
|
|
175
|
-
-------
|
|
176
|
-
dict
|
|
177
|
-
Results.
|
|
178
|
-
"""
|
|
179
|
-
try:
|
|
180
|
-
return self.status.get_results()
|
|
181
|
-
except AttributeError:
|
|
182
|
-
msg = f"Run of type {self.kind} has no results."
|
|
183
|
-
raise EntityError(msg)
|
|
184
|
-
|
|
185
|
-
def result(self, key: str) -> Any:
|
|
186
|
-
"""
|
|
187
|
-
Get result from runtime execution by key.
|
|
188
|
-
|
|
189
|
-
Parameters
|
|
190
|
-
----------
|
|
191
|
-
key : str
|
|
192
|
-
Key of the result.
|
|
193
|
-
|
|
194
|
-
Returns
|
|
195
|
-
-------
|
|
196
|
-
Any
|
|
197
|
-
Result.
|
|
198
|
-
"""
|
|
199
|
-
return self.results().get(key)
|
|
200
|
-
|
|
201
|
-
def outputs(self, as_key: bool = False, as_dict: bool = False) -> dict:
|
|
202
|
-
"""
|
|
203
|
-
Get run objects results.
|
|
204
|
-
|
|
205
|
-
Parameters
|
|
206
|
-
----------
|
|
207
|
-
as_key : bool
|
|
208
|
-
If True, return results as keys.
|
|
209
|
-
as_dict : bool
|
|
210
|
-
If True, return results as dictionaries.
|
|
211
|
-
|
|
212
|
-
Returns
|
|
213
|
-
-------
|
|
214
|
-
dict
|
|
215
|
-
List of output objects.
|
|
216
|
-
"""
|
|
217
|
-
try:
|
|
218
|
-
return self.status.get_outputs(as_key=as_key, as_dict=as_dict)
|
|
219
|
-
except AttributeError:
|
|
220
|
-
msg = f"Run of type {self.kind} has no outputs."
|
|
221
|
-
raise EntityError(msg)
|
|
222
|
-
|
|
223
|
-
def output(self, key: str, as_key: bool = False, as_dict: bool = False) -> MaterialEntity | dict | str | None:
|
|
224
|
-
"""
|
|
225
|
-
Get run object result by key.
|
|
226
|
-
|
|
227
|
-
Parameters
|
|
228
|
-
----------
|
|
229
|
-
key : str
|
|
230
|
-
Key of the result.
|
|
231
|
-
as_key : bool
|
|
232
|
-
If True, return result as key.
|
|
233
|
-
as_dict : bool
|
|
234
|
-
If True, return result as dictionary.
|
|
235
|
-
|
|
236
|
-
Returns
|
|
237
|
-
-------
|
|
238
|
-
Entity | dict | str | None
|
|
239
|
-
Result.
|
|
240
|
-
"""
|
|
241
|
-
return self.outputs(as_key=as_key, as_dict=as_dict).get(key)
|
|
242
|
-
|
|
243
|
-
def values(self) -> dict:
|
|
244
|
-
"""
|
|
245
|
-
Get values from runtime execution.
|
|
246
|
-
|
|
247
|
-
Returns
|
|
248
|
-
-------
|
|
249
|
-
dict
|
|
250
|
-
Values from backend.
|
|
251
|
-
"""
|
|
252
|
-
try:
|
|
253
|
-
value_list = getattr(self.spec, "values", [])
|
|
254
|
-
value_list = value_list if value_list is not None else []
|
|
255
|
-
return self.status.get_values(value_list)
|
|
256
|
-
except AttributeError:
|
|
257
|
-
msg = f"Run of type {self.kind} has no values."
|
|
258
|
-
raise EntityError(msg)
|
|
259
|
-
|
|
260
143
|
def logs(self) -> dict:
|
|
261
144
|
"""
|
|
262
145
|
Get object from backend.
|
|
@@ -307,32 +190,6 @@ class Run(UnversionedEntity):
|
|
|
307
190
|
# TODO verify the logic and order
|
|
308
191
|
self.run()
|
|
309
192
|
|
|
310
|
-
def invoke(self, **kwargs) -> requests.Response:
|
|
311
|
-
"""
|
|
312
|
-
Invoke run.
|
|
313
|
-
|
|
314
|
-
Parameters
|
|
315
|
-
----------
|
|
316
|
-
kwargs
|
|
317
|
-
Keyword arguments to pass to the request.
|
|
318
|
-
|
|
319
|
-
Returns
|
|
320
|
-
-------
|
|
321
|
-
requests.Response
|
|
322
|
-
Response from service.
|
|
323
|
-
"""
|
|
324
|
-
try:
|
|
325
|
-
if not self._context().local and not self.spec.local_execution:
|
|
326
|
-
local = False
|
|
327
|
-
else:
|
|
328
|
-
local = True
|
|
329
|
-
if kwargs is None:
|
|
330
|
-
kwargs = {}
|
|
331
|
-
return self.status.invoke(local, **kwargs)
|
|
332
|
-
except AttributeError:
|
|
333
|
-
msg = f"Run of type {self.kind} has no invoke operation."
|
|
334
|
-
raise EntityError(msg)
|
|
335
|
-
|
|
336
193
|
##############################
|
|
337
194
|
# Helpers
|
|
338
195
|
##############################
|
|
@@ -361,7 +218,7 @@ class Run(UnversionedEntity):
|
|
|
361
218
|
-------
|
|
362
219
|
None
|
|
363
220
|
"""
|
|
364
|
-
self.status: RunStatus = build_status(self.kind, **status)
|
|
221
|
+
self.status: RunStatus = factory.build_status(self.kind, **status)
|
|
365
222
|
|
|
366
223
|
def _set_state(self, state: str) -> None:
|
|
367
224
|
"""
|
|
@@ -402,7 +259,7 @@ class Run(UnversionedEntity):
|
|
|
402
259
|
Runtime
|
|
403
260
|
Runtime object.
|
|
404
261
|
"""
|
|
405
|
-
return build_runtime(self.kind, self.project)
|
|
262
|
+
return factory.build_runtime(self.kind, self.project)
|
|
406
263
|
|
|
407
264
|
def _get_executable(self, runtime: Runtime) -> dict:
|
|
408
265
|
"""
|
|
@@ -419,7 +276,7 @@ class Run(UnversionedEntity):
|
|
|
419
276
|
Executable (function or workflow) from backend.
|
|
420
277
|
"""
|
|
421
278
|
exec_kind = runtime.get_executable_kind()
|
|
422
|
-
entity_type =
|
|
279
|
+
entity_type = factory.get_entity_type_from_builder(exec_kind)
|
|
423
280
|
splitted = self.spec.task.split("/")
|
|
424
281
|
exec_name = splitted[-1].split(":")[0]
|
|
425
282
|
exec_id = splitted[-1].split(":")[1]
|
|
@@ -2,16 +2,16 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
|
-
from digitalhub.entities._base.spec
|
|
5
|
+
from digitalhub.entities._base.entity.spec import Spec, SpecValidator
|
|
6
6
|
from digitalhub.entities.artifact.crud import get_artifact
|
|
7
7
|
from digitalhub.entities.dataitem.crud import get_dataitem
|
|
8
|
-
from digitalhub.entities.entity_types import EntityTypes
|
|
9
8
|
from digitalhub.entities.model.crud import get_model
|
|
10
|
-
from digitalhub.entities.task.models import K8s
|
|
11
|
-
from digitalhub.entities.utils import
|
|
9
|
+
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
12
|
|
|
13
13
|
if typing.TYPE_CHECKING:
|
|
14
|
-
from digitalhub.entities._base.entity.
|
|
14
|
+
from digitalhub.entities._base.entity.entity import Entity
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
ENTITY_FUNC = {
|
|
@@ -22,7 +22,7 @@ ENTITY_FUNC = {
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class RunSpec(Spec):
|
|
25
|
-
"""
|
|
25
|
+
"""RunSpec specifications."""
|
|
26
26
|
|
|
27
27
|
def __init__(
|
|
28
28
|
self,
|
|
@@ -138,9 +138,9 @@ class RunSpec(Spec):
|
|
|
138
138
|
return ENTITY_FUNC[entity_type](key)
|
|
139
139
|
|
|
140
140
|
|
|
141
|
-
class
|
|
141
|
+
class RunValidator(SpecValidator, K8s):
|
|
142
142
|
"""
|
|
143
|
-
|
|
143
|
+
RunValidator validator.
|
|
144
144
|
"""
|
|
145
145
|
|
|
146
146
|
function: str = None
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from digitalhub.entities._base.status
|
|
3
|
+
from digitalhub.entities._base.entity.status import Status
|
|
4
4
|
from digitalhub.entities.artifact.crud import get_artifact
|
|
5
5
|
from digitalhub.entities.dataitem.crud import get_dataitem
|
|
6
|
-
from digitalhub.entities.entity_types import EntityTypes
|
|
7
6
|
from digitalhub.entities.model.crud import get_model
|
|
8
|
-
from digitalhub.entities.utils import
|
|
7
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
8
|
+
from digitalhub.entities.utils.utils import parse_entity_key
|
|
9
9
|
|
|
10
10
|
ENTITY_FUNC = {
|
|
11
11
|
EntityTypes.ARTIFACT.value: get_artifact,
|
|
@@ -16,7 +16,7 @@ ENTITY_FUNC = {
|
|
|
16
16
|
|
|
17
17
|
class RunStatus(Status):
|
|
18
18
|
"""
|
|
19
|
-
|
|
19
|
+
RunStatus status.
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
def __init__(
|
|
@@ -1,63 +1,33 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
from digitalhub.entities._builders.spec import build_spec
|
|
5
|
-
from digitalhub.entities._builders.status import build_status
|
|
6
|
-
from digitalhub.entities._builders.uuid import build_uuid
|
|
7
|
-
from digitalhub.entities.run.entity import Run
|
|
3
|
+
import typing
|
|
8
4
|
|
|
5
|
+
from digitalhub.factory.factory import factory
|
|
6
|
+
from digitalhub.utils.exceptions import BuilderError
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
task: str | None = None,
|
|
16
|
-
local_execution: bool = False,
|
|
17
|
-
**kwargs,
|
|
18
|
-
) -> Run:
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from digitalhub.entities.run._base.entity import Run
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def run_from_parameters(**kwargs) -> Run:
|
|
19
13
|
"""
|
|
20
|
-
Create
|
|
14
|
+
Create a new object.
|
|
21
15
|
|
|
22
16
|
Parameters
|
|
23
17
|
----------
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
kind : str
|
|
27
|
-
Kind the object.
|
|
28
|
-
uuid : str
|
|
29
|
-
ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
|
|
30
|
-
labels : list[str]
|
|
31
|
-
List of labels.
|
|
32
|
-
task : str
|
|
33
|
-
Name of the task associated with the run.
|
|
34
|
-
local_execution : bool
|
|
35
|
-
Flag to determine if object has local execution.
|
|
36
|
-
**kwargs : dict
|
|
37
|
-
Spec keyword arguments.
|
|
18
|
+
**kwargs
|
|
19
|
+
Keyword arguments.
|
|
38
20
|
|
|
39
21
|
Returns
|
|
40
22
|
-------
|
|
41
23
|
Run
|
|
42
24
|
Object instance.
|
|
43
25
|
"""
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
labels=labels,
|
|
50
|
-
)
|
|
51
|
-
spec = build_spec(kind, task=task, local_execution=local_execution, **kwargs)
|
|
52
|
-
status = build_status(kind)
|
|
53
|
-
return Run(
|
|
54
|
-
project=project,
|
|
55
|
-
uuid=uuid,
|
|
56
|
-
kind=kind,
|
|
57
|
-
metadata=metadata,
|
|
58
|
-
spec=spec,
|
|
59
|
-
status=status,
|
|
60
|
-
)
|
|
26
|
+
try:
|
|
27
|
+
kind = kwargs["kind"]
|
|
28
|
+
except KeyError:
|
|
29
|
+
raise BuilderError("Missing 'kind' parameter.")
|
|
30
|
+
return factory.build_entity_from_params(kind, **kwargs)
|
|
61
31
|
|
|
62
32
|
|
|
63
33
|
def run_from_dict(obj: dict) -> Run:
|
|
@@ -74,4 +44,8 @@ def run_from_dict(obj: dict) -> Run:
|
|
|
74
44
|
Run
|
|
75
45
|
Object instance.
|
|
76
46
|
"""
|
|
77
|
-
|
|
47
|
+
try:
|
|
48
|
+
kind = obj["kind"]
|
|
49
|
+
except KeyError:
|
|
50
|
+
raise BuilderError("Missing 'kind' parameter.")
|
|
51
|
+
return factory.build_entity_from_dict(kind, obj)
|
digitalhub/entities/run/crud.py
CHANGED
|
@@ -4,13 +4,13 @@ import typing
|
|
|
4
4
|
|
|
5
5
|
from digitalhub.context.builder import check_context
|
|
6
6
|
from digitalhub.entities._base.crud import delete_entity_api_ctx, list_entity_api_ctx, read_entity_api_ctx
|
|
7
|
-
from digitalhub.entities.entity_types import EntityTypes
|
|
8
7
|
from digitalhub.entities.run.builder import run_from_dict, run_from_parameters
|
|
8
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
9
9
|
from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityError
|
|
10
10
|
from digitalhub.utils.io_utils import read_yaml
|
|
11
11
|
|
|
12
12
|
if typing.TYPE_CHECKING:
|
|
13
|
-
from digitalhub.entities.run.entity import Run
|
|
13
|
+
from digitalhub.entities.run._base.entity import Run
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
ENTITY_TYPE = EntityTypes.RUN.value
|
|
@@ -35,7 +35,7 @@ def new_run(
|
|
|
35
35
|
kind : str
|
|
36
36
|
Kind the object.
|
|
37
37
|
uuid : str
|
|
38
|
-
ID of the object
|
|
38
|
+
ID of the object.
|
|
39
39
|
labels : list[str]
|
|
40
40
|
List of labels.
|
|
41
41
|
task : str
|
|
File without changes
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub.entities._base.versioned.builder import VersionedBuilder
|
|
4
|
+
from digitalhub.entities.secret._base.entity import Secret
|
|
5
|
+
from digitalhub.entities.secret._base.spec import SecretSpec, SecretValidator
|
|
6
|
+
from digitalhub.entities.secret._base.status import SecretStatus
|
|
7
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SecretSecretBuilder(VersionedBuilder):
|
|
11
|
+
"""
|
|
12
|
+
SecretSecretBuilder builder.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
ENTITY_TYPE = EntityTypes.SECRET.value
|
|
16
|
+
ENTITY_CLASS = Secret
|
|
17
|
+
ENTITY_SPEC_CLASS = SecretSpec
|
|
18
|
+
ENTITY_SPEC_VALIDATOR = SecretValidator
|
|
19
|
+
ENTITY_STATUS_CLASS = SecretStatus
|
|
20
|
+
ENTITY_KIND = "secret"
|
|
21
|
+
|
|
22
|
+
def build(
|
|
23
|
+
self,
|
|
24
|
+
kind: str,
|
|
25
|
+
project: str,
|
|
26
|
+
name: str,
|
|
27
|
+
uuid: str | None = None,
|
|
28
|
+
description: str | None = None,
|
|
29
|
+
labels: list[str] | None = None,
|
|
30
|
+
**kwargs,
|
|
31
|
+
) -> Secret:
|
|
32
|
+
"""
|
|
33
|
+
Create a new object.
|
|
34
|
+
|
|
35
|
+
Parameters
|
|
36
|
+
----------
|
|
37
|
+
project : str
|
|
38
|
+
Project name.
|
|
39
|
+
name : str
|
|
40
|
+
Object name.
|
|
41
|
+
kind : str
|
|
42
|
+
Kind the object.
|
|
43
|
+
uuid : str
|
|
44
|
+
ID of the object.
|
|
45
|
+
description : str
|
|
46
|
+
Description of the object (human readable).
|
|
47
|
+
labels : list[str]
|
|
48
|
+
List of labels.
|
|
49
|
+
**kwargs : dict
|
|
50
|
+
Spec keyword arguments.
|
|
51
|
+
|
|
52
|
+
Returns
|
|
53
|
+
-------
|
|
54
|
+
Secret
|
|
55
|
+
Object instance.
|
|
56
|
+
"""
|
|
57
|
+
name = self.build_name(name)
|
|
58
|
+
uuid = self.build_uuid(uuid)
|
|
59
|
+
metadata = self.build_metadata(
|
|
60
|
+
project=project,
|
|
61
|
+
name=name,
|
|
62
|
+
description=description,
|
|
63
|
+
labels=labels,
|
|
64
|
+
)
|
|
65
|
+
path = f"kubernetes://dhcore-proj-secrets-{project}/{name}"
|
|
66
|
+
provider = "kubernetes"
|
|
67
|
+
spec = self.build_spec(
|
|
68
|
+
path=path,
|
|
69
|
+
provider=provider,
|
|
70
|
+
**kwargs,
|
|
71
|
+
)
|
|
72
|
+
status = self.build_status()
|
|
73
|
+
return self.build_entity(
|
|
74
|
+
project=project,
|
|
75
|
+
name=name,
|
|
76
|
+
uuid=uuid,
|
|
77
|
+
kind=kind,
|
|
78
|
+
metadata=metadata,
|
|
79
|
+
spec=spec,
|
|
80
|
+
status=status,
|
|
81
|
+
)
|