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
|
@@ -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
|
+
)
|
|
@@ -3,16 +3,16 @@ from __future__ import annotations
|
|
|
3
3
|
import typing
|
|
4
4
|
from concurrent.futures import ThreadPoolExecutor
|
|
5
5
|
|
|
6
|
-
from digitalhub.entities._base.entity
|
|
7
|
-
from digitalhub.entities.entity_types import EntityTypes
|
|
8
|
-
from digitalhub.runtimes.
|
|
6
|
+
from digitalhub.entities._base.executable.entity import ExecutableEntity
|
|
7
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
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:
|
|
12
|
-
from digitalhub.entities._base.metadata import Metadata
|
|
13
|
-
from digitalhub.entities.function.spec import FunctionSpec
|
|
14
|
-
from digitalhub.entities.function.status import FunctionStatus
|
|
15
|
-
from digitalhub.entities.run.entity import Run
|
|
12
|
+
from digitalhub.entities._base.entity.metadata import Metadata
|
|
13
|
+
from digitalhub.entities.function._base.spec import FunctionSpec
|
|
14
|
+
from digitalhub.entities.function._base.status import FunctionStatus
|
|
15
|
+
from digitalhub.entities.run._base.entity import Run
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class Function(ExecutableEntity):
|
|
@@ -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)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub.entities._base.entity.spec import Spec, SpecValidator
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class FunctionSpec(Spec):
|
|
7
|
+
"""
|
|
8
|
+
FunctionSpec specifications.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FunctionValidator(SpecValidator):
|
|
13
|
+
"""
|
|
14
|
+
FunctionValidator validator.
|
|
15
|
+
"""
|
|
@@ -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.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)
|
|
@@ -9,13 +9,13 @@ from digitalhub.entities._base.crud import (
|
|
|
9
9
|
read_entity_api_ctx,
|
|
10
10
|
read_entity_api_ctx_versions,
|
|
11
11
|
)
|
|
12
|
-
from digitalhub.entities.entity_types import EntityTypes
|
|
13
12
|
from digitalhub.entities.function.builder import function_from_dict, function_from_parameters
|
|
13
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
14
14
|
from digitalhub.utils.exceptions import EntityAlreadyExistsError
|
|
15
15
|
from digitalhub.utils.io_utils import read_yaml
|
|
16
16
|
|
|
17
17
|
if typing.TYPE_CHECKING:
|
|
18
|
-
from digitalhub.entities.function.entity import Function
|
|
18
|
+
from digitalhub.entities.function._base.entity import Function
|
|
19
19
|
|
|
20
20
|
ENTITY_TYPE = EntityTypes.FUNCTION.value
|
|
21
21
|
|
|
@@ -42,7 +42,7 @@ def new_function(
|
|
|
42
42
|
kind : str
|
|
43
43
|
Kind the object.
|
|
44
44
|
uuid : str
|
|
45
|
-
ID of the object
|
|
45
|
+
ID of the object.
|
|
46
46
|
description : str
|
|
47
47
|
Description of the object (human readable).
|
|
48
48
|
labels : list[str]
|
|
File without changes
|
|
@@ -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,13 +2,13 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
|
-
from digitalhub.entities._base.entity
|
|
6
|
-
from digitalhub.entities.entity_types import EntityTypes
|
|
5
|
+
from digitalhub.entities._base.material.entity import MaterialEntity
|
|
6
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
7
7
|
|
|
8
8
|
if typing.TYPE_CHECKING:
|
|
9
|
-
from digitalhub.entities._base.metadata import Metadata
|
|
10
|
-
from digitalhub.entities.model.spec import ModelSpec
|
|
11
|
-
from digitalhub.entities.model.status import ModelStatus
|
|
9
|
+
from digitalhub.entities._base.entity.metadata import Metadata
|
|
10
|
+
from digitalhub.entities.model._base.spec import ModelSpec
|
|
11
|
+
from digitalhub.entities.model._base.status import ModelStatus
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class Model(MaterialEntity):
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub.entities._base.material.spec import MaterialSpec, MaterialValidator
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ModelSpec(MaterialSpec):
|
|
7
|
+
"""
|
|
8
|
+
ModelSpec specifications.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
path: str,
|
|
14
|
+
framework: str | None = None,
|
|
15
|
+
algorithm: str | None = None,
|
|
16
|
+
base_model: str | None = None,
|
|
17
|
+
parameters: dict | None = None,
|
|
18
|
+
metrics: dict | None = None,
|
|
19
|
+
) -> None:
|
|
20
|
+
self.path = path
|
|
21
|
+
self.framework = framework
|
|
22
|
+
self.algorithm = algorithm
|
|
23
|
+
self.base_model = base_model
|
|
24
|
+
self.parameters = parameters
|
|
25
|
+
self.metrics = metrics
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ModelValidator(MaterialValidator):
|
|
29
|
+
"""
|
|
30
|
+
ModelValidator validator.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
path: str
|
|
34
|
+
"""Path to the model."""
|
|
35
|
+
|
|
36
|
+
framework: str = None
|
|
37
|
+
"""Model framework (e.g. 'pytorch')."""
|
|
38
|
+
|
|
39
|
+
algorithm: str = None
|
|
40
|
+
"""Model algorithm (e.g. 'resnet')."""
|
|
41
|
+
|
|
42
|
+
base_model: str = None
|
|
43
|
+
"""Base model."""
|
|
44
|
+
|
|
45
|
+
parameters: dict = None
|
|
46
|
+
"""Model validator."""
|
|
47
|
+
|
|
48
|
+
metrics: dict = None
|
|
49
|
+
"""Model metrics."""
|
|
@@ -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
|
-
from digitalhub.entities.model.entity
|
|
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.entity.model import ModelModel
|
|
20
|
-
|
|
21
|
-
cls_mapper["model"] = ModelModel
|
|
22
|
-
except ImportError:
|
|
23
|
-
...
|
|
24
|
-
|
|
25
|
-
try:
|
|
26
|
-
from digitalhub.entities.model.entity.mlflow import ModelMlflow
|
|
27
|
-
|
|
28
|
-
cls_mapper["mlflow"] = ModelMlflow
|
|
29
|
-
except ImportError:
|
|
30
|
-
...
|
|
31
|
-
try:
|
|
32
|
-
from digitalhub.entities.model.entity.sklearn import ModelSklearn
|
|
33
|
-
|
|
34
|
-
cls_mapper["sklearn"] = ModelSklearn
|
|
35
|
-
except ImportError:
|
|
36
|
-
...
|
|
37
|
-
try:
|
|
38
|
-
from digitalhub.entities.model.entity.huggingface 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)
|
|
@@ -10,14 +10,14 @@ from digitalhub.entities._base.crud import (
|
|
|
10
10
|
read_entity_api_ctx_versions,
|
|
11
11
|
)
|
|
12
12
|
from digitalhub.entities._builders.uuid import build_uuid
|
|
13
|
-
from digitalhub.entities.entity_types import EntityTypes
|
|
14
13
|
from digitalhub.entities.model.builder import model_from_dict, model_from_parameters
|
|
15
|
-
from digitalhub.entities.utils import
|
|
14
|
+
from digitalhub.entities.utils.entity_types import EntityTypes
|
|
15
|
+
from digitalhub.entities.utils.utils import build_log_path_from_source, eval_local_source
|
|
16
16
|
from digitalhub.utils.exceptions import EntityAlreadyExistsError
|
|
17
17
|
from digitalhub.utils.io_utils import read_yaml
|
|
18
18
|
|
|
19
19
|
if typing.TYPE_CHECKING:
|
|
20
|
-
from digitalhub.entities.model.entity
|
|
20
|
+
from digitalhub.entities.model._base.entity import Model
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
ENTITY_TYPE = EntityTypes.MODEL.value
|
|
@@ -46,7 +46,7 @@ def new_model(
|
|
|
46
46
|
kind : str
|
|
47
47
|
Kind the object.
|
|
48
48
|
uuid : str
|
|
49
|
-
ID of the object
|
|
49
|
+
ID of the object.
|
|
50
50
|
description : str
|
|
51
51
|
Description of the object (human readable).
|
|
52
52
|
labels : list[str]
|
|
File without changes
|
|
@@ -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,32 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from digitalhub.entities.model._base.entity import Model
|
|
6
|
+
|
|
7
|
+
if typing.TYPE_CHECKING:
|
|
8
|
+
from digitalhub.entities._base.entity.metadata import Metadata
|
|
9
|
+
from digitalhub.entities.model.huggingface.spec import ModelSpecHuggingface
|
|
10
|
+
from digitalhub.entities.model.huggingface.status import ModelStatusHuggingface
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ModelHuggingface(Model):
|
|
14
|
+
"""
|
|
15
|
+
ModelHuggingface class.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
project: str,
|
|
21
|
+
name: str,
|
|
22
|
+
uuid: str,
|
|
23
|
+
kind: str,
|
|
24
|
+
metadata: Metadata,
|
|
25
|
+
spec: ModelSpecHuggingface,
|
|
26
|
+
status: ModelStatusHuggingface,
|
|
27
|
+
user: str | None = None,
|
|
28
|
+
) -> None:
|
|
29
|
+
super().__init__(project, name, uuid, kind, metadata, spec, status, user)
|
|
30
|
+
|
|
31
|
+
self.spec: ModelSpecHuggingface
|
|
32
|
+
self.status: ModelStatusHuggingface
|