digitalhub 0.10.2__py3-none-any.whl → 0.11.0b0__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 +10 -0
- digitalhub/context/api.py +10 -4
- digitalhub/context/builder.py +35 -20
- digitalhub/context/context.py +35 -24
- digitalhub/entities/_base/entity/builder.py +11 -0
- digitalhub/entities/_base/executable/entity.py +30 -4
- digitalhub/entities/_base/material/utils.py +11 -11
- digitalhub/entities/_commons/enums.py +2 -0
- digitalhub/entities/_processors/base.py +15 -15
- digitalhub/entities/_processors/context.py +13 -13
- digitalhub/entities/_processors/utils.py +2 -2
- digitalhub/entities/builders.py +2 -0
- digitalhub/entities/function/_base/entity.py +49 -3
- digitalhub/entities/project/_base/builder.py +4 -0
- digitalhub/entities/project/_base/entity.py +5 -2
- digitalhub/entities/project/_base/models.py +18 -0
- digitalhub/entities/project/_base/spec.py +6 -0
- digitalhub/entities/project/crud.py +2 -13
- digitalhub/entities/run/_base/entity.py +6 -12
- digitalhub/entities/task/_base/entity.py +4 -4
- digitalhub/entities/task/_base/models.py +22 -2
- digitalhub/entities/trigger/__init__.py +0 -0
- digitalhub/entities/trigger/_base/__init__.py +0 -0
- digitalhub/entities/trigger/_base/builder.py +70 -0
- digitalhub/entities/trigger/_base/entity.py +34 -0
- digitalhub/entities/trigger/_base/spec.py +30 -0
- digitalhub/entities/trigger/_base/status.py +9 -0
- digitalhub/entities/trigger/crud.py +303 -0
- digitalhub/entities/trigger/scheduler/__init__.py +0 -0
- digitalhub/entities/trigger/scheduler/builder.py +19 -0
- digitalhub/entities/trigger/scheduler/entity.py +32 -0
- digitalhub/entities/trigger/scheduler/spec.py +22 -0
- digitalhub/entities/trigger/scheduler/status.py +9 -0
- digitalhub/entities/workflow/_base/entity.py +3 -3
- digitalhub/factory/factory.py +113 -26
- digitalhub/factory/utils.py +31 -14
- digitalhub/runtimes/_base.py +22 -11
- digitalhub/runtimes/builder.py +16 -3
- digitalhub/runtimes/enums.py +11 -1
- digitalhub/stores/configurator/configurator.py +2 -1
- digitalhub/stores/configurator/enums.py +9 -0
- digitalhub/stores/data/api.py +4 -2
- digitalhub/stores/data/builder.py +4 -4
- digitalhub/stores/data/enums.py +11 -0
- digitalhub/stores/data/local/store.py +2 -2
- digitalhub/stores/data/remote/store.py +2 -2
- digitalhub/stores/data/s3/configurator.py +11 -7
- digitalhub/stores/data/s3/store.py +4 -10
- digitalhub/stores/data/sql/configurator.py +20 -11
- digitalhub/stores/data/sql/store.py +2 -4
- digitalhub/stores/data/utils.py +34 -0
- digitalhub/utils/uri_utils.py +5 -0
- {digitalhub-0.10.2.dist-info → digitalhub-0.11.0b0.dist-info}/METADATA +1 -1
- {digitalhub-0.10.2.dist-info → digitalhub-0.11.0b0.dist-info}/RECORD +56 -42
- digitalhub/factory/api.py +0 -277
- {digitalhub-0.10.2.dist-info → digitalhub-0.11.0b0.dist-info}/WHEEL +0 -0
- {digitalhub-0.10.2.dist-info → digitalhub-0.11.0b0.dist-info}/licenses/LICENSE.txt +0 -0
digitalhub/__init__.py
CHANGED
|
@@ -72,6 +72,16 @@ from digitalhub.entities.task.crud import (
|
|
|
72
72
|
new_task,
|
|
73
73
|
update_task,
|
|
74
74
|
)
|
|
75
|
+
from digitalhub.entities.trigger.crud import (
|
|
76
|
+
delete_trigger,
|
|
77
|
+
get_trigger,
|
|
78
|
+
get_trigger_versions,
|
|
79
|
+
import_trigger,
|
|
80
|
+
list_triggers,
|
|
81
|
+
load_trigger,
|
|
82
|
+
new_trigger,
|
|
83
|
+
update_trigger,
|
|
84
|
+
)
|
|
75
85
|
from digitalhub.entities.workflow.crud import (
|
|
76
86
|
delete_workflow,
|
|
77
87
|
get_workflow,
|
digitalhub/context/api.py
CHANGED
|
@@ -9,20 +9,26 @@ if typing.TYPE_CHECKING:
|
|
|
9
9
|
from digitalhub.entities.project._base.entity import Project
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def build_context(project: Project, overwrite: bool = False) ->
|
|
12
|
+
def build_context(project: Project, overwrite: bool = False) -> Context:
|
|
13
13
|
"""
|
|
14
|
-
|
|
14
|
+
Build a new context for a project.
|
|
15
|
+
|
|
16
|
+
Creates or updates a context instance for the given project in the global
|
|
17
|
+
context registry.
|
|
15
18
|
|
|
16
19
|
Parameters
|
|
17
20
|
----------
|
|
18
21
|
project : Project
|
|
19
22
|
The project object used to build the context.
|
|
23
|
+
overwrite : bool, optional
|
|
24
|
+
If True, overwrites existing context if it exists, by default False.
|
|
20
25
|
|
|
21
26
|
Returns
|
|
22
27
|
-------
|
|
23
|
-
|
|
28
|
+
Context
|
|
29
|
+
The newly created or existing context instance.
|
|
24
30
|
"""
|
|
25
|
-
context_builder.build(project, overwrite)
|
|
31
|
+
return context_builder.build(project, overwrite)
|
|
26
32
|
|
|
27
33
|
|
|
28
34
|
def get_context(project: str) -> Context:
|
digitalhub/context/builder.py
CHANGED
|
@@ -11,51 +11,60 @@ if typing.TYPE_CHECKING:
|
|
|
11
11
|
|
|
12
12
|
class ContextBuilder:
|
|
13
13
|
"""
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
A builder class for managing project contexts.
|
|
15
|
+
|
|
16
|
+
This class implements the builder pattern to create and manage Context instances.
|
|
17
|
+
It maintains a registry of project contexts, allowing multiple projects to be
|
|
18
|
+
used simultaneously by storing them with their respective names.
|
|
19
|
+
|
|
20
|
+
Attributes
|
|
21
|
+
----------
|
|
22
|
+
_instances : dict[str, Context]
|
|
23
|
+
Internal registry mapping project names to their Context instances.
|
|
18
24
|
"""
|
|
19
25
|
|
|
20
26
|
def __init__(self) -> None:
|
|
21
27
|
self._instances: dict[str, Context] = {}
|
|
22
28
|
|
|
23
|
-
def build(self,
|
|
29
|
+
def build(self, project: Project, overwrite: bool = False) -> Context:
|
|
24
30
|
"""
|
|
25
|
-
Add a project as context.
|
|
31
|
+
Add a project as context and return the created Context instance.
|
|
26
32
|
|
|
27
33
|
Parameters
|
|
28
34
|
----------
|
|
29
|
-
|
|
30
|
-
The project to
|
|
31
|
-
overwrite : bool
|
|
32
|
-
If True,
|
|
35
|
+
project : Project
|
|
36
|
+
The project instance to create a context for.
|
|
37
|
+
overwrite : bool, optional
|
|
38
|
+
If True, overwrites existing context if project name already exists,
|
|
39
|
+
by default False.
|
|
33
40
|
|
|
34
41
|
Returns
|
|
35
42
|
-------
|
|
36
|
-
|
|
43
|
+
Context
|
|
44
|
+
The newly created or existing Context instance.
|
|
37
45
|
"""
|
|
38
|
-
if (
|
|
39
|
-
self._instances[
|
|
46
|
+
if (project.name not in self._instances) or overwrite:
|
|
47
|
+
self._instances[project.name] = Context(project)
|
|
48
|
+
return self._instances[project.name]
|
|
40
49
|
|
|
41
50
|
def get(self, project: str) -> Context:
|
|
42
51
|
"""
|
|
43
|
-
|
|
52
|
+
Retrieve a context instance by project name.
|
|
44
53
|
|
|
45
54
|
Parameters
|
|
46
55
|
----------
|
|
47
56
|
project : str
|
|
48
|
-
The project
|
|
57
|
+
The name of the project whose context to retrieve.
|
|
49
58
|
|
|
50
59
|
Returns
|
|
51
60
|
-------
|
|
52
61
|
Context
|
|
53
|
-
The project
|
|
62
|
+
The context instance associated with the project.
|
|
54
63
|
|
|
55
64
|
Raises
|
|
56
65
|
------
|
|
57
|
-
|
|
58
|
-
If
|
|
66
|
+
ContextError
|
|
67
|
+
If no context exists for the specified project name.
|
|
59
68
|
"""
|
|
60
69
|
try:
|
|
61
70
|
return self._instances[project]
|
|
@@ -64,16 +73,22 @@ class ContextBuilder:
|
|
|
64
73
|
|
|
65
74
|
def remove(self, project: str) -> None:
|
|
66
75
|
"""
|
|
67
|
-
Remove a project from the
|
|
76
|
+
Remove a project's context from the registry.
|
|
68
77
|
|
|
69
78
|
Parameters
|
|
70
79
|
----------
|
|
71
80
|
project : str
|
|
72
|
-
The project
|
|
81
|
+
The name of the project whose context should be removed.
|
|
73
82
|
|
|
74
83
|
Returns
|
|
75
84
|
-------
|
|
76
85
|
None
|
|
86
|
+
This method doesn't return anything.
|
|
87
|
+
|
|
88
|
+
Notes
|
|
89
|
+
-----
|
|
90
|
+
If the project doesn't exist in the registry, this method
|
|
91
|
+
silently does nothing.
|
|
77
92
|
"""
|
|
78
93
|
self._instances.pop(project, None)
|
|
79
94
|
|
digitalhub/context/context.py
CHANGED
|
@@ -5,60 +5,71 @@ from pathlib import Path
|
|
|
5
5
|
|
|
6
6
|
if typing.TYPE_CHECKING:
|
|
7
7
|
from digitalhub.entities.project._base.entity import Project
|
|
8
|
+
from digitalhub.stores.client._base.client import Client
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class Context:
|
|
11
12
|
"""
|
|
12
|
-
Context class built
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
Context class built from a Project instance.
|
|
14
|
+
|
|
15
|
+
Contains project-specific information and state, including project name,
|
|
16
|
+
client instance, local context paths, and run-time information.
|
|
17
|
+
|
|
18
|
+
Attributes
|
|
19
|
+
----------
|
|
20
|
+
name : str
|
|
21
|
+
The name of the project.
|
|
22
|
+
client : BaseClient
|
|
23
|
+
The client instance (local or remote) associated with the project.
|
|
24
|
+
config : dict
|
|
25
|
+
Project configuration profile.
|
|
26
|
+
local : bool
|
|
27
|
+
Whether the client is local or remote.
|
|
28
|
+
root : Path
|
|
29
|
+
The local context project path.
|
|
30
|
+
is_running : bool
|
|
31
|
+
Flag indicating if the context has an active run.
|
|
32
|
+
_run_ctx : str | None
|
|
33
|
+
Current run key, if any.
|
|
16
34
|
"""
|
|
17
35
|
|
|
18
36
|
def __init__(self, project: Project) -> None:
|
|
19
|
-
self.name = project.name
|
|
20
|
-
self.client = project._client
|
|
21
|
-
self.
|
|
22
|
-
self.
|
|
37
|
+
self.name: str = project.name
|
|
38
|
+
self.client: Client = project._client
|
|
39
|
+
self.config: dict = project.spec.config
|
|
40
|
+
self.local: bool = project._client.is_local()
|
|
41
|
+
self.root: Path = Path(project.spec.context)
|
|
23
42
|
self.root.mkdir(parents=True, exist_ok=True)
|
|
24
43
|
|
|
25
44
|
self.is_running: bool = False
|
|
26
|
-
self._run_ctx: str = None
|
|
45
|
+
self._run_ctx: str | None = None
|
|
27
46
|
|
|
28
47
|
def set_run(self, run_ctx: str) -> None:
|
|
29
48
|
"""
|
|
30
|
-
Set run
|
|
49
|
+
Set the current run key.
|
|
31
50
|
|
|
32
51
|
Parameters
|
|
33
52
|
----------
|
|
34
53
|
run_ctx : str
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Returns
|
|
38
|
-
-------
|
|
39
|
-
None
|
|
54
|
+
The run key to set.
|
|
40
55
|
"""
|
|
41
56
|
self.is_running = True
|
|
42
57
|
self._run_ctx = run_ctx
|
|
43
58
|
|
|
44
59
|
def unset_run(self) -> None:
|
|
45
60
|
"""
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Returns
|
|
49
|
-
-------
|
|
50
|
-
None
|
|
61
|
+
Clear the current run key and reset running state.
|
|
51
62
|
"""
|
|
52
63
|
self.is_running = False
|
|
53
64
|
self._run_ctx = None
|
|
54
65
|
|
|
55
|
-
def get_run_ctx(self) -> str:
|
|
66
|
+
def get_run_ctx(self) -> str | None:
|
|
56
67
|
"""
|
|
57
|
-
Get run
|
|
68
|
+
Get the current run key.
|
|
58
69
|
|
|
59
70
|
Returns
|
|
60
71
|
-------
|
|
61
|
-
str
|
|
62
|
-
|
|
72
|
+
str | None
|
|
73
|
+
The current run key if set, None otherwise.
|
|
63
74
|
"""
|
|
64
75
|
return self._run_ctx
|
|
@@ -178,3 +178,14 @@ class EntityBuilder:
|
|
|
178
178
|
Entity kind.
|
|
179
179
|
"""
|
|
180
180
|
return self.ENTITY_KIND
|
|
181
|
+
|
|
182
|
+
def get_spec_validator(self) -> type[SpecValidator]:
|
|
183
|
+
"""
|
|
184
|
+
Get entity spec validator.
|
|
185
|
+
|
|
186
|
+
Returns
|
|
187
|
+
-------
|
|
188
|
+
type[SpecValidator]
|
|
189
|
+
Entity spec validator.
|
|
190
|
+
"""
|
|
191
|
+
return self.ENTITY_SPEC_VALIDATOR
|
|
@@ -7,7 +7,7 @@ from digitalhub.entities._commons.enums import EntityTypes
|
|
|
7
7
|
from digitalhub.entities._processors.context import context_processor
|
|
8
8
|
from digitalhub.entities.run.crud import delete_run, get_run, list_runs
|
|
9
9
|
from digitalhub.entities.task.crud import delete_task
|
|
10
|
-
from digitalhub.factory.
|
|
10
|
+
from digitalhub.factory.factory import factory
|
|
11
11
|
from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityError
|
|
12
12
|
|
|
13
13
|
if typing.TYPE_CHECKING:
|
|
@@ -16,6 +16,7 @@ if typing.TYPE_CHECKING:
|
|
|
16
16
|
from digitalhub.entities._base.entity.status import Status
|
|
17
17
|
from digitalhub.entities.run._base.entity import Run
|
|
18
18
|
from digitalhub.entities.task._base.entity import Task
|
|
19
|
+
from digitalhub.entities.trigger._base.entity import Trigger
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
class ExecutableEntity(VersionedEntity):
|
|
@@ -102,7 +103,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
102
103
|
# Create a new object from dictionary.
|
|
103
104
|
# the form in which tasks are stored in function
|
|
104
105
|
# status
|
|
105
|
-
task_obj = build_entity_from_dict(task)
|
|
106
|
+
task_obj: Task = factory.build_entity_from_dict(task)
|
|
106
107
|
|
|
107
108
|
# Try to save it in backend to been able to use
|
|
108
109
|
# it for launching runs. In fact, tasks must be
|
|
@@ -145,7 +146,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
145
146
|
kwargs["kind"] = task_kind
|
|
146
147
|
|
|
147
148
|
# Create object instance
|
|
148
|
-
task = build_entity_from_params(**kwargs)
|
|
149
|
+
task: Task = factory.build_entity_from_params(**kwargs)
|
|
149
150
|
task.save()
|
|
150
151
|
|
|
151
152
|
self._tasks[task_kind] = task
|
|
@@ -207,7 +208,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
207
208
|
kwargs["uuid"] = self._tasks[kind].id
|
|
208
209
|
|
|
209
210
|
# Update task
|
|
210
|
-
task = build_entity_from_params(**kwargs)
|
|
211
|
+
task: Task = factory.build_entity_from_params(**kwargs)
|
|
211
212
|
task.save(update=True)
|
|
212
213
|
self._tasks[kind] = task
|
|
213
214
|
return task
|
|
@@ -403,3 +404,28 @@ class ExecutableEntity(VersionedEntity):
|
|
|
403
404
|
project=self.project,
|
|
404
405
|
**kwargs,
|
|
405
406
|
)
|
|
407
|
+
|
|
408
|
+
##############################
|
|
409
|
+
# Trigger
|
|
410
|
+
##############################
|
|
411
|
+
|
|
412
|
+
def new_trigger(self, trigger_kind: str, **kwargs) -> Trigger:
|
|
413
|
+
"""
|
|
414
|
+
Create new trigger.
|
|
415
|
+
|
|
416
|
+
Parameters
|
|
417
|
+
----------
|
|
418
|
+
trigger_kind : str
|
|
419
|
+
Kind the object.
|
|
420
|
+
**kwargs : dict
|
|
421
|
+
Keyword arguments.
|
|
422
|
+
|
|
423
|
+
Returns
|
|
424
|
+
-------
|
|
425
|
+
Trigger
|
|
426
|
+
New trigger.
|
|
427
|
+
"""
|
|
428
|
+
# Create object instance
|
|
429
|
+
trigger: Trigger = factory.build_entity_from_params(**kwargs)
|
|
430
|
+
trigger.save()
|
|
431
|
+
return trigger
|
|
@@ -2,9 +2,9 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
|
-
from digitalhub.stores.data.
|
|
5
|
+
from digitalhub.stores.data.utils import get_default_store
|
|
6
6
|
from digitalhub.utils.file_utils import eval_zip_type
|
|
7
|
-
from digitalhub.utils.uri_utils import
|
|
7
|
+
from digitalhub.utils.uri_utils import has_local_scheme
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def eval_local_source(source: str | list[str]) -> None:
|
|
@@ -34,7 +34,7 @@ def eval_local_source(source: str | list[str]) -> None:
|
|
|
34
34
|
raise ValueError("Invalid source path. Source must be a local path.")
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def eval_zip_sources(source: str | list[str]) ->
|
|
37
|
+
def eval_zip_sources(source: str | list[str]) -> bool:
|
|
38
38
|
"""
|
|
39
39
|
Evaluate zip sources.
|
|
40
40
|
|
|
@@ -45,21 +45,21 @@ def eval_zip_sources(source: str | list[str]) -> str:
|
|
|
45
45
|
|
|
46
46
|
Returns
|
|
47
47
|
-------
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
bool
|
|
49
|
+
True if source is zip.
|
|
50
50
|
"""
|
|
51
51
|
if isinstance(source, list):
|
|
52
52
|
if len(source) > 1:
|
|
53
|
-
return
|
|
53
|
+
return False
|
|
54
54
|
path = source[0]
|
|
55
55
|
else:
|
|
56
56
|
if Path(source).is_dir():
|
|
57
|
-
return
|
|
57
|
+
return False
|
|
58
58
|
path = source
|
|
59
59
|
|
|
60
60
|
if not eval_zip_type(path):
|
|
61
|
-
return
|
|
62
|
-
return
|
|
61
|
+
return False
|
|
62
|
+
return True
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
def build_log_path_from_source(
|
|
@@ -90,8 +90,8 @@ def build_log_path_from_source(
|
|
|
90
90
|
str
|
|
91
91
|
Log path.
|
|
92
92
|
"""
|
|
93
|
-
|
|
94
|
-
path = f"{
|
|
93
|
+
prefix = "zip+" if eval_zip_sources(source) else ""
|
|
94
|
+
path = f"{prefix}{get_default_store(project)}/{project}/{entity_type}/{name}/{uuid}"
|
|
95
95
|
|
|
96
96
|
if isinstance(source, list) and len(source) >= 1:
|
|
97
97
|
if len(source) > 1:
|
|
@@ -17,6 +17,7 @@ class EntityTypes(Enum):
|
|
|
17
17
|
WORKFLOW = "workflow"
|
|
18
18
|
TASK = "task"
|
|
19
19
|
RUN = "run"
|
|
20
|
+
TRIGGER = "trigger"
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
class Relationship(Enum):
|
|
@@ -103,3 +104,4 @@ class EntityKinds(Enum):
|
|
|
103
104
|
MODEL_HUGGINGFACE = "huggingface"
|
|
104
105
|
MODEL_SKLEARN = "sklearn"
|
|
105
106
|
SECRET_SECRET = "secret"
|
|
107
|
+
TRIGGER_SCHEDULER = "scheduler"
|
|
@@ -4,7 +4,7 @@ import typing
|
|
|
4
4
|
|
|
5
5
|
from digitalhub.context.api import delete_context
|
|
6
6
|
from digitalhub.entities._commons.enums import ApiCategories, BackendOperations
|
|
7
|
-
from digitalhub.factory.
|
|
7
|
+
from digitalhub.factory.factory import factory
|
|
8
8
|
from digitalhub.stores.client.api import get_client
|
|
9
9
|
from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityError, EntityNotExistsError
|
|
10
10
|
from digitalhub.utils.io_utils import read_yaml
|
|
@@ -84,11 +84,11 @@ class BaseEntityOperationsProcessor:
|
|
|
84
84
|
client = _entity._client
|
|
85
85
|
obj = _entity
|
|
86
86
|
else:
|
|
87
|
-
client = get_client(kwargs.get("local")
|
|
88
|
-
obj = build_entity_from_params(**kwargs)
|
|
87
|
+
client = get_client(kwargs.get("local"))
|
|
88
|
+
obj = factory.build_entity_from_params(**kwargs)
|
|
89
89
|
ent = self._create_base_entity(client, obj.ENTITY_TYPE, obj.to_dict())
|
|
90
90
|
ent["local"] = client.is_local()
|
|
91
|
-
return build_entity_from_dict(ent)
|
|
91
|
+
return factory.build_entity_from_dict(ent)
|
|
92
92
|
|
|
93
93
|
def _read_base_entity(
|
|
94
94
|
self,
|
|
@@ -147,10 +147,10 @@ class BaseEntityOperationsProcessor:
|
|
|
147
147
|
Project
|
|
148
148
|
Object instance.
|
|
149
149
|
"""
|
|
150
|
-
client = get_client(kwargs.pop("local", False)
|
|
150
|
+
client = get_client(kwargs.pop("local", False))
|
|
151
151
|
obj = self._read_base_entity(client, entity_type, entity_name, **kwargs)
|
|
152
152
|
obj["local"] = client.is_local()
|
|
153
|
-
return build_entity_from_dict(obj)
|
|
153
|
+
return factory.build_entity_from_dict(obj)
|
|
154
154
|
|
|
155
155
|
def import_project_entity(
|
|
156
156
|
self,
|
|
@@ -172,11 +172,11 @@ class BaseEntityOperationsProcessor:
|
|
|
172
172
|
Project
|
|
173
173
|
Object instance.
|
|
174
174
|
"""
|
|
175
|
-
client = get_client(kwargs.pop("local", False)
|
|
175
|
+
client = get_client(kwargs.pop("local", False))
|
|
176
176
|
obj: dict = read_yaml(file)
|
|
177
177
|
obj["status"] = {}
|
|
178
178
|
obj["local"] = client.is_local()
|
|
179
|
-
ent: Project = build_entity_from_dict(obj)
|
|
179
|
+
ent: Project = factory.build_entity_from_dict(obj)
|
|
180
180
|
|
|
181
181
|
try:
|
|
182
182
|
self._create_base_entity(ent._client, ent.ENTITY_TYPE, ent.to_dict())
|
|
@@ -208,10 +208,10 @@ class BaseEntityOperationsProcessor:
|
|
|
208
208
|
Project
|
|
209
209
|
Object instance.
|
|
210
210
|
"""
|
|
211
|
-
client = get_client(kwargs.pop("local", False)
|
|
211
|
+
client = get_client(kwargs.pop("local", False))
|
|
212
212
|
obj: dict = read_yaml(file)
|
|
213
213
|
obj["local"] = client.is_local()
|
|
214
|
-
ent: Project = build_entity_from_dict(obj)
|
|
214
|
+
ent: Project = factory.build_entity_from_dict(obj)
|
|
215
215
|
|
|
216
216
|
try:
|
|
217
217
|
self._update_base_entity(ent._client, ent.ENTITY_TYPE, ent.name, ent.to_dict())
|
|
@@ -278,7 +278,7 @@ class BaseEntityOperationsProcessor:
|
|
|
278
278
|
entities = []
|
|
279
279
|
for obj in objs:
|
|
280
280
|
obj["local"] = client.is_local()
|
|
281
|
-
ent = build_entity_from_dict(obj)
|
|
281
|
+
ent = factory.build_entity_from_dict(obj)
|
|
282
282
|
entities.append(ent)
|
|
283
283
|
return entities
|
|
284
284
|
|
|
@@ -345,10 +345,10 @@ class BaseEntityOperationsProcessor:
|
|
|
345
345
|
Project
|
|
346
346
|
Object instance.
|
|
347
347
|
"""
|
|
348
|
-
client = get_client(kwargs.pop("local", False)
|
|
348
|
+
client = get_client(kwargs.pop("local", False))
|
|
349
349
|
obj = self._update_base_entity(client, entity_type, entity_name, entity_dict, **kwargs)
|
|
350
350
|
obj["local"] = client.is_local()
|
|
351
|
-
return build_entity_from_dict(obj)
|
|
351
|
+
return factory.build_entity_from_dict(obj)
|
|
352
352
|
|
|
353
353
|
def _delete_base_entity(
|
|
354
354
|
self,
|
|
@@ -414,7 +414,7 @@ class BaseEntityOperationsProcessor:
|
|
|
414
414
|
"""
|
|
415
415
|
if kwargs.pop("clean_context", True):
|
|
416
416
|
delete_context(entity_name)
|
|
417
|
-
client = get_client(kwargs.pop("local", False)
|
|
417
|
+
client = get_client(kwargs.pop("local", False))
|
|
418
418
|
return self._delete_base_entity(
|
|
419
419
|
client,
|
|
420
420
|
entity_type,
|
|
@@ -493,7 +493,7 @@ class BaseEntityOperationsProcessor:
|
|
|
493
493
|
-------
|
|
494
494
|
None
|
|
495
495
|
"""
|
|
496
|
-
client = get_client(kwargs.pop("local", False)
|
|
496
|
+
client = get_client(kwargs.pop("local", False))
|
|
497
497
|
api = client.build_api(
|
|
498
498
|
ApiCategories.BASE.value,
|
|
499
499
|
BackendOperations.SHARE.value,
|
|
@@ -9,7 +9,7 @@ from digitalhub.entities._processors.utils import (
|
|
|
9
9
|
get_context_from_project,
|
|
10
10
|
parse_identifier,
|
|
11
11
|
)
|
|
12
|
-
from digitalhub.factory.
|
|
12
|
+
from digitalhub.factory.factory import factory
|
|
13
13
|
from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityError, EntityNotExistsError
|
|
14
14
|
from digitalhub.utils.io_utils import read_yaml
|
|
15
15
|
from digitalhub.utils.types import SourcesOrListOfSources
|
|
@@ -91,9 +91,9 @@ class ContextEntityOperationsProcessor:
|
|
|
91
91
|
obj = _entity
|
|
92
92
|
else:
|
|
93
93
|
context = get_context_from_project(kwargs["project"])
|
|
94
|
-
obj: ContextEntity = build_entity_from_params(**kwargs)
|
|
94
|
+
obj: ContextEntity = factory.build_entity_from_params(**kwargs)
|
|
95
95
|
new_obj = self._create_context_entity(context, obj.ENTITY_TYPE, obj.to_dict())
|
|
96
|
-
return build_entity_from_dict(new_obj)
|
|
96
|
+
return factory.build_entity_from_dict(new_obj)
|
|
97
97
|
|
|
98
98
|
def log_material_entity(
|
|
99
99
|
self,
|
|
@@ -114,12 +114,12 @@ class ContextEntityOperationsProcessor:
|
|
|
114
114
|
"""
|
|
115
115
|
source: SourcesOrListOfSources = kwargs.pop("source")
|
|
116
116
|
context = get_context_from_project(kwargs["project"])
|
|
117
|
-
obj = build_entity_from_params(**kwargs)
|
|
117
|
+
obj = factory.build_entity_from_params(**kwargs)
|
|
118
118
|
if context.is_running:
|
|
119
119
|
obj.add_relationship(Relationship.PRODUCEDBY.value, context.get_run_ctx())
|
|
120
120
|
|
|
121
121
|
new_obj: MaterialEntity = self._create_context_entity(context, obj.ENTITY_TYPE, obj.to_dict())
|
|
122
|
-
new_obj = build_entity_from_dict(new_obj)
|
|
122
|
+
new_obj = factory.build_entity_from_dict(new_obj)
|
|
123
123
|
new_obj.upload(source)
|
|
124
124
|
return new_obj
|
|
125
125
|
|
|
@@ -226,7 +226,7 @@ class ContextEntityOperationsProcessor:
|
|
|
226
226
|
entity_id=entity_id,
|
|
227
227
|
**kwargs,
|
|
228
228
|
)
|
|
229
|
-
entity = build_entity_from_dict(obj)
|
|
229
|
+
entity = factory.build_entity_from_dict(obj)
|
|
230
230
|
return self._post_process_get(entity)
|
|
231
231
|
|
|
232
232
|
def read_unversioned_entity(
|
|
@@ -292,7 +292,7 @@ class ContextEntityOperationsProcessor:
|
|
|
292
292
|
dict_obj: dict = read_yaml(file)
|
|
293
293
|
dict_obj["status"] = {}
|
|
294
294
|
context = get_context_from_project(dict_obj["project"])
|
|
295
|
-
obj = build_entity_from_dict(dict_obj)
|
|
295
|
+
obj = factory.build_entity_from_dict(dict_obj)
|
|
296
296
|
try:
|
|
297
297
|
self._create_context_entity(context, obj.ENTITY_TYPE, obj.to_dict())
|
|
298
298
|
except EntityAlreadyExistsError:
|
|
@@ -329,7 +329,7 @@ class ContextEntityOperationsProcessor:
|
|
|
329
329
|
tsk_dicts = []
|
|
330
330
|
|
|
331
331
|
context = get_context_from_project(exec_dict["project"])
|
|
332
|
-
obj: ExecutableEntity = build_entity_from_dict(exec_dict)
|
|
332
|
+
obj: ExecutableEntity = factory.build_entity_from_dict(exec_dict)
|
|
333
333
|
try:
|
|
334
334
|
self._create_context_entity(context, obj.ENTITY_TYPE, obj.to_dict())
|
|
335
335
|
except EntityAlreadyExistsError:
|
|
@@ -358,7 +358,7 @@ class ContextEntityOperationsProcessor:
|
|
|
358
358
|
"""
|
|
359
359
|
dict_obj: dict = read_yaml(file)
|
|
360
360
|
context = get_context_from_project(dict_obj["project"])
|
|
361
|
-
obj: ContextEntity = build_entity_from_dict(dict_obj)
|
|
361
|
+
obj: ContextEntity = factory.build_entity_from_dict(dict_obj)
|
|
362
362
|
try:
|
|
363
363
|
self._update_context_entity(context, obj.ENTITY_TYPE, obj.id, obj.to_dict())
|
|
364
364
|
except EntityNotExistsError:
|
|
@@ -391,7 +391,7 @@ class ContextEntityOperationsProcessor:
|
|
|
391
391
|
tsk_dicts = []
|
|
392
392
|
|
|
393
393
|
context = get_context_from_project(exec_dict["project"])
|
|
394
|
-
obj: ExecutableEntity = build_entity_from_dict(exec_dict)
|
|
394
|
+
obj: ExecutableEntity = factory.build_entity_from_dict(exec_dict)
|
|
395
395
|
|
|
396
396
|
try:
|
|
397
397
|
self._update_context_entity(context, obj.ENTITY_TYPE, obj.id, obj.to_dict())
|
|
@@ -486,7 +486,7 @@ class ContextEntityOperationsProcessor:
|
|
|
486
486
|
)
|
|
487
487
|
objects = []
|
|
488
488
|
for o in objs:
|
|
489
|
-
entity: ContextEntity = build_entity_from_dict(o)
|
|
489
|
+
entity: ContextEntity = factory.build_entity_from_dict(o)
|
|
490
490
|
entity = self._post_process_get(entity)
|
|
491
491
|
objects.append(entity)
|
|
492
492
|
return objects
|
|
@@ -549,7 +549,7 @@ class ContextEntityOperationsProcessor:
|
|
|
549
549
|
objs = self._list_context_entities(context, entity_type, **kwargs)
|
|
550
550
|
objects = []
|
|
551
551
|
for o in objs:
|
|
552
|
-
entity: ContextEntity = build_entity_from_dict(o)
|
|
552
|
+
entity: ContextEntity = factory.build_entity_from_dict(o)
|
|
553
553
|
entity = self._post_process_get(entity)
|
|
554
554
|
objects.append(entity)
|
|
555
555
|
return objects
|
|
@@ -629,7 +629,7 @@ class ContextEntityOperationsProcessor:
|
|
|
629
629
|
entity_dict,
|
|
630
630
|
**kwargs,
|
|
631
631
|
)
|
|
632
|
-
return build_entity_from_dict(obj)
|
|
632
|
+
return factory.build_entity_from_dict(obj)
|
|
633
633
|
|
|
634
634
|
def _delete_context_entity(
|
|
635
635
|
self,
|
|
@@ -5,7 +5,7 @@ import typing
|
|
|
5
5
|
from digitalhub.context.api import get_context
|
|
6
6
|
from digitalhub.entities._commons.enums import ApiCategories, BackendOperations, EntityTypes
|
|
7
7
|
from digitalhub.entities._commons.utils import get_project_from_key, parse_entity_key
|
|
8
|
-
from digitalhub.factory.
|
|
8
|
+
from digitalhub.factory.factory import factory
|
|
9
9
|
from digitalhub.stores.client.api import get_client
|
|
10
10
|
from digitalhub.utils.exceptions import ContextError, EntityError, EntityNotExistsError
|
|
11
11
|
|
|
@@ -118,7 +118,7 @@ def get_context_from_remote(
|
|
|
118
118
|
try:
|
|
119
119
|
client = get_client()
|
|
120
120
|
obj = _read_base_entity(client, EntityTypes.PROJECT.value, project)
|
|
121
|
-
build_entity_from_dict(obj)
|
|
121
|
+
factory.build_entity_from_dict(obj)
|
|
122
122
|
return get_context(project)
|
|
123
123
|
except EntityNotExistsError:
|
|
124
124
|
raise ContextError(f"Project '{project}' not found.")
|
digitalhub/entities/builders.py
CHANGED
|
@@ -6,6 +6,7 @@ from digitalhub.entities.dataitem.table.builder import DataitemTableBuilder
|
|
|
6
6
|
from digitalhub.entities.model.mlflow.builder import ModelModelBuilder
|
|
7
7
|
from digitalhub.entities.project._base.builder import ProjectProjectBuilder
|
|
8
8
|
from digitalhub.entities.secret._base.builder import SecretSecretBuilder
|
|
9
|
+
from digitalhub.entities.trigger.scheduler.builder import TriggerSchedulerBuilder
|
|
9
10
|
|
|
10
11
|
entity_builders: tuple = (
|
|
11
12
|
(ProjectProjectBuilder.ENTITY_KIND, ProjectProjectBuilder),
|
|
@@ -14,6 +15,7 @@ entity_builders: tuple = (
|
|
|
14
15
|
(DataitemDataitemBuilder.ENTITY_KIND, DataitemDataitemBuilder),
|
|
15
16
|
(DataitemTableBuilder.ENTITY_KIND, DataitemTableBuilder),
|
|
16
17
|
(ModelModelBuilder.ENTITY_KIND, ModelModelBuilder),
|
|
18
|
+
(TriggerSchedulerBuilder.ENTITY_KIND, TriggerSchedulerBuilder),
|
|
17
19
|
)
|
|
18
20
|
|
|
19
21
|
##############################
|