digitalhub 0.8.0b0__py3-none-any.whl → 0.8.0b1__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 +62 -94
- digitalhub/client/__init__.py +0 -0
- digitalhub/client/builder.py +105 -0
- digitalhub/client/objects/__init__.py +0 -0
- digitalhub/client/objects/base.py +56 -0
- digitalhub/client/objects/dhcore.py +681 -0
- digitalhub/client/objects/local.py +533 -0
- digitalhub/context/__init__.py +0 -0
- digitalhub/context/builder.py +178 -0
- digitalhub/context/context.py +136 -0
- digitalhub/datastores/__init__.py +0 -0
- digitalhub/datastores/builder.py +134 -0
- digitalhub/datastores/objects/__init__.py +0 -0
- digitalhub/datastores/objects/base.py +85 -0
- digitalhub/datastores/objects/local.py +42 -0
- digitalhub/datastores/objects/remote.py +23 -0
- digitalhub/datastores/objects/s3.py +38 -0
- digitalhub/datastores/objects/sql.py +60 -0
- digitalhub/entities/__init__.py +0 -0
- digitalhub/entities/_base/__init__.py +0 -0
- digitalhub/entities/_base/api.py +346 -0
- digitalhub/entities/_base/base.py +82 -0
- digitalhub/entities/_base/crud.py +610 -0
- digitalhub/entities/_base/entity/__init__.py +0 -0
- digitalhub/entities/_base/entity/base.py +132 -0
- digitalhub/entities/_base/entity/context.py +118 -0
- digitalhub/entities/_base/entity/executable.py +380 -0
- digitalhub/entities/_base/entity/material.py +214 -0
- digitalhub/entities/_base/entity/unversioned.py +87 -0
- digitalhub/entities/_base/entity/versioned.py +94 -0
- digitalhub/entities/_base/metadata.py +59 -0
- digitalhub/entities/_base/spec/__init__.py +0 -0
- digitalhub/entities/_base/spec/base.py +58 -0
- digitalhub/entities/_base/spec/material.py +22 -0
- digitalhub/entities/_base/state.py +31 -0
- digitalhub/entities/_base/status/__init__.py +0 -0
- digitalhub/entities/_base/status/base.py +32 -0
- digitalhub/entities/_base/status/material.py +49 -0
- digitalhub/entities/_builders/__init__.py +0 -0
- digitalhub/entities/_builders/metadata.py +60 -0
- digitalhub/entities/_builders/name.py +31 -0
- digitalhub/entities/_builders/spec.py +43 -0
- digitalhub/entities/_builders/status.py +62 -0
- digitalhub/entities/_builders/uuid.py +33 -0
- digitalhub/entities/artifact/__init__.py +0 -0
- digitalhub/entities/artifact/builder.py +133 -0
- digitalhub/entities/artifact/crud.py +358 -0
- digitalhub/entities/artifact/entity/__init__.py +0 -0
- digitalhub/entities/artifact/entity/_base.py +39 -0
- digitalhub/entities/artifact/entity/artifact.py +9 -0
- digitalhub/entities/artifact/spec.py +39 -0
- digitalhub/entities/artifact/status.py +15 -0
- digitalhub/entities/dataitem/__init__.py +0 -0
- digitalhub/entities/dataitem/builder.py +144 -0
- digitalhub/entities/dataitem/crud.py +395 -0
- digitalhub/entities/dataitem/entity/__init__.py +0 -0
- digitalhub/entities/dataitem/entity/_base.py +75 -0
- digitalhub/entities/dataitem/entity/dataitem.py +9 -0
- digitalhub/entities/dataitem/entity/iceberg.py +7 -0
- digitalhub/entities/dataitem/entity/table.py +125 -0
- digitalhub/entities/dataitem/models.py +62 -0
- digitalhub/entities/dataitem/spec.py +61 -0
- digitalhub/entities/dataitem/status.py +38 -0
- digitalhub/entities/entity_types.py +19 -0
- digitalhub/entities/function/__init__.py +0 -0
- digitalhub/entities/function/builder.py +86 -0
- digitalhub/entities/function/crud.py +305 -0
- digitalhub/entities/function/entity.py +101 -0
- digitalhub/entities/function/models.py +118 -0
- digitalhub/entities/function/spec.py +81 -0
- digitalhub/entities/function/status.py +9 -0
- digitalhub/entities/model/__init__.py +0 -0
- digitalhub/entities/model/builder.py +152 -0
- digitalhub/entities/model/crud.py +358 -0
- digitalhub/entities/model/entity/__init__.py +0 -0
- digitalhub/entities/model/entity/_base.py +34 -0
- digitalhub/entities/model/entity/huggingface.py +9 -0
- digitalhub/entities/model/entity/mlflow.py +90 -0
- digitalhub/entities/model/entity/model.py +9 -0
- digitalhub/entities/model/entity/sklearn.py +9 -0
- digitalhub/entities/model/models.py +26 -0
- digitalhub/entities/model/spec.py +146 -0
- digitalhub/entities/model/status.py +33 -0
- digitalhub/entities/project/__init__.py +0 -0
- digitalhub/entities/project/builder.py +82 -0
- digitalhub/entities/project/crud.py +350 -0
- digitalhub/entities/project/entity.py +2060 -0
- digitalhub/entities/project/spec.py +50 -0
- digitalhub/entities/project/status.py +9 -0
- digitalhub/entities/registries.py +48 -0
- digitalhub/entities/run/__init__.py +0 -0
- digitalhub/entities/run/builder.py +77 -0
- digitalhub/entities/run/crud.py +232 -0
- digitalhub/entities/run/entity.py +461 -0
- digitalhub/entities/run/spec.py +153 -0
- digitalhub/entities/run/status.py +114 -0
- digitalhub/entities/secret/__init__.py +0 -0
- digitalhub/entities/secret/builder.py +93 -0
- digitalhub/entities/secret/crud.py +294 -0
- digitalhub/entities/secret/entity.py +73 -0
- digitalhub/entities/secret/spec.py +35 -0
- digitalhub/entities/secret/status.py +9 -0
- digitalhub/entities/task/__init__.py +0 -0
- digitalhub/entities/task/builder.py +74 -0
- digitalhub/entities/task/crud.py +241 -0
- digitalhub/entities/task/entity.py +135 -0
- digitalhub/entities/task/models.py +199 -0
- digitalhub/entities/task/spec.py +51 -0
- digitalhub/entities/task/status.py +9 -0
- digitalhub/entities/utils.py +184 -0
- digitalhub/entities/workflow/__init__.py +0 -0
- digitalhub/entities/workflow/builder.py +91 -0
- digitalhub/entities/workflow/crud.py +304 -0
- digitalhub/entities/workflow/entity.py +77 -0
- digitalhub/entities/workflow/spec.py +15 -0
- digitalhub/entities/workflow/status.py +9 -0
- digitalhub/readers/__init__.py +0 -0
- digitalhub/readers/builder.py +54 -0
- digitalhub/readers/objects/__init__.py +0 -0
- digitalhub/readers/objects/base.py +70 -0
- digitalhub/readers/objects/pandas.py +207 -0
- digitalhub/readers/registry.py +15 -0
- digitalhub/registry/__init__.py +0 -0
- digitalhub/registry/models.py +87 -0
- digitalhub/registry/registry.py +74 -0
- digitalhub/registry/utils.py +150 -0
- digitalhub/runtimes/__init__.py +0 -0
- digitalhub/runtimes/base.py +164 -0
- digitalhub/runtimes/builder.py +53 -0
- digitalhub/runtimes/kind_registry.py +170 -0
- digitalhub/stores/__init__.py +0 -0
- digitalhub/stores/builder.py +257 -0
- digitalhub/stores/objects/__init__.py +0 -0
- digitalhub/stores/objects/base.py +189 -0
- digitalhub/stores/objects/local.py +230 -0
- digitalhub/stores/objects/remote.py +143 -0
- digitalhub/stores/objects/s3.py +563 -0
- digitalhub/stores/objects/sql.py +328 -0
- digitalhub/utils/__init__.py +0 -0
- digitalhub/utils/data_utils.py +127 -0
- digitalhub/utils/env_utils.py +123 -0
- digitalhub/utils/exceptions.py +55 -0
- digitalhub/utils/file_utils.py +204 -0
- digitalhub/utils/generic_utils.py +207 -0
- digitalhub/utils/git_utils.py +148 -0
- digitalhub/utils/io_utils.py +79 -0
- digitalhub/utils/logger.py +17 -0
- digitalhub/utils/uri_utils.py +56 -0
- {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b1.dist-info}/METADATA +27 -12
- digitalhub-0.8.0b1.dist-info/RECORD +161 -0
- test/test_crud_artifacts.py +1 -1
- test/test_crud_dataitems.py +1 -1
- test/test_crud_functions.py +1 -1
- test/test_crud_runs.py +1 -1
- test/test_crud_tasks.py +1 -1
- digitalhub-0.8.0b0.dist-info/RECORD +0 -14
- {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b1.dist-info}/LICENSE.txt +0 -0
- {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b1.dist-info}/WHEEL +0 -0
- {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from digitalhub.registry.registry import registry
|
|
6
|
+
from digitalhub.registry.utils import import_class
|
|
7
|
+
from digitalhub.utils.generic_utils import get_timestamp
|
|
8
|
+
|
|
9
|
+
if typing.TYPE_CHECKING:
|
|
10
|
+
from digitalhub.entities._base.metadata import Metadata
|
|
11
|
+
from digitalhub.registry.models import RegistryEntry
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def build_metadata(kind: str, **kwargs) -> Metadata:
|
|
15
|
+
"""
|
|
16
|
+
Build entity metadata object. The builder takes as input
|
|
17
|
+
the kind of metadata's object to build and the keyword
|
|
18
|
+
arguments to pass to the metadata's constructor.
|
|
19
|
+
The specific Metadata class is searched in the global
|
|
20
|
+
registry, where lies info about where to find the class.
|
|
21
|
+
The arguments are parsed, eventually adding default values,
|
|
22
|
+
and then passed to the constructor.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
kind : str
|
|
27
|
+
Registry entry kind.
|
|
28
|
+
**kwargs : dict
|
|
29
|
+
Keyword arguments for the constructor.
|
|
30
|
+
|
|
31
|
+
Returns
|
|
32
|
+
-------
|
|
33
|
+
Metadata
|
|
34
|
+
Metadata object.
|
|
35
|
+
"""
|
|
36
|
+
infos: RegistryEntry = getattr(registry, kind)
|
|
37
|
+
metadata = import_class(infos.metadata.module, infos.metadata.class_name)
|
|
38
|
+
kwargs = parse_arguments(**kwargs)
|
|
39
|
+
return metadata(**kwargs)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def parse_arguments(**kwargs) -> dict:
|
|
43
|
+
"""
|
|
44
|
+
Parse keyword arguments and add default values if necessary.
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
**kwargs : dict
|
|
49
|
+
Keyword arguments.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
dict
|
|
54
|
+
A dictionary containing the entity metadata attributes.
|
|
55
|
+
"""
|
|
56
|
+
if "created" not in kwargs or kwargs["created"] is None:
|
|
57
|
+
kwargs["created"] = get_timestamp()
|
|
58
|
+
if "updated" not in kwargs or kwargs["updated"] is None:
|
|
59
|
+
kwargs["updated"] = kwargs["created"]
|
|
60
|
+
return kwargs
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, Field
|
|
4
|
+
|
|
5
|
+
NAME_REGEX = r"^[a-zA-Z0-9._+-]+$"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class NameValidator(BaseModel):
|
|
9
|
+
"""
|
|
10
|
+
Validate name format.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
name: str = Field(min_length=1, max_length=256, regex=NAME_REGEX)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def build_name(name: str) -> str:
|
|
17
|
+
"""
|
|
18
|
+
Build name.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
name : str
|
|
23
|
+
The name.
|
|
24
|
+
|
|
25
|
+
Returns
|
|
26
|
+
-------
|
|
27
|
+
str
|
|
28
|
+
The name.
|
|
29
|
+
"""
|
|
30
|
+
NameValidator(name=name)
|
|
31
|
+
return name
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from digitalhub.registry.registry import registry
|
|
6
|
+
from digitalhub.registry.utils import import_class
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from digitalhub.entities._base.spec.base import Spec
|
|
10
|
+
from digitalhub.registry.models import RegistryEntry
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def build_spec(kind: str, validate: bool = True, **kwargs) -> Spec:
|
|
14
|
+
"""
|
|
15
|
+
Build entity spec object. The builder takes as input
|
|
16
|
+
the kind of spec's object to build, a validation flag
|
|
17
|
+
and the keyword arguments to pass to the spec's constructor.
|
|
18
|
+
The specific Spec class is searched in the global registry,
|
|
19
|
+
where lies info about where to find the class.
|
|
20
|
+
If the validation flag is set to True, the arguments are
|
|
21
|
+
validated against a pydantic schema and then passed to the
|
|
22
|
+
constructor.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
kind : str
|
|
27
|
+
Registry entry kind.
|
|
28
|
+
validate : bool
|
|
29
|
+
Flag to determine if validate kwargs.
|
|
30
|
+
**kwargs : dict
|
|
31
|
+
Keyword arguments for the constructor.
|
|
32
|
+
|
|
33
|
+
Returns
|
|
34
|
+
-------
|
|
35
|
+
Spec
|
|
36
|
+
Spec object.
|
|
37
|
+
"""
|
|
38
|
+
infos: RegistryEntry = getattr(registry, kind)
|
|
39
|
+
spec = import_class(infos.spec.module, infos.spec.class_name)
|
|
40
|
+
if validate:
|
|
41
|
+
validator = import_class(infos.spec.module, infos.spec.parameters_validator)
|
|
42
|
+
kwargs = validator(**kwargs).dict(by_alias=True, exclude_none=True)
|
|
43
|
+
return spec(**kwargs)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from digitalhub.entities._base.state import State
|
|
6
|
+
from digitalhub.registry.registry import registry
|
|
7
|
+
from digitalhub.registry.utils import import_class
|
|
8
|
+
|
|
9
|
+
if typing.TYPE_CHECKING:
|
|
10
|
+
from digitalhub.entities._base.status.base import Status
|
|
11
|
+
from digitalhub.registry.models import RegistryEntry
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def build_status(kind: str, **kwargs) -> Status:
|
|
15
|
+
"""
|
|
16
|
+
Build entity status object. The builder takes as input
|
|
17
|
+
the kind of status's object to build and the keyword
|
|
18
|
+
arguments to pass to the status's constructor.
|
|
19
|
+
The specific Status class is searched in the global
|
|
20
|
+
registry, where lies info about where to find the class.
|
|
21
|
+
The arguments are parsed, eventually adding default values,
|
|
22
|
+
and then passed to the constructor.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
kind : str
|
|
27
|
+
Registry entry kind.
|
|
28
|
+
**kwargs : dict
|
|
29
|
+
Keyword arguments for the constructor.
|
|
30
|
+
|
|
31
|
+
Returns
|
|
32
|
+
-------
|
|
33
|
+
Status
|
|
34
|
+
Status object.
|
|
35
|
+
"""
|
|
36
|
+
infos: RegistryEntry = getattr(registry, kind)
|
|
37
|
+
status = import_class(infos.status.module, infos.status.class_name)
|
|
38
|
+
kwargs = parse_arguments(**kwargs)
|
|
39
|
+
return status(**kwargs)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def parse_arguments(**kwargs) -> dict:
|
|
43
|
+
"""
|
|
44
|
+
Parse keyword arguments and add default values if necessary.
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
**kwargs : dict
|
|
49
|
+
Keyword arguments.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
dict
|
|
54
|
+
Keyword arguments with default values.
|
|
55
|
+
"""
|
|
56
|
+
state = kwargs.get("state")
|
|
57
|
+
if state is None:
|
|
58
|
+
kwargs["state"] = State.CREATED.value
|
|
59
|
+
else:
|
|
60
|
+
if kwargs["state"] not in State.__members__:
|
|
61
|
+
raise ValueError(f"Invalid state: {state}")
|
|
62
|
+
return kwargs
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from uuid import uuid4
|
|
4
|
+
|
|
5
|
+
from pydantic import UUID4, BaseModel
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class UUIDValidator(BaseModel):
|
|
9
|
+
"""
|
|
10
|
+
Validate UUID format.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
uuid: UUID4
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def build_uuid(uuid: str | None = None) -> str:
|
|
17
|
+
"""
|
|
18
|
+
Create a uuid if not given. If given, validate it.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
uuid : str
|
|
23
|
+
ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
|
|
24
|
+
|
|
25
|
+
Returns
|
|
26
|
+
-------
|
|
27
|
+
str
|
|
28
|
+
Validated UUID4.
|
|
29
|
+
"""
|
|
30
|
+
if uuid is not None:
|
|
31
|
+
UUIDValidator(uuid=uuid)
|
|
32
|
+
return uuid
|
|
33
|
+
return str(uuid4())
|
|
File without changes
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from digitalhub.entities._builders.metadata import build_metadata
|
|
6
|
+
from digitalhub.entities._builders.name import build_name
|
|
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
|
|
11
|
+
|
|
12
|
+
if typing.TYPE_CHECKING:
|
|
13
|
+
from digitalhub.entities.artifact.entity._base import Artifact
|
|
14
|
+
|
|
15
|
+
# Manage class mapper
|
|
16
|
+
cls_mapper = {}
|
|
17
|
+
|
|
18
|
+
try:
|
|
19
|
+
from digitalhub.entities.artifact.entity.artifact import ArtifactArtifact
|
|
20
|
+
|
|
21
|
+
cls_mapper["artifact"] = ArtifactArtifact
|
|
22
|
+
except ImportError:
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _choose_artifact_type(kind: str) -> type[Artifact]:
|
|
27
|
+
"""
|
|
28
|
+
Choose class based on kind.
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
kind : str
|
|
33
|
+
Kind the object.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
type[Artifact]
|
|
38
|
+
Class of the artifact.
|
|
39
|
+
"""
|
|
40
|
+
try:
|
|
41
|
+
return cls_mapper[kind]
|
|
42
|
+
except KeyError:
|
|
43
|
+
raise EntityError(f"Unknown artifact kind: {kind}")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def artifact_from_parameters(
|
|
47
|
+
project: str,
|
|
48
|
+
name: str,
|
|
49
|
+
kind: str,
|
|
50
|
+
uuid: str | None = None,
|
|
51
|
+
description: str | None = None,
|
|
52
|
+
labels: list[str] | None = None,
|
|
53
|
+
embedded: bool = True,
|
|
54
|
+
path: str | None = None,
|
|
55
|
+
**kwargs,
|
|
56
|
+
) -> Artifact:
|
|
57
|
+
"""
|
|
58
|
+
Create a new object.
|
|
59
|
+
|
|
60
|
+
Parameters
|
|
61
|
+
----------
|
|
62
|
+
project : str
|
|
63
|
+
Project name.
|
|
64
|
+
name : str
|
|
65
|
+
Object name.
|
|
66
|
+
kind : str
|
|
67
|
+
Kind the object.
|
|
68
|
+
uuid : str
|
|
69
|
+
ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
|
|
70
|
+
description : str
|
|
71
|
+
Description of the object (human readable).
|
|
72
|
+
labels : list[str]
|
|
73
|
+
List of labels.
|
|
74
|
+
embedded : bool
|
|
75
|
+
Flag to determine if object spec must be embedded in project spec.
|
|
76
|
+
path : str
|
|
77
|
+
Object path on local file system or remote storage. It is also the destination path of upload() method.
|
|
78
|
+
**kwargs : dict
|
|
79
|
+
Spec keyword arguments.
|
|
80
|
+
|
|
81
|
+
Returns
|
|
82
|
+
-------
|
|
83
|
+
Artifact
|
|
84
|
+
Object instance.
|
|
85
|
+
"""
|
|
86
|
+
if path is None:
|
|
87
|
+
raise EntityError("Path must be provided.")
|
|
88
|
+
name = build_name(name)
|
|
89
|
+
uuid = build_uuid(uuid)
|
|
90
|
+
metadata = build_metadata(
|
|
91
|
+
kind,
|
|
92
|
+
project=project,
|
|
93
|
+
name=name,
|
|
94
|
+
version=uuid,
|
|
95
|
+
description=description,
|
|
96
|
+
labels=labels,
|
|
97
|
+
embedded=embedded,
|
|
98
|
+
)
|
|
99
|
+
spec = build_spec(
|
|
100
|
+
kind,
|
|
101
|
+
path=path,
|
|
102
|
+
**kwargs,
|
|
103
|
+
)
|
|
104
|
+
status = build_status(kind)
|
|
105
|
+
cls = _choose_artifact_type(kind)
|
|
106
|
+
return cls(
|
|
107
|
+
project=project,
|
|
108
|
+
name=name,
|
|
109
|
+
uuid=uuid,
|
|
110
|
+
kind=kind,
|
|
111
|
+
metadata=metadata,
|
|
112
|
+
spec=spec,
|
|
113
|
+
status=status,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def artifact_from_dict(obj: dict) -> Artifact:
|
|
118
|
+
"""
|
|
119
|
+
Create a new object from dictionary.
|
|
120
|
+
|
|
121
|
+
Parameters
|
|
122
|
+
----------
|
|
123
|
+
obj : dict
|
|
124
|
+
Dictionary to create object from.
|
|
125
|
+
|
|
126
|
+
Returns
|
|
127
|
+
-------
|
|
128
|
+
Artifact
|
|
129
|
+
Object instance.
|
|
130
|
+
"""
|
|
131
|
+
kind = obj.get("kind")
|
|
132
|
+
cls = _choose_artifact_type(kind)
|
|
133
|
+
return cls.from_dict(obj)
|