digitalhub 0.13.3__py3-none-any.whl → 0.14.0__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 +3 -8
- digitalhub/context/api.py +1 -5
- digitalhub/context/builder.py +1 -5
- digitalhub/context/context.py +15 -9
- digitalhub/entities/_base/_base/entity.py +0 -15
- digitalhub/entities/_base/context/entity.py +1 -1
- digitalhub/entities/_base/entity/builder.py +5 -5
- digitalhub/entities/_base/entity/entity.py +0 -8
- digitalhub/entities/_base/executable/entity.py +169 -79
- digitalhub/entities/_base/material/entity.py +6 -22
- digitalhub/entities/_base/material/utils.py +1 -4
- digitalhub/entities/_base/runtime_entity/builder.py +53 -18
- digitalhub/entities/_base/unversioned/entity.py +1 -1
- digitalhub/entities/_base/versioned/entity.py +1 -1
- digitalhub/entities/_commons/enums.py +1 -31
- digitalhub/entities/_commons/utils.py +83 -21
- digitalhub/entities/_constructors/_resources.py +151 -0
- digitalhub/entities/{_base/entity/_constructors → _constructors}/name.py +18 -0
- digitalhub/entities/_processors/base/__init__.py +3 -0
- digitalhub/entities/_processors/{base.py → base/crud.py} +14 -226
- digitalhub/entities/_processors/base/import_export.py +123 -0
- digitalhub/entities/_processors/base/processor.py +302 -0
- digitalhub/entities/_processors/base/special_ops.py +108 -0
- digitalhub/entities/_processors/context/__init__.py +3 -0
- digitalhub/entities/_processors/context/crud.py +652 -0
- digitalhub/entities/_processors/context/import_export.py +242 -0
- digitalhub/entities/_processors/context/material.py +123 -0
- digitalhub/entities/_processors/context/processor.py +400 -0
- digitalhub/entities/_processors/context/special_ops.py +476 -0
- digitalhub/entities/_processors/processors.py +12 -0
- digitalhub/entities/_processors/utils.py +12 -11
- digitalhub/entities/artifact/crud.py +58 -22
- digitalhub/entities/artifact/utils.py +3 -3
- digitalhub/entities/dataitem/crud.py +63 -20
- digitalhub/entities/dataitem/table/entity.py +24 -22
- digitalhub/entities/dataitem/utils.py +15 -15
- digitalhub/entities/function/_base/entity.py +3 -3
- digitalhub/entities/function/crud.py +55 -24
- digitalhub/entities/model/_base/entity.py +62 -20
- digitalhub/entities/model/crud.py +58 -22
- digitalhub/entities/model/utils.py +3 -3
- digitalhub/entities/project/_base/entity.py +321 -152
- digitalhub/entities/project/crud.py +15 -23
- digitalhub/entities/run/_base/builder.py +0 -4
- digitalhub/entities/run/_base/entity.py +70 -63
- digitalhub/entities/run/crud.py +79 -26
- digitalhub/entities/secret/_base/entity.py +1 -5
- digitalhub/entities/secret/crud.py +29 -26
- digitalhub/entities/task/_base/builder.py +0 -4
- digitalhub/entities/task/_base/entity.py +5 -5
- digitalhub/entities/task/_base/models.py +13 -16
- digitalhub/entities/task/crud.py +61 -29
- digitalhub/entities/trigger/_base/entity.py +1 -5
- digitalhub/entities/trigger/crud.py +64 -24
- digitalhub/entities/workflow/_base/entity.py +3 -3
- digitalhub/entities/workflow/crud.py +55 -21
- digitalhub/factory/entity.py +283 -0
- digitalhub/factory/enums.py +18 -0
- digitalhub/factory/registry.py +197 -0
- digitalhub/factory/runtime.py +44 -0
- digitalhub/factory/utils.py +3 -54
- digitalhub/runtimes/_base.py +2 -2
- digitalhub/stores/client/_base/enums.py +39 -0
- digitalhub/stores/client/_base/key_builder.py +2 -2
- digitalhub/stores/client/_base/params_builder.py +48 -0
- digitalhub/stores/client/api.py +6 -10
- digitalhub/stores/client/builder.py +4 -4
- digitalhub/stores/client/dhcore/api_builder.py +2 -1
- digitalhub/stores/client/dhcore/client.py +85 -429
- digitalhub/stores/client/dhcore/configurator.py +109 -328
- digitalhub/stores/client/dhcore/enums.py +0 -16
- digitalhub/stores/client/dhcore/error_parser.py +0 -4
- digitalhub/stores/client/dhcore/header_manager.py +61 -0
- digitalhub/stores/client/dhcore/http_handler.py +133 -0
- digitalhub/stores/client/dhcore/params_builder.py +147 -134
- digitalhub/stores/client/dhcore/response_processor.py +102 -0
- digitalhub/stores/client/dhcore/utils.py +6 -72
- digitalhub/stores/client/local/api_builder.py +1 -1
- digitalhub/stores/client/local/client.py +79 -47
- digitalhub/stores/client/local/params_builder.py +18 -41
- digitalhub/stores/credentials/api.py +0 -4
- digitalhub/stores/credentials/configurator.py +2 -28
- digitalhub/stores/credentials/enums.py +3 -0
- digitalhub/stores/credentials/handler.py +0 -12
- digitalhub/stores/credentials/ini_module.py +0 -22
- digitalhub/stores/credentials/store.py +0 -4
- digitalhub/stores/data/_base/store.py +0 -16
- digitalhub/stores/data/builder.py +1 -5
- digitalhub/stores/data/local/store.py +0 -103
- digitalhub/stores/data/remote/store.py +0 -4
- digitalhub/stores/data/s3/configurator.py +60 -14
- digitalhub/stores/data/s3/store.py +49 -16
- digitalhub/stores/data/sql/configurator.py +0 -8
- digitalhub/stores/data/sql/store.py +21 -10
- digitalhub/stores/readers/data/factory.py +0 -8
- digitalhub/stores/readers/data/pandas/reader.py +0 -16
- digitalhub/utils/file_utils.py +0 -17
- digitalhub/utils/generic_utils.py +0 -12
- digitalhub/utils/git_utils.py +0 -8
- digitalhub/utils/io_utils.py +0 -12
- digitalhub/utils/store_utils.py +44 -0
- {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/METADATA +3 -2
- {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/RECORD +111 -95
- digitalhub/entities/_processors/context.py +0 -1450
- digitalhub/entities/task/_base/utils.py +0 -22
- digitalhub/factory/factory.py +0 -381
- digitalhub/stores/client/dhcore/models.py +0 -40
- digitalhub/stores/data/s3/utils.py +0 -78
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/__init__.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/metadata.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/spec.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/status.py +0 -0
- /digitalhub/entities/{_base/entity/_constructors → _constructors}/uuid.py +0 -0
- {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/WHEEL +0 -0
- {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.13.3.dist-info → digitalhub-0.14.0.dist-info}/licenses/LICENSE +0 -0
digitalhub/__init__.py
CHANGED
|
@@ -95,16 +95,11 @@ from digitalhub.entities.workflow.crud import (
|
|
|
95
95
|
new_workflow,
|
|
96
96
|
update_workflow,
|
|
97
97
|
)
|
|
98
|
+
from digitalhub.stores.client.dhcore.utils import refresh_token
|
|
99
|
+
from digitalhub.stores.credentials.api import get_current_profile, set_current_profile
|
|
100
|
+
from digitalhub.utils.store_utils import get_s3_client, get_sql_engine
|
|
98
101
|
|
|
99
102
|
try:
|
|
100
103
|
from digitalhub.entities.model.mlflow.utils import from_mlflow_run, get_mlflow_model_metrics
|
|
101
104
|
except ImportError:
|
|
102
105
|
...
|
|
103
|
-
|
|
104
|
-
# Register entities into registry
|
|
105
|
-
from digitalhub.factory.utils import register_entities, register_runtimes_entities
|
|
106
|
-
from digitalhub.stores.client.dhcore.utils import refresh_token, set_dhcore_env
|
|
107
|
-
from digitalhub.stores.credentials.api import get_current_profile, set_current_profile
|
|
108
|
-
|
|
109
|
-
register_entities()
|
|
110
|
-
register_runtimes_entities()
|
digitalhub/context/api.py
CHANGED
|
@@ -24,7 +24,7 @@ def build_context(project: Project, overwrite: bool = False) -> Context:
|
|
|
24
24
|
----------
|
|
25
25
|
project : Project
|
|
26
26
|
The project object used to build the context.
|
|
27
|
-
overwrite : bool
|
|
27
|
+
overwrite : bool
|
|
28
28
|
If True, overwrites existing context if it exists. Default is False.
|
|
29
29
|
|
|
30
30
|
Returns
|
|
@@ -60,9 +60,5 @@ def delete_context(project: str) -> None:
|
|
|
60
60
|
----------
|
|
61
61
|
project : str
|
|
62
62
|
Project name.
|
|
63
|
-
|
|
64
|
-
Returns
|
|
65
|
-
-------
|
|
66
|
-
None
|
|
67
63
|
"""
|
|
68
64
|
context_builder.remove(project)
|
digitalhub/context/builder.py
CHANGED
|
@@ -38,7 +38,7 @@ class ContextBuilder:
|
|
|
38
38
|
----------
|
|
39
39
|
project : Project
|
|
40
40
|
The project instance to create a context for.
|
|
41
|
-
overwrite : bool
|
|
41
|
+
overwrite : bool
|
|
42
42
|
If True, overwrites existing context if project name already exists. Default is False.
|
|
43
43
|
|
|
44
44
|
Returns
|
|
@@ -82,10 +82,6 @@ class ContextBuilder:
|
|
|
82
82
|
----------
|
|
83
83
|
project : str
|
|
84
84
|
The name of the project whose context should be removed.
|
|
85
|
-
|
|
86
|
-
Returns
|
|
87
|
-
-------
|
|
88
|
-
None
|
|
89
85
|
This method does not return anything.
|
|
90
86
|
|
|
91
87
|
Notes
|
digitalhub/context/context.py
CHANGED
|
@@ -8,7 +8,10 @@ import os
|
|
|
8
8
|
import typing
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
|
|
11
|
+
from digitalhub.entities._commons.enums import EntityTypes
|
|
11
12
|
from digitalhub.runtimes.enums import RuntimeEnvVar
|
|
13
|
+
from digitalhub.stores.client._base.enums import ApiCategories, BackendOperations
|
|
14
|
+
from digitalhub.utils.exceptions import BackendError
|
|
12
15
|
|
|
13
16
|
if typing.TYPE_CHECKING:
|
|
14
17
|
from digitalhub.entities.project._base.entity import Project
|
|
@@ -58,7 +61,18 @@ class Context:
|
|
|
58
61
|
"""
|
|
59
62
|
run_id = os.getenv(RuntimeEnvVar.RUN_ID.value)
|
|
60
63
|
if run_id is not None:
|
|
61
|
-
|
|
64
|
+
try:
|
|
65
|
+
api = self.client.build_api(
|
|
66
|
+
category=ApiCategories.CONTEXT.value,
|
|
67
|
+
operation=BackendOperations.READ.value,
|
|
68
|
+
project=self.name,
|
|
69
|
+
entity_type=EntityTypes.RUN.value,
|
|
70
|
+
entity_id=run_id,
|
|
71
|
+
)
|
|
72
|
+
run_key = self.client.read_object(api=api)["key"]
|
|
73
|
+
self.set_run(run_key)
|
|
74
|
+
except BackendError:
|
|
75
|
+
pass
|
|
62
76
|
|
|
63
77
|
def set_run(self, run_ctx: str) -> None:
|
|
64
78
|
"""
|
|
@@ -68,10 +82,6 @@ class Context:
|
|
|
68
82
|
----------
|
|
69
83
|
run_ctx : str
|
|
70
84
|
The run key to set.
|
|
71
|
-
|
|
72
|
-
Returns
|
|
73
|
-
-------
|
|
74
|
-
None
|
|
75
85
|
"""
|
|
76
86
|
self.is_running = True
|
|
77
87
|
self._run_ctx = run_ctx
|
|
@@ -79,10 +89,6 @@ class Context:
|
|
|
79
89
|
def unset_run(self) -> None:
|
|
80
90
|
"""
|
|
81
91
|
Clear the current run key and reset running state.
|
|
82
|
-
|
|
83
|
-
Returns
|
|
84
|
-
-------
|
|
85
|
-
None
|
|
86
92
|
"""
|
|
87
93
|
self.is_running = False
|
|
88
94
|
self._run_ctx = None
|
|
@@ -54,26 +54,11 @@ class Base:
|
|
|
54
54
|
----------
|
|
55
55
|
**kwargs : dict
|
|
56
56
|
Keyword arguments to be set as attributes.
|
|
57
|
-
|
|
58
|
-
Returns
|
|
59
|
-
-------
|
|
60
|
-
None
|
|
61
57
|
"""
|
|
62
58
|
for k, v in kwargs.items():
|
|
63
59
|
if k not in self.__dict__:
|
|
64
60
|
setattr(self, k, v)
|
|
65
61
|
|
|
66
|
-
def _get_private_attrs(self) -> dict:
|
|
67
|
-
"""
|
|
68
|
-
Return all private attributes of the object.
|
|
69
|
-
|
|
70
|
-
Returns
|
|
71
|
-
-------
|
|
72
|
-
dict
|
|
73
|
-
A dictionary containing the private attributes of the entity instance.
|
|
74
|
-
"""
|
|
75
|
-
return {k: v for k, v in self.__dict__.items() if k.startswith("_")}
|
|
76
|
-
|
|
77
62
|
def __repr__(self) -> str:
|
|
78
63
|
"""
|
|
79
64
|
Return string representation of the entity object.
|
|
@@ -8,7 +8,7 @@ import typing
|
|
|
8
8
|
|
|
9
9
|
from digitalhub.context.api import get_context
|
|
10
10
|
from digitalhub.entities._base.entity.entity import Entity
|
|
11
|
-
from digitalhub.entities._processors.
|
|
11
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
12
12
|
from digitalhub.utils.generic_utils import get_timestamp
|
|
13
13
|
from digitalhub.utils.io_utils import write_yaml
|
|
14
14
|
|
|
@@ -7,11 +7,11 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
from abc import abstractmethod
|
|
9
9
|
|
|
10
|
-
from digitalhub.entities.
|
|
11
|
-
from digitalhub.entities.
|
|
12
|
-
from digitalhub.entities.
|
|
13
|
-
from digitalhub.entities.
|
|
14
|
-
from digitalhub.entities.
|
|
10
|
+
from digitalhub.entities._constructors.metadata import build_metadata
|
|
11
|
+
from digitalhub.entities._constructors.name import build_name
|
|
12
|
+
from digitalhub.entities._constructors.spec import build_spec
|
|
13
|
+
from digitalhub.entities._constructors.status import build_status
|
|
14
|
+
from digitalhub.entities._constructors.uuid import build_uuid
|
|
15
15
|
from digitalhub.utils.exceptions import BuilderError
|
|
16
16
|
|
|
17
17
|
if typing.TYPE_CHECKING:
|
|
@@ -67,10 +67,6 @@ class Entity(Base):
|
|
|
67
67
|
----------
|
|
68
68
|
obj : dict
|
|
69
69
|
Mapping representation of object.
|
|
70
|
-
|
|
71
|
-
Returns
|
|
72
|
-
-------
|
|
73
|
-
None
|
|
74
70
|
"""
|
|
75
71
|
self.metadata = obj.metadata
|
|
76
72
|
self.spec = obj.spec
|
|
@@ -95,10 +91,6 @@ class Entity(Base):
|
|
|
95
91
|
The target entity.
|
|
96
92
|
source : str
|
|
97
93
|
The source entity.
|
|
98
|
-
|
|
99
|
-
Returns
|
|
100
|
-
-------
|
|
101
|
-
None
|
|
102
94
|
"""
|
|
103
95
|
if self.metadata.relationships is None:
|
|
104
96
|
self.metadata.relationships = []
|
|
@@ -9,11 +9,11 @@ from abc import abstractmethod
|
|
|
9
9
|
|
|
10
10
|
from digitalhub.entities._base.versioned.entity import VersionedEntity
|
|
11
11
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
12
|
-
from digitalhub.entities._processors.
|
|
12
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
13
13
|
from digitalhub.entities.run.crud import list_runs
|
|
14
14
|
from digitalhub.entities.task.crud import delete_task, list_tasks
|
|
15
15
|
from digitalhub.entities.trigger.crud import list_triggers
|
|
16
|
-
from digitalhub.factory.
|
|
16
|
+
from digitalhub.factory.entity import entity_factory
|
|
17
17
|
from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityError
|
|
18
18
|
|
|
19
19
|
if typing.TYPE_CHECKING:
|
|
@@ -94,10 +94,6 @@ class ExecutableEntity(VersionedEntity):
|
|
|
94
94
|
----------
|
|
95
95
|
tasks : list[dict]
|
|
96
96
|
List of tasks to import.
|
|
97
|
-
|
|
98
|
-
Returns
|
|
99
|
-
-------
|
|
100
|
-
None
|
|
101
97
|
"""
|
|
102
98
|
# Loop over tasks list, in the case where the function
|
|
103
99
|
# is imported from local file.
|
|
@@ -109,7 +105,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
109
105
|
# Create a new object from dictionary.
|
|
110
106
|
# the form in which tasks are stored in function
|
|
111
107
|
# status
|
|
112
|
-
task_obj: Task =
|
|
108
|
+
task_obj: Task = entity_factory.build_entity_from_dict(task)
|
|
113
109
|
|
|
114
110
|
# Try to save it in backend to been able to use
|
|
115
111
|
# it for launching runs. In fact, tasks must be
|
|
@@ -149,7 +145,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
149
145
|
kwargs["kind"] = kind
|
|
150
146
|
|
|
151
147
|
# Create object instance
|
|
152
|
-
task: Task =
|
|
148
|
+
task: Task = entity_factory.build_entity_from_params(**kwargs)
|
|
153
149
|
task.save()
|
|
154
150
|
|
|
155
151
|
self._tasks[kind] = task
|
|
@@ -183,21 +179,62 @@ class ExecutableEntity(VersionedEntity):
|
|
|
183
179
|
self._tasks[kind] = resp[0]
|
|
184
180
|
return self._tasks[kind]
|
|
185
181
|
|
|
186
|
-
def list_task(
|
|
182
|
+
def list_task(
|
|
183
|
+
self,
|
|
184
|
+
q: str | None = None,
|
|
185
|
+
name: str | None = None,
|
|
186
|
+
kind: str | None = None,
|
|
187
|
+
user: str | None = None,
|
|
188
|
+
state: str | None = None,
|
|
189
|
+
created: str | None = None,
|
|
190
|
+
updated: str | None = None,
|
|
191
|
+
) -> list[Task]:
|
|
187
192
|
"""
|
|
188
|
-
List tasks.
|
|
193
|
+
List tasks of the executable entity from backend.
|
|
189
194
|
|
|
190
195
|
Parameters
|
|
191
196
|
----------
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
q : str
|
|
198
|
+
Query string to filter objects.
|
|
199
|
+
name : str
|
|
200
|
+
Object name.
|
|
201
|
+
kind : str
|
|
202
|
+
Kind of the object.
|
|
203
|
+
user : str
|
|
204
|
+
User that created the object.
|
|
205
|
+
state : str
|
|
206
|
+
Object state.
|
|
207
|
+
created : str
|
|
208
|
+
Creation date filter.
|
|
209
|
+
updated : str
|
|
210
|
+
Update date filter.
|
|
194
211
|
|
|
195
212
|
Returns
|
|
196
213
|
-------
|
|
197
|
-
list
|
|
198
|
-
List of
|
|
214
|
+
list[Task]
|
|
215
|
+
List of object instances.
|
|
216
|
+
"""
|
|
217
|
+
return self._list_tasks(
|
|
218
|
+
self.project,
|
|
219
|
+
q=q,
|
|
220
|
+
name=name,
|
|
221
|
+
kind=kind,
|
|
222
|
+
user=user,
|
|
223
|
+
state=state,
|
|
224
|
+
created=created,
|
|
225
|
+
updated=updated,
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
def _list_tasks(self, **kwargs) -> list[Task]:
|
|
199
229
|
"""
|
|
200
|
-
|
|
230
|
+
List all tasks of the executable entity from backend.
|
|
231
|
+
|
|
232
|
+
Returns
|
|
233
|
+
-------
|
|
234
|
+
list[Task]
|
|
235
|
+
List of object instances.
|
|
236
|
+
"""
|
|
237
|
+
kwargs[self.ENTITY_TYPE] = self._get_executable_string()
|
|
201
238
|
return list_tasks(self.project, **kwargs)
|
|
202
239
|
|
|
203
240
|
def update_task(self, kind: str, **kwargs) -> Task:
|
|
@@ -225,7 +262,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
225
262
|
kwargs["uuid"] = self._tasks[kind].id
|
|
226
263
|
|
|
227
264
|
# Update task
|
|
228
|
-
task: Task =
|
|
265
|
+
task: Task = entity_factory.build_entity_from_params(**kwargs)
|
|
229
266
|
task.save(update=True)
|
|
230
267
|
self._tasks[kind] = task
|
|
231
268
|
return task
|
|
@@ -265,7 +302,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
265
302
|
Response from backend.
|
|
266
303
|
"""
|
|
267
304
|
params = {self.ENTITY_TYPE: self._get_executable_string(), "kind": kind}
|
|
268
|
-
return context_processor.list_context_entities(self.project, EntityTypes.TASK.value, params
|
|
305
|
+
return context_processor.list_context_entities(self.project, EntityTypes.TASK.value, **params)
|
|
269
306
|
|
|
270
307
|
def _check_task_in_backend(self, kind: str) -> bool:
|
|
271
308
|
"""
|
|
@@ -295,10 +332,6 @@ class ExecutableEntity(VersionedEntity):
|
|
|
295
332
|
kind : str
|
|
296
333
|
Kind the object.
|
|
297
334
|
|
|
298
|
-
Returns
|
|
299
|
-
-------
|
|
300
|
-
None
|
|
301
|
-
|
|
302
335
|
Raises
|
|
303
336
|
------
|
|
304
337
|
EntityError
|
|
@@ -316,10 +349,6 @@ class ExecutableEntity(VersionedEntity):
|
|
|
316
349
|
kind : str
|
|
317
350
|
Kind the object.
|
|
318
351
|
|
|
319
|
-
Returns
|
|
320
|
-
-------
|
|
321
|
-
None
|
|
322
|
-
|
|
323
352
|
Raises
|
|
324
353
|
------
|
|
325
354
|
EntityError
|
|
@@ -338,35 +367,21 @@ class ExecutableEntity(VersionedEntity):
|
|
|
338
367
|
Create and execute a new run.
|
|
339
368
|
"""
|
|
340
369
|
|
|
341
|
-
def get_run(
|
|
342
|
-
self,
|
|
343
|
-
identifier: str,
|
|
344
|
-
**kwargs,
|
|
345
|
-
) -> Run:
|
|
370
|
+
def get_run(self, identifier: str) -> Run:
|
|
346
371
|
"""
|
|
347
|
-
Get object from backend.
|
|
372
|
+
Get specific run object of the executable from backend.
|
|
348
373
|
|
|
349
374
|
Parameters
|
|
350
375
|
----------
|
|
351
376
|
identifier : str
|
|
352
377
|
Entity key (store://...) or entity ID.
|
|
353
|
-
**kwargs : dict
|
|
354
|
-
Parameters to pass to the API call.
|
|
355
378
|
|
|
356
379
|
Returns
|
|
357
380
|
-------
|
|
358
381
|
Run
|
|
359
382
|
Object instance.
|
|
360
|
-
|
|
361
|
-
Examples
|
|
362
|
-
--------
|
|
363
|
-
Using entity key:
|
|
364
|
-
>>> obj = executable.get_run("store://my-secret-key")
|
|
365
|
-
|
|
366
|
-
Using entity ID:
|
|
367
|
-
>>> obj = executable.get_run("123")
|
|
368
383
|
"""
|
|
369
|
-
entities = self.
|
|
384
|
+
entities = self._list_runs()
|
|
370
385
|
for entity in entities:
|
|
371
386
|
if getattr(entity.spec, self.ENTITY_TYPE) == self._get_executable_string():
|
|
372
387
|
if entity.id == identifier:
|
|
@@ -375,25 +390,69 @@ class ExecutableEntity(VersionedEntity):
|
|
|
375
390
|
return entity
|
|
376
391
|
raise EntityError(f"Run '{identifier}' does not exist or does not belong to this executable.")
|
|
377
392
|
|
|
378
|
-
def list_runs(
|
|
393
|
+
def list_runs(
|
|
394
|
+
self,
|
|
395
|
+
q: str | None = None,
|
|
396
|
+
name: str | None = None,
|
|
397
|
+
kind: str | None = None,
|
|
398
|
+
user: str | None = None,
|
|
399
|
+
state: str | None = None,
|
|
400
|
+
created: str | None = None,
|
|
401
|
+
updated: str | None = None,
|
|
402
|
+
task: str | None = None,
|
|
403
|
+
action: str | None = None,
|
|
404
|
+
) -> list[Run]:
|
|
379
405
|
"""
|
|
380
|
-
List
|
|
406
|
+
List runs of the executable entity from backend.
|
|
381
407
|
|
|
382
408
|
Parameters
|
|
383
409
|
----------
|
|
384
|
-
|
|
385
|
-
|
|
410
|
+
q : str
|
|
411
|
+
Query string to filter objects.
|
|
412
|
+
name : str
|
|
413
|
+
Object name.
|
|
414
|
+
kind : str
|
|
415
|
+
Kind of the object.
|
|
416
|
+
user : str
|
|
417
|
+
User that created the object.
|
|
418
|
+
state : str
|
|
419
|
+
Object state.
|
|
420
|
+
created : str
|
|
421
|
+
Creation date filter.
|
|
422
|
+
updated : str
|
|
423
|
+
Update date filter.
|
|
424
|
+
task : str
|
|
425
|
+
Task string filter.
|
|
426
|
+
action : str
|
|
427
|
+
Action name filter.
|
|
386
428
|
|
|
387
429
|
Returns
|
|
388
430
|
-------
|
|
389
431
|
list[Run]
|
|
390
432
|
List of object instances.
|
|
433
|
+
"""
|
|
434
|
+
return self._list_runs(
|
|
435
|
+
q=q,
|
|
436
|
+
name=name,
|
|
437
|
+
kind=kind,
|
|
438
|
+
user=user,
|
|
439
|
+
state=state,
|
|
440
|
+
created=created,
|
|
441
|
+
updated=updated,
|
|
442
|
+
task=task,
|
|
443
|
+
action=action,
|
|
444
|
+
)
|
|
391
445
|
|
|
392
|
-
|
|
393
|
-
--------
|
|
394
|
-
>>> objs = executable.list_runs()
|
|
446
|
+
def _list_runs(self, **kwargs) -> list[Run]:
|
|
395
447
|
"""
|
|
396
|
-
|
|
448
|
+
List all runs of the executable entity from backend.
|
|
449
|
+
|
|
450
|
+
Returns
|
|
451
|
+
-------
|
|
452
|
+
list[Run]
|
|
453
|
+
List of object instances.
|
|
454
|
+
"""
|
|
455
|
+
kwargs[self.ENTITY_TYPE] = self._get_executable_string()
|
|
397
456
|
return list_runs(self.project, **kwargs)
|
|
398
457
|
|
|
399
458
|
##############################
|
|
@@ -421,17 +480,17 @@ class ExecutableEntity(VersionedEntity):
|
|
|
421
480
|
|
|
422
481
|
Returns
|
|
423
482
|
-------
|
|
424
|
-
|
|
425
|
-
|
|
483
|
+
Trigger
|
|
484
|
+
Object instance.
|
|
426
485
|
"""
|
|
427
486
|
# Get task
|
|
428
|
-
task_kind =
|
|
487
|
+
task_kind = entity_factory.get_task_kind_from_action(self.kind, action)
|
|
429
488
|
task = self._get_or_create_task(task_kind)
|
|
430
489
|
task_string = task._get_task_string()
|
|
431
490
|
|
|
432
491
|
# Get run validator for building trigger template
|
|
433
|
-
run_kind =
|
|
434
|
-
run_validator: SpecValidator =
|
|
492
|
+
run_kind = entity_factory.get_run_kind_from_action(self.kind, action)
|
|
493
|
+
run_validator: SpecValidator = entity_factory.get_spec_validator(run_kind)
|
|
435
494
|
# Override kwargs
|
|
436
495
|
kwargs["project"] = self.project
|
|
437
496
|
kwargs["kind"] = trigger_kind
|
|
@@ -441,15 +500,11 @@ class ExecutableEntity(VersionedEntity):
|
|
|
441
500
|
kwargs["template"] = run_validator(**kwargs).to_dict()
|
|
442
501
|
|
|
443
502
|
# Create object instance
|
|
444
|
-
trigger: Trigger =
|
|
503
|
+
trigger: Trigger = entity_factory.build_entity_from_params(**kwargs)
|
|
445
504
|
trigger.save()
|
|
446
505
|
return trigger
|
|
447
506
|
|
|
448
|
-
def get_trigger(
|
|
449
|
-
self,
|
|
450
|
-
identifier: str,
|
|
451
|
-
**kwargs,
|
|
452
|
-
) -> Trigger:
|
|
507
|
+
def get_trigger(self, identifier: str) -> Trigger:
|
|
453
508
|
"""
|
|
454
509
|
Get object from backend.
|
|
455
510
|
|
|
@@ -457,23 +512,13 @@ class ExecutableEntity(VersionedEntity):
|
|
|
457
512
|
----------
|
|
458
513
|
identifier : str
|
|
459
514
|
Entity key (store://...) or entity ID.
|
|
460
|
-
**kwargs : dict
|
|
461
|
-
Parameters to pass to the API call.
|
|
462
515
|
|
|
463
516
|
Returns
|
|
464
517
|
-------
|
|
465
518
|
Trigger
|
|
466
519
|
Object instance.
|
|
467
|
-
|
|
468
|
-
Examples
|
|
469
|
-
--------
|
|
470
|
-
Using entity key:
|
|
471
|
-
>>> obj = executable.get_trigger("store://my-trigger-key")
|
|
472
|
-
|
|
473
|
-
Using entity ID:
|
|
474
|
-
>>> obj = executable.get_trigger("123")
|
|
475
520
|
"""
|
|
476
|
-
entities = self.
|
|
521
|
+
entities = self._list_triggers()
|
|
477
522
|
for entity in entities:
|
|
478
523
|
if getattr(entity.spec, self.ENTITY_TYPE) == self._get_executable_string():
|
|
479
524
|
if entity.id == identifier:
|
|
@@ -482,9 +527,58 @@ class ExecutableEntity(VersionedEntity):
|
|
|
482
527
|
return entity
|
|
483
528
|
raise EntityError(f"Trigger '{identifier}' does not exist or does not belong to this executable.")
|
|
484
529
|
|
|
485
|
-
def list_triggers(
|
|
530
|
+
def list_triggers(
|
|
531
|
+
self,
|
|
532
|
+
q: str | None = None,
|
|
533
|
+
name: str | None = None,
|
|
534
|
+
kind: str | None = None,
|
|
535
|
+
user: str | None = None,
|
|
536
|
+
created: str | None = None,
|
|
537
|
+
updated: str | None = None,
|
|
538
|
+
version: str | None = None,
|
|
539
|
+
task: str | None = None,
|
|
540
|
+
) -> list[Trigger]:
|
|
486
541
|
"""
|
|
487
|
-
List
|
|
542
|
+
List triggers of the executable entity from backend.
|
|
543
|
+
|
|
544
|
+
Parameters
|
|
545
|
+
----------
|
|
546
|
+
q : str
|
|
547
|
+
Query string to filter objects.
|
|
548
|
+
name : str
|
|
549
|
+
Object name.
|
|
550
|
+
kind : str
|
|
551
|
+
Kind of the object.
|
|
552
|
+
user : str
|
|
553
|
+
User that created the object.
|
|
554
|
+
created : str
|
|
555
|
+
Creation date filter.
|
|
556
|
+
updated : str
|
|
557
|
+
Update date filter.
|
|
558
|
+
version : str
|
|
559
|
+
Object version, default is latest.
|
|
560
|
+
task : str
|
|
561
|
+
Task string filter.
|
|
562
|
+
|
|
563
|
+
Returns
|
|
564
|
+
-------
|
|
565
|
+
list[Trigger]
|
|
566
|
+
List of object instances.
|
|
567
|
+
"""
|
|
568
|
+
return self._list_triggers(
|
|
569
|
+
q=q,
|
|
570
|
+
name=name,
|
|
571
|
+
kind=kind,
|
|
572
|
+
user=user,
|
|
573
|
+
created=created,
|
|
574
|
+
updated=updated,
|
|
575
|
+
version=version,
|
|
576
|
+
task=task,
|
|
577
|
+
)
|
|
578
|
+
|
|
579
|
+
def _list_triggers(self, **kwargs) -> list[Trigger]:
|
|
580
|
+
"""
|
|
581
|
+
List triggers of the executable from backend.
|
|
488
582
|
|
|
489
583
|
Parameters
|
|
490
584
|
----------
|
|
@@ -495,10 +589,6 @@ class ExecutableEntity(VersionedEntity):
|
|
|
495
589
|
-------
|
|
496
590
|
list[Trigger]
|
|
497
591
|
List of object instances.
|
|
498
|
-
|
|
499
|
-
Examples
|
|
500
|
-
--------
|
|
501
|
-
>>> objs = executable.list_triggers()
|
|
502
592
|
"""
|
|
503
|
-
kwargs[
|
|
593
|
+
kwargs[self.ENTITY_TYPE] = self._get_executable_string()
|
|
504
594
|
return list_triggers(self.project, **kwargs)
|
|
@@ -9,7 +9,7 @@ from pathlib import Path
|
|
|
9
9
|
|
|
10
10
|
from digitalhub.entities._base.material.utils import refresh_decorator
|
|
11
11
|
from digitalhub.entities._base.versioned.entity import VersionedEntity
|
|
12
|
-
from digitalhub.entities._processors.
|
|
12
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
13
13
|
from digitalhub.stores.data.api import get_store
|
|
14
14
|
from digitalhub.utils.types import SourcesOrListOfSources
|
|
15
15
|
|
|
@@ -146,20 +146,16 @@ class MaterialEntity(VersionedEntity):
|
|
|
146
146
|
source : str | list[str]
|
|
147
147
|
Local filepath, directory or list of filepaths.
|
|
148
148
|
|
|
149
|
-
Returns
|
|
150
|
-
-------
|
|
151
|
-
None
|
|
152
|
-
|
|
153
149
|
Examples
|
|
154
150
|
--------
|
|
155
151
|
Upload a single file:
|
|
156
152
|
|
|
157
|
-
>>> entity.spec.path =
|
|
158
|
-
>>> entity.upload(
|
|
153
|
+
>>> entity.spec.path = "s3://bucket/data.csv"
|
|
154
|
+
>>> entity.upload("./data.csv")
|
|
159
155
|
|
|
160
156
|
Upload a folder:
|
|
161
|
-
>>> entity.spec.path =
|
|
162
|
-
>>> entity.upload(
|
|
157
|
+
>>> entity.spec.path = "s3://bucket/data/"
|
|
158
|
+
>>> entity.upload("./data")
|
|
163
159
|
"""
|
|
164
160
|
# Get store and upload object
|
|
165
161
|
store = get_store(self.spec.path)
|
|
@@ -181,10 +177,6 @@ class MaterialEntity(VersionedEntity):
|
|
|
181
177
|
----------
|
|
182
178
|
files : list[dict]
|
|
183
179
|
Files to add.
|
|
184
|
-
|
|
185
|
-
Returns
|
|
186
|
-
-------
|
|
187
|
-
None
|
|
188
180
|
"""
|
|
189
181
|
available = 100 - len(self.status.files)
|
|
190
182
|
if len(files) > available:
|
|
@@ -204,7 +196,7 @@ class MaterialEntity(VersionedEntity):
|
|
|
204
196
|
list
|
|
205
197
|
Paths of the files in the status.
|
|
206
198
|
"""
|
|
207
|
-
return [f.get("path")
|
|
199
|
+
return [f.get("path") for f in self.status.files]
|
|
208
200
|
|
|
209
201
|
##############################
|
|
210
202
|
# Private Helpers
|
|
@@ -218,10 +210,6 @@ class MaterialEntity(VersionedEntity):
|
|
|
218
210
|
----------
|
|
219
211
|
files_info : list[dict] | None
|
|
220
212
|
Files info.
|
|
221
|
-
|
|
222
|
-
Returns
|
|
223
|
-
-------
|
|
224
|
-
None
|
|
225
213
|
"""
|
|
226
214
|
if files_info is None:
|
|
227
215
|
return
|
|
@@ -233,10 +221,6 @@ class MaterialEntity(VersionedEntity):
|
|
|
233
221
|
def _get_files_info(self) -> None:
|
|
234
222
|
"""
|
|
235
223
|
Get files info from backend.
|
|
236
|
-
|
|
237
|
-
Returns
|
|
238
|
-
-------
|
|
239
|
-
None
|
|
240
224
|
"""
|
|
241
225
|
if not self._context().local and not self.status.files:
|
|
242
226
|
files = context_processor.read_files_info(
|
|
@@ -21,10 +21,6 @@ def eval_local_source(source: str | list[str]) -> None:
|
|
|
21
21
|
----------
|
|
22
22
|
source : str | list[str]
|
|
23
23
|
Source(s).
|
|
24
|
-
|
|
25
|
-
Returns
|
|
26
|
-
-------
|
|
27
|
-
None
|
|
28
24
|
"""
|
|
29
25
|
if isinstance(source, list):
|
|
30
26
|
if not source:
|
|
@@ -111,6 +107,7 @@ def build_log_path_from_source(
|
|
|
111
107
|
|
|
112
108
|
return path
|
|
113
109
|
|
|
110
|
+
|
|
114
111
|
def refresh_decorator(fn: typing.Callable) -> typing.Callable:
|
|
115
112
|
"""
|
|
116
113
|
Refresh decorator.
|