digitalhub 0.8.0b3__py3-none-any.whl → 0.8.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/__init__.py +3 -2
- digitalhub/client/dhcore/client.py +6 -1
- digitalhub/context/builder.py +1 -1
- digitalhub/context/context.py +1 -1
- digitalhub/entities/_base/entity/entity.py +2 -28
- digitalhub/entities/_base/unversioned/builder.py +66 -0
- digitalhub/entities/_base/unversioned/entity.py +0 -38
- digitalhub/entities/_base/versioned/builder.py +68 -0
- digitalhub/entities/_base/versioned/entity.py +0 -41
- digitalhub/entities/_builders/entity.py +37 -32
- digitalhub/entities/_builders/metadata.py +3 -10
- digitalhub/entities/_builders/spec.py +11 -21
- digitalhub/entities/_builders/status.py +8 -18
- digitalhub/entities/_builders/uuid.py +4 -11
- digitalhub/entities/artifact/_base/builder.py +86 -0
- digitalhub/entities/artifact/artifact/builder.py +18 -0
- digitalhub/entities/artifact/builder.py +15 -97
- digitalhub/entities/artifact/crud.py +1 -1
- digitalhub/entities/builders.py +63 -0
- digitalhub/entities/dataitem/_base/builder.py +86 -0
- digitalhub/entities/dataitem/builder.py +15 -108
- digitalhub/entities/dataitem/crud.py +3 -3
- digitalhub/entities/dataitem/dataitem/builder.py +18 -0
- digitalhub/entities/dataitem/iceberg/builder.py +18 -0
- digitalhub/entities/dataitem/table/builder.py +18 -0
- digitalhub/entities/function/_base/builder.py +78 -0
- digitalhub/entities/function/_base/entity.py +2 -2
- digitalhub/entities/function/builder.py +22 -57
- digitalhub/entities/function/crud.py +1 -1
- digitalhub/entities/model/_base/builder.py +86 -0
- digitalhub/entities/model/builder.py +15 -116
- digitalhub/entities/model/crud.py +1 -1
- digitalhub/entities/model/huggingface/builder.py +18 -0
- digitalhub/entities/model/mlflow/builder.py +18 -0
- digitalhub/entities/model/model/builder.py +18 -0
- digitalhub/entities/model/sklearn/builder.py +18 -0
- digitalhub/entities/project/_base/builder.py +128 -0
- digitalhub/entities/project/{project → _base}/entity.py +9 -51
- digitalhub/entities/project/builder.py +20 -51
- digitalhub/entities/project/crud.py +1 -1
- digitalhub/entities/run/_base/builder.py +73 -0
- digitalhub/entities/run/_base/entity.py +17 -152
- digitalhub/entities/run/builder.py +21 -47
- digitalhub/entities/run/crud.py +1 -1
- digitalhub/entities/secret/_base/builder.py +81 -0
- digitalhub/entities/secret/{secret → _base}/entity.py +2 -2
- digitalhub/entities/secret/builder.py +20 -62
- digitalhub/entities/secret/crud.py +2 -2
- digitalhub/entities/task/_base/builder.py +76 -0
- digitalhub/entities/task/builder.py +21 -44
- digitalhub/entities/task/crud.py +1 -1
- digitalhub/entities/workflow/_base/builder.py +78 -0
- digitalhub/entities/workflow/_base/entity.py +2 -2
- digitalhub/entities/workflow/builder.py +20 -60
- digitalhub/entities/workflow/crud.py +1 -1
- digitalhub/factory/factory.py +204 -0
- digitalhub/factory/utils.py +90 -0
- digitalhub/runtimes/builder.py +24 -41
- digitalhub/runtimes/kind_registry.py +14 -0
- digitalhub/runtimes/utils.py +28 -0
- digitalhub/utils/exceptions.py +6 -0
- digitalhub/utils/generic_utils.py +1 -1
- {digitalhub-0.8.0b3.dist-info → digitalhub-0.8.0b5.dist-info}/METADATA +1 -1
- {digitalhub-0.8.0b3.dist-info → digitalhub-0.8.0b5.dist-info}/RECORD +75 -57
- digitalhub/entities/_builders/factory.py +0 -44
- digitalhub/entities/registries.py +0 -48
- digitalhub/registry/models.py +0 -87
- digitalhub/registry/registry.py +0 -74
- digitalhub/registry/utils.py +0 -151
- /digitalhub/entities/project/{project → _base}/__init__.py +0 -0
- /digitalhub/entities/project/{project → _base}/spec.py +0 -0
- /digitalhub/entities/project/{project → _base}/status.py +0 -0
- /digitalhub/entities/secret/{secret → _base}/__init__.py +0 -0
- /digitalhub/entities/secret/{secret → _base}/spec.py +0 -0
- /digitalhub/entities/secret/{secret → _base}/status.py +0 -0
- /digitalhub/{registry → factory}/__init__.py +0 -0
- /digitalhub/runtimes/{base.py → _base.py} +0 -0
- {digitalhub-0.8.0b3.dist-info → digitalhub-0.8.0b5.dist-info}/LICENSE.txt +0 -0
- {digitalhub-0.8.0b3.dist-info → digitalhub-0.8.0b5.dist-info}/WHEEL +0 -0
- {digitalhub-0.8.0b3.dist-info → digitalhub-0.8.0b5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from digitalhub.entities._base.versioned.builder import VersionedBuilder
|
|
6
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from digitalhub.entities.function._base.entity import Function
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FunctionBuilder(VersionedBuilder):
|
|
13
|
+
"""
|
|
14
|
+
Function builder.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
ENTITY_TYPE = EntityTypes.FUNCTION.value
|
|
18
|
+
|
|
19
|
+
def build(
|
|
20
|
+
self,
|
|
21
|
+
kind: str,
|
|
22
|
+
project: str,
|
|
23
|
+
name: str,
|
|
24
|
+
uuid: str | None = None,
|
|
25
|
+
description: str | None = None,
|
|
26
|
+
labels: list[str] | None = None,
|
|
27
|
+
embedded: bool = True,
|
|
28
|
+
**kwargs,
|
|
29
|
+
) -> Function:
|
|
30
|
+
"""
|
|
31
|
+
Create a new object.
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
project : str
|
|
36
|
+
Project name.
|
|
37
|
+
name : str
|
|
38
|
+
Object name.
|
|
39
|
+
kind : str
|
|
40
|
+
Kind the object.
|
|
41
|
+
uuid : str
|
|
42
|
+
ID of the object.
|
|
43
|
+
description : str
|
|
44
|
+
Description of the object (human readable).
|
|
45
|
+
labels : list[str]
|
|
46
|
+
List of labels.
|
|
47
|
+
embedded : bool
|
|
48
|
+
Flag to determine if object spec must be embedded in project spec.
|
|
49
|
+
**kwargs : dict
|
|
50
|
+
Spec keyword arguments.
|
|
51
|
+
|
|
52
|
+
Returns
|
|
53
|
+
-------
|
|
54
|
+
Function
|
|
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
|
+
embedded=embedded,
|
|
65
|
+
)
|
|
66
|
+
spec = self.build_spec(
|
|
67
|
+
**kwargs,
|
|
68
|
+
)
|
|
69
|
+
status = self.build_status()
|
|
70
|
+
return self.build_entity(
|
|
71
|
+
project=project,
|
|
72
|
+
name=name,
|
|
73
|
+
uuid=uuid,
|
|
74
|
+
kind=kind,
|
|
75
|
+
metadata=metadata,
|
|
76
|
+
spec=spec,
|
|
77
|
+
status=status,
|
|
78
|
+
)
|
|
@@ -5,7 +5,7 @@ from concurrent.futures import ThreadPoolExecutor
|
|
|
5
5
|
|
|
6
6
|
from digitalhub.entities._base.executable.entity import ExecutableEntity
|
|
7
7
|
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
8
|
-
from digitalhub.runtimes.
|
|
8
|
+
from digitalhub.runtimes.utils import get_kind_registry
|
|
9
9
|
from digitalhub.utils.exceptions import BackendError
|
|
10
10
|
|
|
11
11
|
if typing.TYPE_CHECKING:
|
|
@@ -72,7 +72,7 @@ class Function(ExecutableEntity):
|
|
|
72
72
|
Run instance.
|
|
73
73
|
"""
|
|
74
74
|
# Get kind registry
|
|
75
|
-
kind_reg = get_kind_registry(self.kind)
|
|
75
|
+
kind_reg = get_kind_registry(self.kind, self.project)
|
|
76
76
|
|
|
77
77
|
# Get task and run kind
|
|
78
78
|
task_kind = kind_reg.get_task_kind_from_action(action=action)
|
|
@@ -1,72 +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._builders.uuid import build_uuid
|
|
8
|
-
from digitalhub.entities.function._base.entity import Function
|
|
3
|
+
import typing
|
|
9
4
|
|
|
5
|
+
from digitalhub.factory.factory import factory
|
|
6
|
+
from digitalhub.utils.exceptions import BuilderError
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
description: str | None = None,
|
|
17
|
-
labels: list[str] | None = None,
|
|
18
|
-
embedded: bool = True,
|
|
19
|
-
**kwargs,
|
|
20
|
-
) -> Function:
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from digitalhub.entities.function._base.entity import Function
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def function_from_parameters(**kwargs) -> Function:
|
|
21
13
|
"""
|
|
22
|
-
Create a new
|
|
14
|
+
Create a new object.
|
|
23
15
|
|
|
24
16
|
Parameters
|
|
25
17
|
----------
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
name : str
|
|
29
|
-
Object name.
|
|
30
|
-
kind : str
|
|
31
|
-
Kind the object.
|
|
32
|
-
uuid : str
|
|
33
|
-
ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
|
|
34
|
-
description : str
|
|
35
|
-
Description of the object (human readable).
|
|
36
|
-
labels : list[str]
|
|
37
|
-
List of labels.
|
|
38
|
-
embedded : bool
|
|
39
|
-
Flag to determine if object spec must be embedded in project spec.
|
|
40
|
-
**kwargs : dict
|
|
41
|
-
Spec keyword arguments.
|
|
18
|
+
**kwargs
|
|
19
|
+
Keyword arguments.
|
|
42
20
|
|
|
43
21
|
Returns
|
|
44
22
|
-------
|
|
45
23
|
Function
|
|
46
24
|
Object instance.
|
|
47
25
|
"""
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
project=project,
|
|
54
|
-
name=name,
|
|
55
|
-
version=uuid,
|
|
56
|
-
description=description,
|
|
57
|
-
labels=labels,
|
|
58
|
-
embedded=embedded,
|
|
59
|
-
)
|
|
60
|
-
status = build_status(kind)
|
|
61
|
-
return Function(
|
|
62
|
-
project=project,
|
|
63
|
-
name=name,
|
|
64
|
-
uuid=uuid,
|
|
65
|
-
kind=kind,
|
|
66
|
-
metadata=metadata,
|
|
67
|
-
spec=spec,
|
|
68
|
-
status=status,
|
|
69
|
-
)
|
|
26
|
+
try:
|
|
27
|
+
kind = kwargs["kind"]
|
|
28
|
+
except KeyError:
|
|
29
|
+
raise BuilderError("Missing 'kind' parameter.")
|
|
30
|
+
return factory.build_entity_from_params(kind, **kwargs)
|
|
70
31
|
|
|
71
32
|
|
|
72
33
|
def function_from_dict(obj: dict) -> Function:
|
|
@@ -81,6 +42,10 @@ def function_from_dict(obj: dict) -> Function:
|
|
|
81
42
|
Returns
|
|
82
43
|
-------
|
|
83
44
|
Function
|
|
84
|
-
|
|
45
|
+
Object instance.
|
|
85
46
|
"""
|
|
86
|
-
|
|
47
|
+
try:
|
|
48
|
+
kind = obj["kind"]
|
|
49
|
+
except KeyError:
|
|
50
|
+
raise BuilderError("Missing 'kind' parameter.")
|
|
51
|
+
return factory.build_entity_from_dict(kind, obj)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from digitalhub.entities._base.versioned.builder import VersionedBuilder
|
|
6
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
7
|
+
from digitalhub.utils.exceptions import EntityError
|
|
8
|
+
|
|
9
|
+
if typing.TYPE_CHECKING:
|
|
10
|
+
from digitalhub.entities.model._base.entity import Model
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ModelBuilder(VersionedBuilder):
|
|
14
|
+
"""
|
|
15
|
+
Model builder.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
ENTITY_TYPE = EntityTypes.MODEL.value
|
|
19
|
+
|
|
20
|
+
def build(
|
|
21
|
+
self,
|
|
22
|
+
kind: str,
|
|
23
|
+
project: str,
|
|
24
|
+
name: str,
|
|
25
|
+
uuid: str | None = None,
|
|
26
|
+
description: str | None = None,
|
|
27
|
+
labels: list[str] | None = None,
|
|
28
|
+
embedded: bool = True,
|
|
29
|
+
path: str | None = None,
|
|
30
|
+
**kwargs,
|
|
31
|
+
) -> Model:
|
|
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
|
+
embedded : bool
|
|
50
|
+
Flag to determine if object spec must be embedded in project spec.
|
|
51
|
+
path : str
|
|
52
|
+
Object path on local file system or remote storage. It is also the destination path of upload() method.
|
|
53
|
+
**kwargs : dict
|
|
54
|
+
Spec keyword arguments.
|
|
55
|
+
|
|
56
|
+
Returns
|
|
57
|
+
-------
|
|
58
|
+
Model
|
|
59
|
+
Object instance.
|
|
60
|
+
"""
|
|
61
|
+
if path is None:
|
|
62
|
+
raise EntityError("Path must be provided.")
|
|
63
|
+
|
|
64
|
+
name = self.build_name(name)
|
|
65
|
+
uuid = self.build_uuid(uuid)
|
|
66
|
+
metadata = self.build_metadata(
|
|
67
|
+
project=project,
|
|
68
|
+
name=name,
|
|
69
|
+
description=description,
|
|
70
|
+
labels=labels,
|
|
71
|
+
embedded=embedded,
|
|
72
|
+
)
|
|
73
|
+
spec = self.build_spec(
|
|
74
|
+
path=path,
|
|
75
|
+
**kwargs,
|
|
76
|
+
)
|
|
77
|
+
status = self.build_status()
|
|
78
|
+
return self.build_entity(
|
|
79
|
+
project=project,
|
|
80
|
+
name=name,
|
|
81
|
+
uuid=uuid,
|
|
82
|
+
kind=kind,
|
|
83
|
+
metadata=metadata,
|
|
84
|
+
spec=spec,
|
|
85
|
+
status=status,
|
|
86
|
+
)
|
|
@@ -2,135 +2,32 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
|
-
from digitalhub.
|
|
6
|
-
from digitalhub.
|
|
7
|
-
from digitalhub.entities._builders.spec import build_spec
|
|
8
|
-
from digitalhub.entities._builders.status import build_status
|
|
9
|
-
from digitalhub.entities._builders.uuid import build_uuid
|
|
10
|
-
from digitalhub.utils.exceptions import EntityError
|
|
5
|
+
from digitalhub.factory.factory import factory
|
|
6
|
+
from digitalhub.utils.exceptions import BuilderError
|
|
11
7
|
|
|
12
8
|
if typing.TYPE_CHECKING:
|
|
13
9
|
from digitalhub.entities.model._base.entity import Model
|
|
14
10
|
|
|
15
|
-
# Manage class mapper
|
|
16
|
-
cls_mapper = {}
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
from digitalhub.entities.model.model.entity import ModelModel
|
|
20
|
-
|
|
21
|
-
cls_mapper["model"] = ModelModel
|
|
22
|
-
except ImportError:
|
|
23
|
-
...
|
|
24
|
-
|
|
25
|
-
try:
|
|
26
|
-
from digitalhub.entities.model.mlflow.entity import ModelMlflow
|
|
27
|
-
|
|
28
|
-
cls_mapper["mlflow"] = ModelMlflow
|
|
29
|
-
except ImportError:
|
|
30
|
-
...
|
|
31
|
-
try:
|
|
32
|
-
from digitalhub.entities.model.sklearn.entity import ModelSklearn
|
|
33
|
-
|
|
34
|
-
cls_mapper["sklearn"] = ModelSklearn
|
|
35
|
-
except ImportError:
|
|
36
|
-
...
|
|
37
|
-
try:
|
|
38
|
-
from digitalhub.entities.model.huggingface.entity import ModelHuggingface
|
|
39
|
-
|
|
40
|
-
cls_mapper["huggingface"] = ModelHuggingface
|
|
41
|
-
except ImportError:
|
|
42
|
-
pass
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def _choose_model_type(kind: str) -> type[Model]:
|
|
46
|
-
"""
|
|
47
|
-
Choose class based on kind.
|
|
48
|
-
|
|
49
|
-
Parameters
|
|
50
|
-
----------
|
|
51
|
-
kind : str
|
|
52
|
-
Kind the object.
|
|
53
|
-
|
|
54
|
-
Returns
|
|
55
|
-
-------
|
|
56
|
-
type[Model]
|
|
57
|
-
Class of the model.
|
|
58
|
-
"""
|
|
59
|
-
try:
|
|
60
|
-
return cls_mapper[kind]
|
|
61
|
-
except KeyError:
|
|
62
|
-
raise EntityError(f"Unknown model kind: {kind}")
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
def model_from_parameters(
|
|
66
|
-
project: str,
|
|
67
|
-
name: str,
|
|
68
|
-
kind: str,
|
|
69
|
-
uuid: str | None = None,
|
|
70
|
-
description: str | None = None,
|
|
71
|
-
labels: list[str] | None = None,
|
|
72
|
-
embedded: bool = True,
|
|
73
|
-
path: str | None = None,
|
|
74
|
-
**kwargs,
|
|
75
|
-
) -> Model:
|
|
12
|
+
def model_from_parameters(**kwargs) -> Model:
|
|
76
13
|
"""
|
|
77
14
|
Create a new object.
|
|
78
15
|
|
|
79
16
|
Parameters
|
|
80
17
|
----------
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
name : str
|
|
84
|
-
Object name.
|
|
85
|
-
kind : str
|
|
86
|
-
Kind the object.
|
|
87
|
-
uuid : str
|
|
88
|
-
ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
|
|
89
|
-
labels : list[str]
|
|
90
|
-
List of labels.
|
|
91
|
-
description : str
|
|
92
|
-
Description of the object (human readable).
|
|
93
|
-
embedded : bool
|
|
94
|
-
Flag to determine if object spec must be embedded in project spec.
|
|
95
|
-
path : str
|
|
96
|
-
Object path on local file system or remote storage. It is also the destination path of upload() method.
|
|
97
|
-
**kwargs : dict
|
|
98
|
-
Spec keyword arguments.
|
|
18
|
+
**kwargs
|
|
19
|
+
Keyword arguments.
|
|
99
20
|
|
|
100
21
|
Returns
|
|
101
22
|
-------
|
|
102
23
|
Model
|
|
103
24
|
Object instance.
|
|
104
25
|
"""
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
kind,
|
|
111
|
-
project=project,
|
|
112
|
-
name=name,
|
|
113
|
-
version=uuid,
|
|
114
|
-
description=description,
|
|
115
|
-
labels=labels,
|
|
116
|
-
embedded=embedded,
|
|
117
|
-
)
|
|
118
|
-
spec = build_spec(
|
|
119
|
-
kind,
|
|
120
|
-
path=path,
|
|
121
|
-
**kwargs,
|
|
122
|
-
)
|
|
123
|
-
status = build_status(kind)
|
|
124
|
-
cls = _choose_model_type(kind)
|
|
125
|
-
return cls(
|
|
126
|
-
project=project,
|
|
127
|
-
name=name,
|
|
128
|
-
uuid=uuid,
|
|
129
|
-
kind=kind,
|
|
130
|
-
metadata=metadata,
|
|
131
|
-
spec=spec,
|
|
132
|
-
status=status,
|
|
133
|
-
)
|
|
26
|
+
try:
|
|
27
|
+
kind = kwargs["kind"]
|
|
28
|
+
except KeyError:
|
|
29
|
+
raise BuilderError("Missing 'kind' parameter.")
|
|
30
|
+
return factory.build_entity_from_params(kind, **kwargs)
|
|
134
31
|
|
|
135
32
|
|
|
136
33
|
def model_from_dict(obj: dict) -> Model:
|
|
@@ -147,6 +44,8 @@ def model_from_dict(obj: dict) -> Model:
|
|
|
147
44
|
Model
|
|
148
45
|
Object instance.
|
|
149
46
|
"""
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
47
|
+
try:
|
|
48
|
+
kind = obj["kind"]
|
|
49
|
+
except KeyError:
|
|
50
|
+
raise BuilderError("Missing 'kind' parameter.")
|
|
51
|
+
return factory.build_entity_from_dict(kind, obj)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub.entities.model._base.builder import ModelBuilder
|
|
4
|
+
from digitalhub.entities.model.huggingface.entity import ModelHuggingface
|
|
5
|
+
from digitalhub.entities.model.huggingface.spec import ModelSpecHuggingface, ModelValidatorHuggingface
|
|
6
|
+
from digitalhub.entities.model.huggingface.status import ModelStatusHuggingface
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ModelHuggingfaceBuilder(ModelBuilder):
|
|
10
|
+
"""
|
|
11
|
+
ModelHuggingface builder.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
ENTITY_CLASS = ModelHuggingface
|
|
15
|
+
ENTITY_SPEC_CLASS = ModelSpecHuggingface
|
|
16
|
+
ENTITY_SPEC_VALIDATOR = ModelValidatorHuggingface
|
|
17
|
+
ENTITY_STATUS_CLASS = ModelStatusHuggingface
|
|
18
|
+
ENTITY_KIND = "huggingface"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub.entities.model._base.builder import ModelBuilder
|
|
4
|
+
from digitalhub.entities.model.mlflow.entity import ModelMlflow
|
|
5
|
+
from digitalhub.entities.model.mlflow.spec import ModelSpecMlflow, ModelValidatorMlflow
|
|
6
|
+
from digitalhub.entities.model.mlflow.status import ModelStatusMlflow
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ModelModelBuilder(ModelBuilder):
|
|
10
|
+
"""
|
|
11
|
+
ModelMlflow builder.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
ENTITY_CLASS = ModelMlflow
|
|
15
|
+
ENTITY_SPEC_CLASS = ModelSpecMlflow
|
|
16
|
+
ENTITY_SPEC_VALIDATOR = ModelValidatorMlflow
|
|
17
|
+
ENTITY_STATUS_CLASS = ModelStatusMlflow
|
|
18
|
+
ENTITY_KIND = "mlflow"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub.entities.model._base.builder import ModelBuilder
|
|
4
|
+
from digitalhub.entities.model.model.entity import ModelModel
|
|
5
|
+
from digitalhub.entities.model.model.spec import ModelSpecModel, ModelValidatorModel
|
|
6
|
+
from digitalhub.entities.model.model.status import ModelStatusModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ModelMlflowBuilder(ModelBuilder):
|
|
10
|
+
"""
|
|
11
|
+
ModelModel builder.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
ENTITY_CLASS = ModelModel
|
|
15
|
+
ENTITY_SPEC_CLASS = ModelSpecModel
|
|
16
|
+
ENTITY_SPEC_VALIDATOR = ModelValidatorModel
|
|
17
|
+
ENTITY_STATUS_CLASS = ModelStatusModel
|
|
18
|
+
ENTITY_KIND = "model"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub.entities.model._base.builder import ModelBuilder
|
|
4
|
+
from digitalhub.entities.model.sklearn.entity import ModelSklearn
|
|
5
|
+
from digitalhub.entities.model.sklearn.spec import ModelSpecSklearn, ModelValidatorSklearn
|
|
6
|
+
from digitalhub.entities.model.sklearn.status import ModelStatusSklearn
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ModelSklearnBuilder(ModelBuilder):
|
|
10
|
+
"""
|
|
11
|
+
ModelSklearn builder.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
ENTITY_CLASS = ModelSklearn
|
|
15
|
+
ENTITY_SPEC_CLASS = ModelSpecSklearn
|
|
16
|
+
ENTITY_SPEC_VALIDATOR = ModelValidatorSklearn
|
|
17
|
+
ENTITY_STATUS_CLASS = ModelStatusSklearn
|
|
18
|
+
ENTITY_KIND = "sklearn"
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub.entities._builders.entity import EntityBuilder
|
|
4
|
+
from digitalhub.entities.project._base.entity import Project
|
|
5
|
+
from digitalhub.entities.project._base.spec import ProjectSpec, ProjectValidator
|
|
6
|
+
from digitalhub.entities.project._base.status import ProjectStatus
|
|
7
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ProjectProjectBuilder(EntityBuilder):
|
|
11
|
+
"""
|
|
12
|
+
ProjectProject builder.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
ENTITY_TYPE = EntityTypes.PROJECT.value
|
|
16
|
+
ENTITY_CLASS = Project
|
|
17
|
+
ENTITY_SPEC_CLASS = ProjectSpec
|
|
18
|
+
ENTITY_SPEC_VALIDATOR = ProjectValidator
|
|
19
|
+
ENTITY_STATUS_CLASS = ProjectStatus
|
|
20
|
+
ENTITY_KIND = "project"
|
|
21
|
+
|
|
22
|
+
def build(
|
|
23
|
+
self,
|
|
24
|
+
name: str,
|
|
25
|
+
kind: str,
|
|
26
|
+
description: str | None = None,
|
|
27
|
+
labels: list[str] | None = None,
|
|
28
|
+
local: bool = False,
|
|
29
|
+
context: str | None = None,
|
|
30
|
+
**kwargs,
|
|
31
|
+
) -> Project:
|
|
32
|
+
"""
|
|
33
|
+
Create a new object.
|
|
34
|
+
|
|
35
|
+
Parameters
|
|
36
|
+
----------
|
|
37
|
+
name : str
|
|
38
|
+
Object name.
|
|
39
|
+
kind : str
|
|
40
|
+
Kind the object.
|
|
41
|
+
description : str
|
|
42
|
+
Description of the object (human readable).
|
|
43
|
+
labels : list[str]
|
|
44
|
+
List of labels.
|
|
45
|
+
local : bool
|
|
46
|
+
If True, use local backend, if False use DHCore backend. Default to False.
|
|
47
|
+
context : str
|
|
48
|
+
The context local folder of the project.
|
|
49
|
+
**kwargs : dict
|
|
50
|
+
Spec keyword arguments.
|
|
51
|
+
|
|
52
|
+
Returns
|
|
53
|
+
-------
|
|
54
|
+
Project
|
|
55
|
+
Object instance.
|
|
56
|
+
"""
|
|
57
|
+
name = self.build_name(name)
|
|
58
|
+
metadata = self.build_metadata(
|
|
59
|
+
project=name,
|
|
60
|
+
name=name,
|
|
61
|
+
description=description,
|
|
62
|
+
labels=labels,
|
|
63
|
+
)
|
|
64
|
+
spec = self.build_spec(
|
|
65
|
+
context=context,
|
|
66
|
+
**kwargs,
|
|
67
|
+
)
|
|
68
|
+
status = self.build_status()
|
|
69
|
+
return self.build_entity(
|
|
70
|
+
name=name,
|
|
71
|
+
kind=kind,
|
|
72
|
+
metadata=metadata,
|
|
73
|
+
spec=spec,
|
|
74
|
+
status=status,
|
|
75
|
+
local=local,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
def from_dict(self, obj: dict, validate: bool = True) -> Project:
|
|
79
|
+
"""
|
|
80
|
+
Create a new object from dictionary.
|
|
81
|
+
|
|
82
|
+
Parameters
|
|
83
|
+
----------
|
|
84
|
+
obj : dict
|
|
85
|
+
Dictionary to create object from.
|
|
86
|
+
validate : bool
|
|
87
|
+
Flag to indicate if arguments must be validated.
|
|
88
|
+
|
|
89
|
+
Returns
|
|
90
|
+
-------
|
|
91
|
+
Project
|
|
92
|
+
Object instance.
|
|
93
|
+
"""
|
|
94
|
+
parsed_dict = self._parse_dict(obj, validate=validate)
|
|
95
|
+
return self.build_entity(**parsed_dict)
|
|
96
|
+
|
|
97
|
+
def _parse_dict(self, obj: dict, validate: bool = True) -> dict:
|
|
98
|
+
"""
|
|
99
|
+
Get dictionary and parse it to a valid entity dictionary.
|
|
100
|
+
|
|
101
|
+
Parameters
|
|
102
|
+
----------
|
|
103
|
+
entity : str
|
|
104
|
+
Entity type.
|
|
105
|
+
obj : dict
|
|
106
|
+
Dictionary to parse.
|
|
107
|
+
|
|
108
|
+
Returns
|
|
109
|
+
-------
|
|
110
|
+
dict
|
|
111
|
+
A dictionary containing the attributes of the entity instance.
|
|
112
|
+
"""
|
|
113
|
+
name = self.build_name(obj.get("name"))
|
|
114
|
+
kind = obj.get("kind")
|
|
115
|
+
local = obj.get("local", False)
|
|
116
|
+
metadata = self.build_metadata(**obj.get("metadata", {}))
|
|
117
|
+
spec = self.build_spec(validate=validate, **obj.get("spec", {}))
|
|
118
|
+
status = self.build_status(**obj.get("status", {}))
|
|
119
|
+
user = obj.get("user")
|
|
120
|
+
return {
|
|
121
|
+
"name": name,
|
|
122
|
+
"kind": kind,
|
|
123
|
+
"metadata": metadata,
|
|
124
|
+
"spec": spec,
|
|
125
|
+
"status": status,
|
|
126
|
+
"user": user,
|
|
127
|
+
"local": local,
|
|
128
|
+
}
|