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,95 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Unit tests for the entity Models
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import digitalhub as dh
|
|
6
|
+
from digitalhub.entities.model._base.entity import Model
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TestModelCRUD:
|
|
10
|
+
def create_test_dicts(self):
|
|
11
|
+
names = ["test1", "test2", "test3", "test4"]
|
|
12
|
+
uuids = [
|
|
13
|
+
"d150bcca-bb64-451d-8455-dff862254b95",
|
|
14
|
+
"31acdd2d-0c41-428c-b68b-1b133da9e97b",
|
|
15
|
+
"b4a3dfdc-b917-44c4-9a29-613dcf734244",
|
|
16
|
+
"2618d9c4-cd61-440f-aebb-7e5761709f3b",
|
|
17
|
+
]
|
|
18
|
+
paths = [
|
|
19
|
+
"./data/my_random_forest_model.pkl",
|
|
20
|
+
"s3://bucket/model.pkl",
|
|
21
|
+
"sql://database/schema/linear_regression_model.joblib",
|
|
22
|
+
"https://url.com/bert_base_uncased.pt",
|
|
23
|
+
]
|
|
24
|
+
kind = ["model", "model", "model", "model"]
|
|
25
|
+
|
|
26
|
+
dicts = []
|
|
27
|
+
for i in range(len(names)):
|
|
28
|
+
dicts.append({"name": names[i], "uuid": uuids[i], "path": paths[i], "kind": kind[i]})
|
|
29
|
+
|
|
30
|
+
return dicts
|
|
31
|
+
|
|
32
|
+
def test_create_delete(self):
|
|
33
|
+
dicts = self.create_test_dicts()
|
|
34
|
+
p = dh.get_or_create_project("test", local=True)
|
|
35
|
+
# Create and delete models
|
|
36
|
+
for i in dicts:
|
|
37
|
+
d = dh.new_model(p.name, **i)
|
|
38
|
+
dh.delete_model(d.key)
|
|
39
|
+
d = dh.new_model(p.name, **i)
|
|
40
|
+
dh.delete_model(d.name, project=p.name, entity_id=d.id)
|
|
41
|
+
d = p.new_model(**i)
|
|
42
|
+
p.delete_model(d.key)
|
|
43
|
+
assert dh.list_models(p.name) == []
|
|
44
|
+
dh.delete_project("test", local=True, clean_context=True)
|
|
45
|
+
|
|
46
|
+
def test_list(self):
|
|
47
|
+
dicts = self.create_test_dicts()
|
|
48
|
+
p = dh.get_or_create_project("test", local=True)
|
|
49
|
+
|
|
50
|
+
assert dh.list_models(p.name) == []
|
|
51
|
+
|
|
52
|
+
for i in dicts:
|
|
53
|
+
dh.new_model(p.name, **i)
|
|
54
|
+
|
|
55
|
+
# List models
|
|
56
|
+
l_obj = dh.list_models(p.name)
|
|
57
|
+
assert isinstance(l_obj, list)
|
|
58
|
+
assert len(l_obj) == 4
|
|
59
|
+
for i in l_obj:
|
|
60
|
+
assert isinstance(i, Model)
|
|
61
|
+
|
|
62
|
+
# delete listed objects
|
|
63
|
+
for obj in l_obj:
|
|
64
|
+
dh.delete_model(obj.key)
|
|
65
|
+
|
|
66
|
+
assert len(dh.list_models(p.name)) == 0
|
|
67
|
+
|
|
68
|
+
dh.delete_project("test", clean_context=True, local=True)
|
|
69
|
+
|
|
70
|
+
def test_get(self):
|
|
71
|
+
dicts = self.create_test_dicts()
|
|
72
|
+
p = dh.get_or_create_project("test", local=True)
|
|
73
|
+
|
|
74
|
+
for i in dicts:
|
|
75
|
+
o1 = dh.new_model(p.name, **i)
|
|
76
|
+
assert isinstance(o1, Model)
|
|
77
|
+
|
|
78
|
+
# Get by name and id
|
|
79
|
+
o2 = dh.get_model(o1.name, project=p.name, entity_id=o1.id)
|
|
80
|
+
assert isinstance(o2, Model)
|
|
81
|
+
assert o1.id == o2.id
|
|
82
|
+
|
|
83
|
+
# Get by key
|
|
84
|
+
o3 = dh.get_model(o1.key)
|
|
85
|
+
assert isinstance(o3, Model)
|
|
86
|
+
assert o1.id == o3.id
|
|
87
|
+
|
|
88
|
+
# delete listed objects
|
|
89
|
+
l_obj = dh.list_models(p.name)
|
|
90
|
+
for obj in l_obj:
|
|
91
|
+
dh.delete_model(obj.key)
|
|
92
|
+
|
|
93
|
+
assert len(dh.list_models(p.name)) == 0
|
|
94
|
+
|
|
95
|
+
dh.delete_project("test", clean_context=True, local=True)
|
test/test_crud_functions.py
CHANGED
test/test_crud_runs.py
CHANGED
test/test_crud_tasks.py
CHANGED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import typing
|
|
4
|
-
|
|
5
|
-
from digitalhub.entities._base.entity.context import ContextEntity
|
|
6
|
-
from digitalhub.entities._builders.metadata import build_metadata
|
|
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.io_utils import write_yaml
|
|
11
|
-
|
|
12
|
-
if typing.TYPE_CHECKING:
|
|
13
|
-
from digitalhub.entities._base.metadata import Metadata
|
|
14
|
-
from digitalhub.entities._base.spec.base import Spec
|
|
15
|
-
from digitalhub.entities._base.status.base import Status
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class UnversionedEntity(ContextEntity):
|
|
19
|
-
def __init__(
|
|
20
|
-
self,
|
|
21
|
-
project: str,
|
|
22
|
-
uuid: str,
|
|
23
|
-
kind: str,
|
|
24
|
-
metadata: Metadata,
|
|
25
|
-
spec: Spec,
|
|
26
|
-
status: Status,
|
|
27
|
-
user: str | None = None,
|
|
28
|
-
) -> None:
|
|
29
|
-
super().__init__(project, kind, metadata, spec, status, user)
|
|
30
|
-
self.id = uuid
|
|
31
|
-
self.key = f"store://{project}/{self.ENTITY_TYPE}/{kind}/{uuid}"
|
|
32
|
-
self._obj_attr.extend(["id"])
|
|
33
|
-
|
|
34
|
-
def export(self, filename: str | None = None) -> str:
|
|
35
|
-
"""
|
|
36
|
-
Export object as a YAML file.
|
|
37
|
-
|
|
38
|
-
Parameters
|
|
39
|
-
----------
|
|
40
|
-
filename : str
|
|
41
|
-
Name of the export YAML file. If not specified, the default value is used.
|
|
42
|
-
|
|
43
|
-
Returns
|
|
44
|
-
-------
|
|
45
|
-
str
|
|
46
|
-
Exported file.
|
|
47
|
-
"""
|
|
48
|
-
obj = self.to_dict()
|
|
49
|
-
if filename is None:
|
|
50
|
-
filename = f"{self.ENTITY_TYPE}-{self.id}.yml"
|
|
51
|
-
pth = self._context().root / filename
|
|
52
|
-
write_yaml(pth, obj)
|
|
53
|
-
return str(pth)
|
|
54
|
-
|
|
55
|
-
@staticmethod
|
|
56
|
-
def _parse_dict(obj: dict, validate: bool = True) -> dict:
|
|
57
|
-
"""
|
|
58
|
-
Get dictionary and parse it to a valid entity dictionary.
|
|
59
|
-
|
|
60
|
-
Parameters
|
|
61
|
-
----------
|
|
62
|
-
entity : str
|
|
63
|
-
Entity type.
|
|
64
|
-
obj : dict
|
|
65
|
-
Dictionary to parse.
|
|
66
|
-
|
|
67
|
-
Returns
|
|
68
|
-
-------
|
|
69
|
-
dict
|
|
70
|
-
A dictionary containing the attributes of the entity instance.
|
|
71
|
-
"""
|
|
72
|
-
project = obj.get("project")
|
|
73
|
-
kind = obj.get("kind")
|
|
74
|
-
uuid = build_uuid(obj.get("id"))
|
|
75
|
-
metadata = build_metadata(kind, **obj.get("metadata", {}))
|
|
76
|
-
spec = build_spec(kind, validate=validate, **obj.get("spec", {}))
|
|
77
|
-
status = build_status(kind, **obj.get("status", {}))
|
|
78
|
-
user = obj.get("user")
|
|
79
|
-
return {
|
|
80
|
-
"project": project,
|
|
81
|
-
"uuid": uuid,
|
|
82
|
-
"kind": kind,
|
|
83
|
-
"metadata": metadata,
|
|
84
|
-
"spec": spec,
|
|
85
|
-
"status": status,
|
|
86
|
-
"user": user,
|
|
87
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import typing
|
|
4
|
-
|
|
5
|
-
from digitalhub.entities._base.entity.context import ContextEntity
|
|
6
|
-
from digitalhub.entities._builders.metadata import build_metadata
|
|
7
|
-
from digitalhub.entities._builders.name import build_name
|
|
8
|
-
from digitalhub.entities._builders.spec import build_spec
|
|
9
|
-
from digitalhub.entities._builders.status import build_status
|
|
10
|
-
from digitalhub.entities._builders.uuid import build_uuid
|
|
11
|
-
from digitalhub.utils.io_utils import write_yaml
|
|
12
|
-
|
|
13
|
-
if typing.TYPE_CHECKING:
|
|
14
|
-
from digitalhub.entities._base.metadata import Metadata
|
|
15
|
-
from digitalhub.entities._base.spec.base import Spec
|
|
16
|
-
from digitalhub.entities._base.status.base import Status
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class VersionedEntity(ContextEntity):
|
|
20
|
-
def __init__(
|
|
21
|
-
self,
|
|
22
|
-
project: str,
|
|
23
|
-
name: str,
|
|
24
|
-
uuid: str,
|
|
25
|
-
kind: str,
|
|
26
|
-
metadata: Metadata,
|
|
27
|
-
spec: Spec,
|
|
28
|
-
status: Status,
|
|
29
|
-
user: str | None = None,
|
|
30
|
-
) -> None:
|
|
31
|
-
super().__init__(project, kind, metadata, spec, status, user)
|
|
32
|
-
self.name = name
|
|
33
|
-
self.id = uuid
|
|
34
|
-
self.key = f"store://{project}/{self.ENTITY_TYPE}/{kind}/{name}:{uuid}"
|
|
35
|
-
|
|
36
|
-
# Add attributes to be used in the to_dict method
|
|
37
|
-
self._obj_attr.extend(["name", "id"])
|
|
38
|
-
|
|
39
|
-
def export(self, filename: str | None = None) -> str:
|
|
40
|
-
"""
|
|
41
|
-
Export object as a YAML file.
|
|
42
|
-
|
|
43
|
-
Parameters
|
|
44
|
-
----------
|
|
45
|
-
filename : str
|
|
46
|
-
Name of the export YAML file. If not specified, the default value is used.
|
|
47
|
-
|
|
48
|
-
Returns
|
|
49
|
-
-------
|
|
50
|
-
str
|
|
51
|
-
Exported file.
|
|
52
|
-
"""
|
|
53
|
-
obj = self.to_dict()
|
|
54
|
-
if filename is None:
|
|
55
|
-
filename = f"{self.ENTITY_TYPE}-{self.name}-{self.id}.yml"
|
|
56
|
-
pth = self._context().root / filename
|
|
57
|
-
write_yaml(pth, obj)
|
|
58
|
-
return str(pth)
|
|
59
|
-
|
|
60
|
-
@staticmethod
|
|
61
|
-
def _parse_dict(obj: dict, validate: bool = True) -> dict:
|
|
62
|
-
"""
|
|
63
|
-
Get dictionary and parse it to a valid entity dictionary.
|
|
64
|
-
|
|
65
|
-
Parameters
|
|
66
|
-
----------
|
|
67
|
-
entity : str
|
|
68
|
-
Entity type.
|
|
69
|
-
obj : dict
|
|
70
|
-
Dictionary to parse.
|
|
71
|
-
|
|
72
|
-
Returns
|
|
73
|
-
-------
|
|
74
|
-
dict
|
|
75
|
-
A dictionary containing the attributes of the entity instance.
|
|
76
|
-
"""
|
|
77
|
-
project = obj.get("project")
|
|
78
|
-
kind = obj.get("kind")
|
|
79
|
-
name = build_name(obj.get("name"))
|
|
80
|
-
uuid = build_uuid(obj.get("id"))
|
|
81
|
-
metadata = build_metadata(kind, **obj.get("metadata", {}))
|
|
82
|
-
spec = build_spec(kind, validate=validate, **obj.get("spec", {}))
|
|
83
|
-
status = build_status(kind, **obj.get("status", {}))
|
|
84
|
-
user = obj.get("user")
|
|
85
|
-
return {
|
|
86
|
-
"project": project,
|
|
87
|
-
"name": name,
|
|
88
|
-
"uuid": uuid,
|
|
89
|
-
"kind": kind,
|
|
90
|
-
"metadata": metadata,
|
|
91
|
-
"spec": spec,
|
|
92
|
-
"status": status,
|
|
93
|
-
"user": user,
|
|
94
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from pydantic import Field
|
|
4
|
-
|
|
5
|
-
from digitalhub.entities._base.spec.material import MaterialParams, MaterialSpec
|
|
6
|
-
from digitalhub.entities.dataitem.models import TableSchema
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class DataitemSpec(MaterialSpec):
|
|
10
|
-
"""
|
|
11
|
-
Dataitem specifications.
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class DataitemParams(MaterialParams):
|
|
16
|
-
"""
|
|
17
|
-
Dataitem parameters.
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class DataitemSpecDataitem(DataitemSpec):
|
|
22
|
-
"""
|
|
23
|
-
Dataitem dataitem specifications.
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class DataitemParamsDataitem(DataitemParams):
|
|
28
|
-
"""
|
|
29
|
-
Dataitem dataitem parameters.
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class DataitemSpecTable(DataitemSpec):
|
|
34
|
-
"""
|
|
35
|
-
Dataitem table specifications.
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
def __init__(self, path: str, schema: dict | None = None) -> None:
|
|
39
|
-
super().__init__(path)
|
|
40
|
-
self.schema = schema
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class DataitemParamsTable(DataitemParams):
|
|
44
|
-
"""
|
|
45
|
-
Dataitem table parameters.
|
|
46
|
-
"""
|
|
47
|
-
|
|
48
|
-
schema_: TableSchema = Field(default=None, alias="schema")
|
|
49
|
-
"""The schema of the dataitem in table schema format."""
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
class DataitemSpecIceberg(DataitemSpec):
|
|
53
|
-
"""
|
|
54
|
-
Dataitem iceberg specifications.
|
|
55
|
-
"""
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
class DataitemParamsIceberg(DataitemParams):
|
|
59
|
-
"""
|
|
60
|
-
Dataitem iceberg parameters.
|
|
61
|
-
"""
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from digitalhub.entities._base.status.material import MaterialStatus
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class DataitemStatus(MaterialStatus):
|
|
7
|
-
"""
|
|
8
|
-
Status class for dataitem entities.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
def __init__(
|
|
12
|
-
self,
|
|
13
|
-
state: str,
|
|
14
|
-
message: str | None = None,
|
|
15
|
-
files: list[dict] | None = None,
|
|
16
|
-
preview: dict | None = None,
|
|
17
|
-
**kwargs,
|
|
18
|
-
) -> None:
|
|
19
|
-
super().__init__(state, message, files)
|
|
20
|
-
self.preview = preview
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class DataitemStatusDataitem(DataitemStatus):
|
|
24
|
-
"""
|
|
25
|
-
Status class for dataitem dataitem entities.
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class DataitemStatusTable(DataitemStatus):
|
|
30
|
-
"""
|
|
31
|
-
Status class for dataitem table entities.
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class DataitemStatusIceberg(DataitemStatus):
|
|
36
|
-
"""
|
|
37
|
-
Status class for dataitem iceberg entities.
|
|
38
|
-
"""
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from digitalhub.entities._base.spec.base import Spec, SpecParams
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class FunctionSpec(Spec):
|
|
7
|
-
"""
|
|
8
|
-
Specification for a Function.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class FunctionParams(SpecParams):
|
|
13
|
-
"""
|
|
14
|
-
Function parameters model.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class SourceCodeStruct:
|
|
19
|
-
"""
|
|
20
|
-
Source code struct.
|
|
21
|
-
"""
|
|
22
|
-
|
|
23
|
-
def __init__(
|
|
24
|
-
self,
|
|
25
|
-
source: str | None = None,
|
|
26
|
-
handler: str | None = None,
|
|
27
|
-
code: str | None = None,
|
|
28
|
-
base64: str | None = None,
|
|
29
|
-
init_function: str | None = None,
|
|
30
|
-
lang: str | None = None,
|
|
31
|
-
) -> None:
|
|
32
|
-
"""
|
|
33
|
-
Constructor.
|
|
34
|
-
|
|
35
|
-
Parameters
|
|
36
|
-
----------
|
|
37
|
-
source : str
|
|
38
|
-
Source reference.
|
|
39
|
-
handler : str
|
|
40
|
-
Function entrypoint.
|
|
41
|
-
code : str
|
|
42
|
-
Source code (plain).
|
|
43
|
-
base64 : str
|
|
44
|
-
Source code (base64 encoded).
|
|
45
|
-
init_function : str
|
|
46
|
-
Init function for remote execution.
|
|
47
|
-
lang : str
|
|
48
|
-
Source code language (hint).
|
|
49
|
-
"""
|
|
50
|
-
self.source = source
|
|
51
|
-
self.handler = handler
|
|
52
|
-
self.code = code
|
|
53
|
-
self.base64 = base64
|
|
54
|
-
self.init_function = init_function
|
|
55
|
-
self.lang = lang
|
|
56
|
-
|
|
57
|
-
def to_dict(self) -> dict:
|
|
58
|
-
"""
|
|
59
|
-
Convert to dictionary.
|
|
60
|
-
|
|
61
|
-
Returns
|
|
62
|
-
-------
|
|
63
|
-
dict
|
|
64
|
-
Dictionary representation of the object.
|
|
65
|
-
"""
|
|
66
|
-
dict_ = {}
|
|
67
|
-
if self.source is not None:
|
|
68
|
-
dict_["source"] = self.source
|
|
69
|
-
if self.handler is not None:
|
|
70
|
-
dict_["handler"] = self.handler
|
|
71
|
-
if self.base64 is not None:
|
|
72
|
-
dict_["base64"] = self.base64
|
|
73
|
-
if self.init_function is not None:
|
|
74
|
-
dict_["init_function"] = self.init_function
|
|
75
|
-
if self.lang is not None:
|
|
76
|
-
dict_["lang"] = self.lang
|
|
77
|
-
|
|
78
|
-
return dict_
|
|
79
|
-
|
|
80
|
-
def __repr__(self) -> str:
|
|
81
|
-
return str(self.to_dict())
|