digitalhub 0.8.0b0__py3-none-any.whl → 0.8.0b2__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.0b2.dist-info}/METADATA +27 -12
- digitalhub-0.8.0b2.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.0b2.dist-info}/LICENSE.txt +0 -0
- {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b2.dist-info}/WHEEL +0 -0
- {digitalhub-0.8.0b0.dist-info → digitalhub-0.8.0b2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub.entities._base.spec.base import Spec, SpecParams
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ProjectSpec(Spec):
|
|
7
|
+
"""
|
|
8
|
+
Project specification.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
context: str | None = None,
|
|
14
|
+
functions: list | None = None,
|
|
15
|
+
artifacts: list | None = None,
|
|
16
|
+
workflows: list | None = None,
|
|
17
|
+
dataitems: list | None = None,
|
|
18
|
+
models: list | None = None,
|
|
19
|
+
**kwargs,
|
|
20
|
+
) -> None:
|
|
21
|
+
self.context = context if context is not None else "./"
|
|
22
|
+
self.functions = functions if functions is not None else []
|
|
23
|
+
self.artifacts = artifacts if artifacts is not None else []
|
|
24
|
+
self.workflows = workflows if workflows is not None else []
|
|
25
|
+
self.dataitems = dataitems if dataitems is not None else []
|
|
26
|
+
self.models = models if models is not None else []
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class ProjectParams(SpecParams):
|
|
30
|
+
"""
|
|
31
|
+
Parameters model for project.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
context: str = None
|
|
35
|
+
"""The project's context."""
|
|
36
|
+
|
|
37
|
+
functions: list = None
|
|
38
|
+
"""List of project's functions."""
|
|
39
|
+
|
|
40
|
+
artifacts: list = None
|
|
41
|
+
"""List of project's artifacts."""
|
|
42
|
+
|
|
43
|
+
workflows: list = None
|
|
44
|
+
"""List of project's workflows."""
|
|
45
|
+
|
|
46
|
+
dataitems: list = None
|
|
47
|
+
"""List of project's dataitems."""
|
|
48
|
+
|
|
49
|
+
models: list = None
|
|
50
|
+
"""List of project's models."""
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub.entities.entity_types import EntityTypes
|
|
4
|
+
from digitalhub.registry.registry import registry
|
|
5
|
+
from digitalhub.registry.utils import create_info
|
|
6
|
+
|
|
7
|
+
# Root module
|
|
8
|
+
root = "digitalhub.entities"
|
|
9
|
+
|
|
10
|
+
# Projects
|
|
11
|
+
entity_type = EntityTypes.PROJECT.value
|
|
12
|
+
prefix = entity_type.capitalize()
|
|
13
|
+
project_info = create_info(root, entity_type, prefix)
|
|
14
|
+
registry.register("project", project_info)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# Secrets
|
|
18
|
+
entity_type = EntityTypes.SECRET.value
|
|
19
|
+
prefix = entity_type.capitalize()
|
|
20
|
+
secret_info = create_info(root, entity_type, prefix)
|
|
21
|
+
registry.register("secret", secret_info)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Artifacts
|
|
25
|
+
entity_type = EntityTypes.ARTIFACT.value
|
|
26
|
+
for i in ["artifact"]:
|
|
27
|
+
prefix = entity_type.capitalize()
|
|
28
|
+
suffix = i.capitalize()
|
|
29
|
+
artifact_info = create_info(root, entity_type, prefix, suffix)
|
|
30
|
+
registry.register(i, artifact_info)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# Dataitems
|
|
34
|
+
entity_type = EntityTypes.DATAITEM.value
|
|
35
|
+
for i in ["dataitem", "table"]:
|
|
36
|
+
prefix = entity_type.capitalize()
|
|
37
|
+
suffix = i.capitalize()
|
|
38
|
+
dataitem_info = create_info(root, entity_type, prefix, suffix)
|
|
39
|
+
registry.register(i, dataitem_info)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# Models
|
|
43
|
+
entity_type = EntityTypes.MODEL.value
|
|
44
|
+
for i in ["model", "mlflow", "sklearn", "huggingface"]:
|
|
45
|
+
prefix = entity_type.capitalize()
|
|
46
|
+
suffix = i.capitalize()
|
|
47
|
+
model_info = create_info(root, entity_type, prefix, suffix)
|
|
48
|
+
registry.register(i, model_info)
|
|
File without changes
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from digitalhub.entities._builders.metadata import build_metadata
|
|
4
|
+
from digitalhub.entities._builders.spec import build_spec
|
|
5
|
+
from digitalhub.entities._builders.status import build_status
|
|
6
|
+
from digitalhub.entities._builders.uuid import build_uuid
|
|
7
|
+
from digitalhub.entities.run.entity import Run
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def run_from_parameters(
|
|
11
|
+
project: str,
|
|
12
|
+
kind: str,
|
|
13
|
+
uuid: str | None = None,
|
|
14
|
+
labels: list[str] | None = None,
|
|
15
|
+
task: str | None = None,
|
|
16
|
+
local_execution: bool = False,
|
|
17
|
+
**kwargs,
|
|
18
|
+
) -> Run:
|
|
19
|
+
"""
|
|
20
|
+
Create run.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
project : str
|
|
25
|
+
Project name.
|
|
26
|
+
kind : str
|
|
27
|
+
Kind the object.
|
|
28
|
+
uuid : str
|
|
29
|
+
ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
|
|
30
|
+
labels : list[str]
|
|
31
|
+
List of labels.
|
|
32
|
+
task : str
|
|
33
|
+
Name of the task associated with the run.
|
|
34
|
+
local_execution : bool
|
|
35
|
+
Flag to determine if object has local execution.
|
|
36
|
+
**kwargs : dict
|
|
37
|
+
Spec keyword arguments.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
Run
|
|
42
|
+
Object instance.
|
|
43
|
+
"""
|
|
44
|
+
uuid = build_uuid(uuid)
|
|
45
|
+
metadata = build_metadata(
|
|
46
|
+
kind=kind,
|
|
47
|
+
project=project,
|
|
48
|
+
name=uuid,
|
|
49
|
+
labels=labels,
|
|
50
|
+
)
|
|
51
|
+
spec = build_spec(kind, task=task, local_execution=local_execution, **kwargs)
|
|
52
|
+
status = build_status(kind)
|
|
53
|
+
return Run(
|
|
54
|
+
project=project,
|
|
55
|
+
uuid=uuid,
|
|
56
|
+
kind=kind,
|
|
57
|
+
metadata=metadata,
|
|
58
|
+
spec=spec,
|
|
59
|
+
status=status,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def run_from_dict(obj: dict) -> Run:
|
|
64
|
+
"""
|
|
65
|
+
Create a new object from dictionary.
|
|
66
|
+
|
|
67
|
+
Parameters
|
|
68
|
+
----------
|
|
69
|
+
obj : dict
|
|
70
|
+
Dictionary to create object from.
|
|
71
|
+
|
|
72
|
+
Returns
|
|
73
|
+
-------
|
|
74
|
+
Run
|
|
75
|
+
Object instance.
|
|
76
|
+
"""
|
|
77
|
+
return Run.from_dict(obj)
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from digitalhub.context.builder import check_context
|
|
6
|
+
from digitalhub.entities._base.crud import delete_entity_api_ctx, list_entity_api_ctx, read_entity_api_ctx
|
|
7
|
+
from digitalhub.entities.entity_types import EntityTypes
|
|
8
|
+
from digitalhub.entities.run.builder import run_from_dict, run_from_parameters
|
|
9
|
+
from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityError
|
|
10
|
+
from digitalhub.utils.io_utils import read_yaml
|
|
11
|
+
|
|
12
|
+
if typing.TYPE_CHECKING:
|
|
13
|
+
from digitalhub.entities.run.entity import Run
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
ENTITY_TYPE = EntityTypes.RUN.value
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def new_run(
|
|
20
|
+
project: str,
|
|
21
|
+
kind: str,
|
|
22
|
+
uuid: str | None = None,
|
|
23
|
+
labels: list[str] | None = None,
|
|
24
|
+
task: str | None = None,
|
|
25
|
+
local_execution: bool = False,
|
|
26
|
+
**kwargs,
|
|
27
|
+
) -> Run:
|
|
28
|
+
"""
|
|
29
|
+
Create a new object.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
project : str
|
|
34
|
+
Project name.
|
|
35
|
+
kind : str
|
|
36
|
+
Kind the object.
|
|
37
|
+
uuid : str
|
|
38
|
+
ID of the object (UUID4, e.g. 40f25c4b-d26b-4221-b048-9527aff291e2).
|
|
39
|
+
labels : list[str]
|
|
40
|
+
List of labels.
|
|
41
|
+
task : str
|
|
42
|
+
Name of the task associated with the run.
|
|
43
|
+
local_execution : bool
|
|
44
|
+
Flag to determine if object has local execution.
|
|
45
|
+
**kwargs : dict
|
|
46
|
+
Spec keyword arguments.
|
|
47
|
+
|
|
48
|
+
Returns
|
|
49
|
+
-------
|
|
50
|
+
Run
|
|
51
|
+
Object instance.
|
|
52
|
+
|
|
53
|
+
Examples
|
|
54
|
+
--------
|
|
55
|
+
>>> obj = new_function(project="my-project",
|
|
56
|
+
>>> name="my-function",
|
|
57
|
+
>>> kind="python+run",
|
|
58
|
+
>>> task="task-string"
|
|
59
|
+
"""
|
|
60
|
+
check_context(project)
|
|
61
|
+
obj = run_from_parameters(
|
|
62
|
+
project=project,
|
|
63
|
+
kind=kind,
|
|
64
|
+
uuid=uuid,
|
|
65
|
+
labels=labels,
|
|
66
|
+
task=task,
|
|
67
|
+
local_execution=local_execution,
|
|
68
|
+
**kwargs,
|
|
69
|
+
)
|
|
70
|
+
obj.save()
|
|
71
|
+
return obj
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def get_run(
|
|
75
|
+
identifier: str,
|
|
76
|
+
project: str | None = None,
|
|
77
|
+
**kwargs,
|
|
78
|
+
) -> Run:
|
|
79
|
+
"""
|
|
80
|
+
Get object from backend.
|
|
81
|
+
|
|
82
|
+
Parameters
|
|
83
|
+
----------
|
|
84
|
+
identifier : str
|
|
85
|
+
Entity key (store://...) or entity ID.
|
|
86
|
+
project : str
|
|
87
|
+
Project name.
|
|
88
|
+
**kwargs : dict
|
|
89
|
+
Parameters to pass to the API call.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
Run
|
|
94
|
+
Object instance.
|
|
95
|
+
|
|
96
|
+
Examples
|
|
97
|
+
--------
|
|
98
|
+
Using entity key:
|
|
99
|
+
>>> obj = get_run("store://my-run-key")
|
|
100
|
+
|
|
101
|
+
Using entity ID:
|
|
102
|
+
>>> obj = get_run("my-run-id"
|
|
103
|
+
>>> project="my-project")
|
|
104
|
+
"""
|
|
105
|
+
if not identifier.startswith("store://") and project is None:
|
|
106
|
+
raise EntityError("Specify entity key or entity ID combined with project")
|
|
107
|
+
obj = read_entity_api_ctx(
|
|
108
|
+
identifier,
|
|
109
|
+
ENTITY_TYPE,
|
|
110
|
+
project=project,
|
|
111
|
+
entity_id=identifier,
|
|
112
|
+
**kwargs,
|
|
113
|
+
)
|
|
114
|
+
return run_from_dict(obj)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def list_runs(project: str, **kwargs) -> list[Run]:
|
|
118
|
+
"""
|
|
119
|
+
List all latest version objects from backend.
|
|
120
|
+
|
|
121
|
+
Parameters
|
|
122
|
+
----------
|
|
123
|
+
project : str
|
|
124
|
+
Project name.
|
|
125
|
+
**kwargs : dict
|
|
126
|
+
Parameters to pass to the API call.
|
|
127
|
+
|
|
128
|
+
Returns
|
|
129
|
+
-------
|
|
130
|
+
list[Run]
|
|
131
|
+
List of object instances.
|
|
132
|
+
|
|
133
|
+
Examples
|
|
134
|
+
--------
|
|
135
|
+
>>> objs = list_runs(project="my-project")
|
|
136
|
+
"""
|
|
137
|
+
# TODO more examples: search by function, latest for task and function
|
|
138
|
+
objs = list_entity_api_ctx(
|
|
139
|
+
project=project,
|
|
140
|
+
entity_type=ENTITY_TYPE,
|
|
141
|
+
**kwargs,
|
|
142
|
+
)
|
|
143
|
+
return [run_from_dict(obj) for obj in objs]
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def import_run(file: str) -> Run:
|
|
147
|
+
"""
|
|
148
|
+
Get object from file.
|
|
149
|
+
|
|
150
|
+
Parameters
|
|
151
|
+
----------
|
|
152
|
+
file : str
|
|
153
|
+
Path to YAML file.
|
|
154
|
+
|
|
155
|
+
Returns
|
|
156
|
+
-------
|
|
157
|
+
Run
|
|
158
|
+
Object instance.
|
|
159
|
+
|
|
160
|
+
Example
|
|
161
|
+
-------
|
|
162
|
+
>>> obj = import_run("my-run.yaml")
|
|
163
|
+
"""
|
|
164
|
+
dict_obj: dict = read_yaml(file)
|
|
165
|
+
obj = run_from_dict(dict_obj)
|
|
166
|
+
try:
|
|
167
|
+
obj.save()
|
|
168
|
+
except EntityAlreadyExistsError:
|
|
169
|
+
pass
|
|
170
|
+
finally:
|
|
171
|
+
return obj
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def update_run(entity: Run) -> Run:
|
|
175
|
+
"""
|
|
176
|
+
Update object. Note that object spec are immutable.
|
|
177
|
+
|
|
178
|
+
Parameters
|
|
179
|
+
----------
|
|
180
|
+
entity : Run
|
|
181
|
+
Object to update.
|
|
182
|
+
|
|
183
|
+
Returns
|
|
184
|
+
-------
|
|
185
|
+
Run
|
|
186
|
+
Entity updated.
|
|
187
|
+
|
|
188
|
+
Examples
|
|
189
|
+
--------
|
|
190
|
+
>>> obj = update_run(obj)
|
|
191
|
+
"""
|
|
192
|
+
return entity.save(update=True)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def delete_run(
|
|
196
|
+
identifier: str,
|
|
197
|
+
project: str | None = None,
|
|
198
|
+
**kwargs,
|
|
199
|
+
) -> dict:
|
|
200
|
+
"""
|
|
201
|
+
Delete object from backend.
|
|
202
|
+
|
|
203
|
+
Parameters
|
|
204
|
+
----------
|
|
205
|
+
identifier : str
|
|
206
|
+
Entity key (store://...) or entity ID.
|
|
207
|
+
project : str
|
|
208
|
+
Project name.
|
|
209
|
+
**kwargs : dict
|
|
210
|
+
Parameters to pass to the API call.
|
|
211
|
+
|
|
212
|
+
Returns
|
|
213
|
+
-------
|
|
214
|
+
dict
|
|
215
|
+
Response from backend.
|
|
216
|
+
|
|
217
|
+
Examples
|
|
218
|
+
--------
|
|
219
|
+
>>> obj = delete_run("store://my-run-key")
|
|
220
|
+
>>> obj = delete_run("my-run-id", project="my-project")
|
|
221
|
+
"""
|
|
222
|
+
if not identifier.startswith("store://") and project is None:
|
|
223
|
+
raise EntityError("Specify entity key or entity ID combined with project")
|
|
224
|
+
return delete_entity_api_ctx(
|
|
225
|
+
identifier=identifier,
|
|
226
|
+
entity_type=ENTITY_TYPE,
|
|
227
|
+
project=project,
|
|
228
|
+
entity_id=identifier,
|
|
229
|
+
**kwargs,
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
# TODO read logs
|