digitalhub 0.13.4__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 +2 -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.4.dist-info → digitalhub-0.14.0.dist-info}/METADATA +3 -2
- {digitalhub-0.13.4.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.4.dist-info → digitalhub-0.14.0.dist-info}/WHEEL +0 -0
- {digitalhub-0.13.4.dist-info → digitalhub-0.14.0.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.13.4.dist-info → digitalhub-0.14.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -7,7 +7,8 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
10
|
-
from digitalhub.entities.
|
|
10
|
+
from digitalhub.entities._commons.utils import is_valid_key
|
|
11
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
11
12
|
from digitalhub.utils.exceptions import EntityNotExistsError
|
|
12
13
|
|
|
13
14
|
if typing.TYPE_CHECKING:
|
|
@@ -80,7 +81,6 @@ def get_secret(
|
|
|
80
81
|
identifier: str,
|
|
81
82
|
project: str | None = None,
|
|
82
83
|
entity_id: str | None = None,
|
|
83
|
-
**kwargs,
|
|
84
84
|
) -> Secret:
|
|
85
85
|
"""
|
|
86
86
|
Get object from backend.
|
|
@@ -93,8 +93,6 @@ def get_secret(
|
|
|
93
93
|
Project name.
|
|
94
94
|
entity_id : str
|
|
95
95
|
Entity ID.
|
|
96
|
-
**kwargs : dict
|
|
97
|
-
Parameters to pass to the API call.
|
|
98
96
|
|
|
99
97
|
Returns
|
|
100
98
|
-------
|
|
@@ -111,28 +109,26 @@ def get_secret(
|
|
|
111
109
|
>>> project="my-project",
|
|
112
110
|
>>> entity_id="my-secret-id")
|
|
113
111
|
"""
|
|
114
|
-
if not identifier
|
|
112
|
+
if not is_valid_key(identifier):
|
|
115
113
|
if project is None:
|
|
116
114
|
raise ValueError("Project must be provided.")
|
|
117
|
-
secrets = list_secrets(project=project
|
|
115
|
+
secrets = list_secrets(project=project)
|
|
118
116
|
for secret in secrets:
|
|
119
117
|
if secret.name == identifier:
|
|
120
118
|
return secret
|
|
121
119
|
else:
|
|
122
120
|
raise EntityNotExistsError(f"Secret {identifier} not found.")
|
|
123
121
|
return context_processor.read_context_entity(
|
|
124
|
-
identifier,
|
|
122
|
+
identifier=identifier,
|
|
125
123
|
entity_type=ENTITY_TYPE,
|
|
126
124
|
project=project,
|
|
127
125
|
entity_id=entity_id,
|
|
128
|
-
**kwargs,
|
|
129
126
|
)
|
|
130
127
|
|
|
131
128
|
|
|
132
129
|
def get_secret_versions(
|
|
133
130
|
identifier: str,
|
|
134
131
|
project: str | None = None,
|
|
135
|
-
**kwargs,
|
|
136
132
|
) -> list[Secret]:
|
|
137
133
|
"""
|
|
138
134
|
Get object versions from backend.
|
|
@@ -143,8 +139,6 @@ def get_secret_versions(
|
|
|
143
139
|
Entity key (store://...) or entity name.
|
|
144
140
|
project : str
|
|
145
141
|
Project name.
|
|
146
|
-
**kwargs : dict
|
|
147
|
-
Parameters to pass to the API call.
|
|
148
142
|
|
|
149
143
|
Returns
|
|
150
144
|
-------
|
|
@@ -161,14 +155,13 @@ def get_secret_versions(
|
|
|
161
155
|
>>> project="my-project")
|
|
162
156
|
"""
|
|
163
157
|
return context_processor.read_context_entity_versions(
|
|
164
|
-
identifier,
|
|
158
|
+
identifier=identifier,
|
|
165
159
|
entity_type=ENTITY_TYPE,
|
|
166
160
|
project=project,
|
|
167
|
-
**kwargs,
|
|
168
161
|
)
|
|
169
162
|
|
|
170
163
|
|
|
171
|
-
def list_secrets(project: str
|
|
164
|
+
def list_secrets(project: str) -> list[Secret]:
|
|
172
165
|
"""
|
|
173
166
|
List all latest version objects from backend.
|
|
174
167
|
|
|
@@ -176,8 +169,6 @@ def list_secrets(project: str, **kwargs) -> list[Secret]:
|
|
|
176
169
|
----------
|
|
177
170
|
project : str
|
|
178
171
|
Project name.
|
|
179
|
-
**kwargs : dict
|
|
180
|
-
Parameters to pass to the API call.
|
|
181
172
|
|
|
182
173
|
Returns
|
|
183
174
|
-------
|
|
@@ -191,18 +182,28 @@ def list_secrets(project: str, **kwargs) -> list[Secret]:
|
|
|
191
182
|
return context_processor.list_context_entities(
|
|
192
183
|
project=project,
|
|
193
184
|
entity_type=ENTITY_TYPE,
|
|
194
|
-
**kwargs,
|
|
195
185
|
)
|
|
196
186
|
|
|
197
187
|
|
|
198
|
-
def import_secret(
|
|
188
|
+
def import_secret(
|
|
189
|
+
file: str | None = None,
|
|
190
|
+
key: str | None = None,
|
|
191
|
+
reset_id: bool = False,
|
|
192
|
+
context: str | None = None,
|
|
193
|
+
) -> Secret:
|
|
199
194
|
"""
|
|
200
|
-
Import object from a YAML file
|
|
195
|
+
Import an object from a YAML file or from a storage key.
|
|
201
196
|
|
|
202
197
|
Parameters
|
|
203
198
|
----------
|
|
204
199
|
file : str
|
|
205
|
-
Path to YAML file.
|
|
200
|
+
Path to the YAML file.
|
|
201
|
+
key : str
|
|
202
|
+
Entity key (store://...).
|
|
203
|
+
reset_id : bool
|
|
204
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
205
|
+
context : str
|
|
206
|
+
Project name to use for context resolution.
|
|
206
207
|
|
|
207
208
|
Returns
|
|
208
209
|
-------
|
|
@@ -213,7 +214,12 @@ def import_secret(file: str) -> Secret:
|
|
|
213
214
|
--------
|
|
214
215
|
>>> obj = import_secret("my-secret.yaml")
|
|
215
216
|
"""
|
|
216
|
-
return context_processor.import_context_entity(
|
|
217
|
+
return context_processor.import_context_entity(
|
|
218
|
+
file,
|
|
219
|
+
key,
|
|
220
|
+
reset_id,
|
|
221
|
+
context,
|
|
222
|
+
)
|
|
217
223
|
|
|
218
224
|
|
|
219
225
|
def load_secret(file: str) -> Secret:
|
|
@@ -268,7 +274,6 @@ def delete_secret(
|
|
|
268
274
|
project: str | None = None,
|
|
269
275
|
entity_id: str | None = None,
|
|
270
276
|
delete_all_versions: bool = False,
|
|
271
|
-
**kwargs,
|
|
272
277
|
) -> dict:
|
|
273
278
|
"""
|
|
274
279
|
Delete object from backend.
|
|
@@ -282,9 +287,8 @@ def delete_secret(
|
|
|
282
287
|
entity_id : str
|
|
283
288
|
Entity ID.
|
|
284
289
|
delete_all_versions : bool
|
|
285
|
-
Delete all versions of the named entity.
|
|
286
|
-
|
|
287
|
-
Parameters to pass to the API call.
|
|
290
|
+
Delete all versions of the named entity.
|
|
291
|
+
If True, use entity name instead of entity key as identifier.
|
|
288
292
|
|
|
289
293
|
Returns
|
|
290
294
|
-------
|
|
@@ -307,5 +311,4 @@ def delete_secret(
|
|
|
307
311
|
project=project,
|
|
308
312
|
entity_id=entity_id,
|
|
309
313
|
delete_all_versions=delete_all_versions,
|
|
310
|
-
**kwargs,
|
|
311
314
|
)
|
|
@@ -8,8 +8,8 @@ import typing
|
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._base.unversioned.entity import UnversionedEntity
|
|
10
10
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
11
|
-
from digitalhub.entities._processors.
|
|
12
|
-
from digitalhub.factory.
|
|
11
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
12
|
+
from digitalhub.factory.entity import entity_factory
|
|
13
13
|
|
|
14
14
|
if typing.TYPE_CHECKING:
|
|
15
15
|
from digitalhub.entities._base.entity.metadata import Metadata
|
|
@@ -67,8 +67,8 @@ class Task(UnversionedEntity):
|
|
|
67
67
|
Run
|
|
68
68
|
Run object.
|
|
69
69
|
"""
|
|
70
|
-
exec_kind =
|
|
71
|
-
exec_type =
|
|
70
|
+
exec_kind = entity_factory.get_executable_kind(self.kind)
|
|
71
|
+
exec_type = entity_factory.get_entity_type_from_kind(exec_kind)
|
|
72
72
|
kwargs[exec_type] = getattr(self.spec, exec_type)
|
|
73
73
|
return self.new_run(
|
|
74
74
|
save=save,
|
|
@@ -112,7 +112,7 @@ class Task(UnversionedEntity):
|
|
|
112
112
|
"""
|
|
113
113
|
if save:
|
|
114
114
|
return context_processor.create_context_entity(**kwargs)
|
|
115
|
-
return
|
|
115
|
+
return entity_factory.build_entity_from_params(**kwargs)
|
|
116
116
|
|
|
117
117
|
def get_run(self, entity_key: str) -> Run:
|
|
118
118
|
"""
|
|
@@ -18,6 +18,7 @@ class VolumeType(Enum):
|
|
|
18
18
|
PERSISTENT_VOLUME_CLAIM = "persistent_volume_claim"
|
|
19
19
|
EMPTY_DIR = "empty_dir"
|
|
20
20
|
EPHEMERAL = "ephemeral"
|
|
21
|
+
SHARED_VOLUME = "shared_volume"
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
class SpecEmptyDir(BaseModel):
|
|
@@ -46,6 +47,14 @@ class SpecEphemeral(BaseModel):
|
|
|
46
47
|
size: Optional[str] = None
|
|
47
48
|
|
|
48
49
|
|
|
50
|
+
class SharedVolumeSpec(BaseModel):
|
|
51
|
+
"""
|
|
52
|
+
Shared volume spec model.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
size: Optional[str] = None
|
|
56
|
+
|
|
57
|
+
|
|
49
58
|
class Volume(BaseModel):
|
|
50
59
|
"""
|
|
51
60
|
Volume model.
|
|
@@ -62,7 +71,7 @@ class Volume(BaseModel):
|
|
|
62
71
|
mount_path: str
|
|
63
72
|
"""Volume mount path inside the container."""
|
|
64
73
|
|
|
65
|
-
spec: Optional[Union[SpecEmptyDir, SpecPVC, SpecEphemeral]] = None
|
|
74
|
+
spec: Optional[Union[SpecEmptyDir, SpecPVC, SpecEphemeral, SharedVolumeSpec]] = None
|
|
66
75
|
"""Volume spec."""
|
|
67
76
|
|
|
68
77
|
|
|
@@ -78,30 +87,18 @@ class NodeSelector(BaseModel):
|
|
|
78
87
|
"""Node selector value."""
|
|
79
88
|
|
|
80
89
|
|
|
81
|
-
class ResourceItem(BaseModel):
|
|
82
|
-
"""
|
|
83
|
-
Resource item model.
|
|
84
|
-
"""
|
|
85
|
-
|
|
86
|
-
requests: str = Field(default=None, pattern=r"[\d]+|^([0-9])+([a-zA-Z])+$")
|
|
87
|
-
"""Resource requests."""
|
|
88
|
-
|
|
89
|
-
limits: str = Field(default=None, pattern=r"[\d]+|^([0-9])+([a-zA-Z])+$")
|
|
90
|
-
"""Resource limits."""
|
|
91
|
-
|
|
92
|
-
|
|
93
90
|
class Resource(BaseModel):
|
|
94
91
|
"""
|
|
95
92
|
Resource model.
|
|
96
93
|
"""
|
|
97
94
|
|
|
98
|
-
cpu: Optional[
|
|
95
|
+
cpu: Optional[str] = Field(default=None, pattern=r"[\d]+|^([0-9])+([a-zA-Z])+$")
|
|
99
96
|
"""CPU resource model."""
|
|
100
97
|
|
|
101
|
-
mem: Optional[
|
|
98
|
+
mem: Optional[str] = Field(default=None, pattern=r"[\d]+|^([0-9])+([a-zA-Z])+$")
|
|
102
99
|
"""Memory resource model."""
|
|
103
100
|
|
|
104
|
-
gpu: Optional[
|
|
101
|
+
gpu: Optional[str] = Field(default=None, pattern=r"[\d]+|^([0-9])+([a-zA-Z])+$")
|
|
105
102
|
"""GPU resource model."""
|
|
106
103
|
|
|
107
104
|
|
digitalhub/entities/task/crud.py
CHANGED
|
@@ -7,8 +7,7 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
10
|
-
from digitalhub.entities._processors.
|
|
11
|
-
from digitalhub.utils.exceptions import EntityError
|
|
10
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
12
11
|
|
|
13
12
|
if typing.TYPE_CHECKING:
|
|
14
13
|
from digitalhub.entities.task._base.entity import Task
|
|
@@ -71,7 +70,6 @@ def new_task(
|
|
|
71
70
|
def get_task(
|
|
72
71
|
identifier: str,
|
|
73
72
|
project: str | None = None,
|
|
74
|
-
**kwargs,
|
|
75
73
|
) -> Task:
|
|
76
74
|
"""
|
|
77
75
|
Get object from backend.
|
|
@@ -82,8 +80,6 @@ def get_task(
|
|
|
82
80
|
Entity key (store://...) or entity ID.
|
|
83
81
|
project : str
|
|
84
82
|
Project name.
|
|
85
|
-
**kwargs : dict
|
|
86
|
-
Parameters to pass to the API call.
|
|
87
83
|
|
|
88
84
|
Returns
|
|
89
85
|
-------
|
|
@@ -100,14 +96,24 @@ def get_task(
|
|
|
100
96
|
>>> project="my-project")
|
|
101
97
|
"""
|
|
102
98
|
return context_processor.read_unversioned_entity(
|
|
103
|
-
identifier,
|
|
99
|
+
identifier=identifier,
|
|
104
100
|
entity_type=ENTITY_TYPE,
|
|
105
101
|
project=project,
|
|
106
|
-
**kwargs,
|
|
107
102
|
)
|
|
108
103
|
|
|
109
104
|
|
|
110
|
-
def list_tasks(
|
|
105
|
+
def list_tasks(
|
|
106
|
+
project: str,
|
|
107
|
+
q: str | None = None,
|
|
108
|
+
name: str | None = None,
|
|
109
|
+
kind: str | None = None,
|
|
110
|
+
user: str | None = None,
|
|
111
|
+
state: str | None = None,
|
|
112
|
+
created: str | None = None,
|
|
113
|
+
updated: str | None = None,
|
|
114
|
+
function: str | None = None,
|
|
115
|
+
workflow: str | None = None,
|
|
116
|
+
) -> list[Task]:
|
|
111
117
|
"""
|
|
112
118
|
List all latest version objects from backend.
|
|
113
119
|
|
|
@@ -115,8 +121,24 @@ def list_tasks(project: str, **kwargs) -> list[Task]:
|
|
|
115
121
|
----------
|
|
116
122
|
project : str
|
|
117
123
|
Project name.
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
q : str
|
|
125
|
+
Query string to filter objects.
|
|
126
|
+
name : str
|
|
127
|
+
Object name.
|
|
128
|
+
kind : str
|
|
129
|
+
Kind of the object.
|
|
130
|
+
user : str
|
|
131
|
+
User that created the object.
|
|
132
|
+
state : str
|
|
133
|
+
Object state.
|
|
134
|
+
created : str
|
|
135
|
+
Creation date filter.
|
|
136
|
+
updated : str
|
|
137
|
+
Update date filter.
|
|
138
|
+
function : str
|
|
139
|
+
Function key filter.
|
|
140
|
+
workflow : str
|
|
141
|
+
Workflow key filter.
|
|
120
142
|
|
|
121
143
|
Returns
|
|
122
144
|
-------
|
|
@@ -130,18 +152,37 @@ def list_tasks(project: str, **kwargs) -> list[Task]:
|
|
|
130
152
|
return context_processor.list_context_entities(
|
|
131
153
|
project=project,
|
|
132
154
|
entity_type=ENTITY_TYPE,
|
|
133
|
-
|
|
155
|
+
q=q,
|
|
156
|
+
name=name,
|
|
157
|
+
kind=kind,
|
|
158
|
+
user=user,
|
|
159
|
+
state=state,
|
|
160
|
+
created=created,
|
|
161
|
+
updated=updated,
|
|
162
|
+
function=function,
|
|
163
|
+
workflow=workflow,
|
|
134
164
|
)
|
|
135
165
|
|
|
136
166
|
|
|
137
|
-
def import_task(
|
|
167
|
+
def import_task(
|
|
168
|
+
file: str | None = None,
|
|
169
|
+
key: str | None = None,
|
|
170
|
+
reset_id: bool = False,
|
|
171
|
+
context: str | None = None,
|
|
172
|
+
) -> Task:
|
|
138
173
|
"""
|
|
139
|
-
Import object from a YAML file
|
|
174
|
+
Import an object from a YAML file or from a storage key.
|
|
140
175
|
|
|
141
176
|
Parameters
|
|
142
177
|
----------
|
|
143
178
|
file : str
|
|
144
|
-
Path to YAML file.
|
|
179
|
+
Path to the YAML file.
|
|
180
|
+
key : str
|
|
181
|
+
Entity key (store://...).
|
|
182
|
+
reset_id : bool
|
|
183
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
184
|
+
context : str
|
|
185
|
+
Project name to use for context resolution.
|
|
145
186
|
|
|
146
187
|
Returns
|
|
147
188
|
-------
|
|
@@ -152,7 +193,12 @@ def import_task(file: str) -> Task:
|
|
|
152
193
|
-------
|
|
153
194
|
>>> obj = import_task("my-task.yaml")
|
|
154
195
|
"""
|
|
155
|
-
return context_processor.import_context_entity(
|
|
196
|
+
return context_processor.import_context_entity(
|
|
197
|
+
file,
|
|
198
|
+
key,
|
|
199
|
+
reset_id,
|
|
200
|
+
context,
|
|
201
|
+
)
|
|
156
202
|
|
|
157
203
|
|
|
158
204
|
def load_task(file: str) -> Task:
|
|
@@ -206,9 +252,7 @@ def delete_task(
|
|
|
206
252
|
identifier: str,
|
|
207
253
|
project: str | None = None,
|
|
208
254
|
entity_id: str | None = None,
|
|
209
|
-
delete_all_versions: bool = False,
|
|
210
255
|
cascade: bool = True,
|
|
211
|
-
**kwargs,
|
|
212
256
|
) -> dict:
|
|
213
257
|
"""
|
|
214
258
|
Delete object from backend.
|
|
@@ -221,8 +265,6 @@ def delete_task(
|
|
|
221
265
|
Project name.
|
|
222
266
|
entity_id : str
|
|
223
267
|
Entity ID.
|
|
224
|
-
delete_all_versions : bool
|
|
225
|
-
Delete all versions of the named entity. If True, use entity name instead of entity key as identifier.
|
|
226
268
|
cascade : bool
|
|
227
269
|
Cascade delete.
|
|
228
270
|
**kwargs : dict
|
|
@@ -235,22 +277,12 @@ def delete_task(
|
|
|
235
277
|
|
|
236
278
|
Examples
|
|
237
279
|
--------
|
|
238
|
-
If delete_all_versions is False:
|
|
239
280
|
>>> obj = delete_task("store://my-task-key")
|
|
240
|
-
|
|
241
|
-
Otherwise:
|
|
242
|
-
>>> obj = delete_task("task-name",
|
|
243
|
-
>>> project="my-project",
|
|
244
|
-
>>> delete_all_versions=True)
|
|
245
281
|
"""
|
|
246
|
-
if not identifier.startswith("store://"):
|
|
247
|
-
raise EntityError("Task has no name. Use key instead.")
|
|
248
282
|
return context_processor.delete_context_entity(
|
|
249
283
|
identifier=identifier,
|
|
250
284
|
entity_type=ENTITY_TYPE,
|
|
251
285
|
project=project,
|
|
252
286
|
entity_id=entity_id,
|
|
253
|
-
delete_all_versions=delete_all_versions,
|
|
254
287
|
cascade=cascade,
|
|
255
|
-
**kwargs,
|
|
256
288
|
)
|
|
@@ -8,7 +8,7 @@ import typing
|
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._base.versioned.entity import VersionedEntity
|
|
10
10
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
11
|
-
from digitalhub.entities._processors.
|
|
11
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
12
12
|
|
|
13
13
|
if typing.TYPE_CHECKING:
|
|
14
14
|
from digitalhub.entities._base.entity.metadata import Metadata
|
|
@@ -41,9 +41,5 @@ class Trigger(VersionedEntity):
|
|
|
41
41
|
def stop(self) -> None:
|
|
42
42
|
"""
|
|
43
43
|
Stop trigger.
|
|
44
|
-
|
|
45
|
-
Returns
|
|
46
|
-
-------
|
|
47
|
-
None
|
|
48
44
|
"""
|
|
49
45
|
return context_processor.stop_entity(self.project, self.ENTITY_TYPE, self.id)
|
|
@@ -7,7 +7,7 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
10
|
-
from digitalhub.entities._processors.
|
|
10
|
+
from digitalhub.entities._processors.processors import context_processor
|
|
11
11
|
|
|
12
12
|
if typing.TYPE_CHECKING:
|
|
13
13
|
from digitalhub.entities.trigger._base.entity import Trigger
|
|
@@ -91,7 +91,6 @@ def get_trigger(
|
|
|
91
91
|
identifier: str,
|
|
92
92
|
project: str | None = None,
|
|
93
93
|
entity_id: str | None = None,
|
|
94
|
-
**kwargs,
|
|
95
94
|
) -> Trigger:
|
|
96
95
|
"""
|
|
97
96
|
Get object from backend.
|
|
@@ -104,8 +103,6 @@ def get_trigger(
|
|
|
104
103
|
Project name.
|
|
105
104
|
entity_id : str
|
|
106
105
|
Entity ID.
|
|
107
|
-
**kwargs : dict
|
|
108
|
-
Parameters to pass to the API call.
|
|
109
106
|
|
|
110
107
|
Returns
|
|
111
108
|
-------
|
|
@@ -123,18 +120,16 @@ def get_trigger(
|
|
|
123
120
|
>>> entity_id="my-trigger-id")
|
|
124
121
|
"""
|
|
125
122
|
return context_processor.read_context_entity(
|
|
126
|
-
identifier,
|
|
123
|
+
identifier=identifier,
|
|
127
124
|
entity_type=ENTITY_TYPE,
|
|
128
125
|
project=project,
|
|
129
126
|
entity_id=entity_id,
|
|
130
|
-
**kwargs,
|
|
131
127
|
)
|
|
132
128
|
|
|
133
129
|
|
|
134
130
|
def get_trigger_versions(
|
|
135
131
|
identifier: str,
|
|
136
132
|
project: str | None = None,
|
|
137
|
-
**kwargs,
|
|
138
133
|
) -> list[Trigger]:
|
|
139
134
|
"""
|
|
140
135
|
Get object versions from backend.
|
|
@@ -145,8 +140,6 @@ def get_trigger_versions(
|
|
|
145
140
|
Entity key (store://...) or entity name.
|
|
146
141
|
project : str
|
|
147
142
|
Project name.
|
|
148
|
-
**kwargs : dict
|
|
149
|
-
Parameters to pass to the API call.
|
|
150
143
|
|
|
151
144
|
Returns
|
|
152
145
|
-------
|
|
@@ -163,14 +156,24 @@ def get_trigger_versions(
|
|
|
163
156
|
>>> project="my-project")
|
|
164
157
|
"""
|
|
165
158
|
return context_processor.read_context_entity_versions(
|
|
166
|
-
identifier,
|
|
159
|
+
identifier=identifier,
|
|
167
160
|
entity_type=ENTITY_TYPE,
|
|
168
161
|
project=project,
|
|
169
|
-
**kwargs,
|
|
170
162
|
)
|
|
171
163
|
|
|
172
164
|
|
|
173
|
-
def list_triggers(
|
|
165
|
+
def list_triggers(
|
|
166
|
+
project: str,
|
|
167
|
+
q: str | None = None,
|
|
168
|
+
name: str | None = None,
|
|
169
|
+
kind: str | None = None,
|
|
170
|
+
user: str | None = None,
|
|
171
|
+
state: str | None = None,
|
|
172
|
+
created: str | None = None,
|
|
173
|
+
updated: str | None = None,
|
|
174
|
+
version: str | None = None,
|
|
175
|
+
task: str | None = None,
|
|
176
|
+
) -> list[Trigger]:
|
|
174
177
|
"""
|
|
175
178
|
List all latest version objects from backend.
|
|
176
179
|
|
|
@@ -178,8 +181,24 @@ def list_triggers(project: str, **kwargs) -> list[Trigger]:
|
|
|
178
181
|
----------
|
|
179
182
|
project : str
|
|
180
183
|
Project name.
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
q : str
|
|
185
|
+
Query string to filter objects.
|
|
186
|
+
name : str
|
|
187
|
+
Object name.
|
|
188
|
+
kind : str
|
|
189
|
+
Kind of the object.
|
|
190
|
+
user : str
|
|
191
|
+
User that created the object.
|
|
192
|
+
state : str
|
|
193
|
+
Object state.
|
|
194
|
+
created : str
|
|
195
|
+
Creation date filter.
|
|
196
|
+
updated : str
|
|
197
|
+
Update date filter.
|
|
198
|
+
version : str
|
|
199
|
+
Object version, default is latest.
|
|
200
|
+
task : str
|
|
201
|
+
Task string filter.
|
|
183
202
|
|
|
184
203
|
Returns
|
|
185
204
|
-------
|
|
@@ -193,18 +212,37 @@ def list_triggers(project: str, **kwargs) -> list[Trigger]:
|
|
|
193
212
|
return context_processor.list_context_entities(
|
|
194
213
|
project=project,
|
|
195
214
|
entity_type=ENTITY_TYPE,
|
|
196
|
-
|
|
215
|
+
q=q,
|
|
216
|
+
name=name,
|
|
217
|
+
kind=kind,
|
|
218
|
+
user=user,
|
|
219
|
+
state=state,
|
|
220
|
+
created=created,
|
|
221
|
+
updated=updated,
|
|
222
|
+
version=version,
|
|
223
|
+
task=task,
|
|
197
224
|
)
|
|
198
225
|
|
|
199
226
|
|
|
200
|
-
def import_trigger(
|
|
227
|
+
def import_trigger(
|
|
228
|
+
file: str | None = None,
|
|
229
|
+
key: str | None = None,
|
|
230
|
+
reset_id: bool = False,
|
|
231
|
+
context: str | None = None,
|
|
232
|
+
) -> Trigger:
|
|
201
233
|
"""
|
|
202
|
-
Import object from a YAML file
|
|
234
|
+
Import an object from a YAML file or from a storage key.
|
|
203
235
|
|
|
204
236
|
Parameters
|
|
205
237
|
----------
|
|
206
238
|
file : str
|
|
207
|
-
Path to YAML file.
|
|
239
|
+
Path to the YAML file.
|
|
240
|
+
key : str
|
|
241
|
+
Entity key (store://...).
|
|
242
|
+
reset_id : bool
|
|
243
|
+
Flag to determine if the ID of executable entities should be reset.
|
|
244
|
+
context : str
|
|
245
|
+
Project name to use for context resolution.
|
|
208
246
|
|
|
209
247
|
Returns
|
|
210
248
|
-------
|
|
@@ -215,7 +253,12 @@ def import_trigger(file: str) -> Trigger:
|
|
|
215
253
|
--------
|
|
216
254
|
>>> obj = import_trigger("my-trigger.yaml")
|
|
217
255
|
"""
|
|
218
|
-
return context_processor.import_context_entity(
|
|
256
|
+
return context_processor.import_context_entity(
|
|
257
|
+
file,
|
|
258
|
+
key,
|
|
259
|
+
reset_id,
|
|
260
|
+
context,
|
|
261
|
+
)
|
|
219
262
|
|
|
220
263
|
|
|
221
264
|
def load_trigger(file: str) -> Trigger:
|
|
@@ -270,7 +313,6 @@ def delete_trigger(
|
|
|
270
313
|
project: str | None = None,
|
|
271
314
|
entity_id: str | None = None,
|
|
272
315
|
delete_all_versions: bool = False,
|
|
273
|
-
**kwargs,
|
|
274
316
|
) -> dict:
|
|
275
317
|
"""
|
|
276
318
|
Delete object from backend.
|
|
@@ -284,9 +326,8 @@ def delete_trigger(
|
|
|
284
326
|
entity_id : str
|
|
285
327
|
Entity ID.
|
|
286
328
|
delete_all_versions : bool
|
|
287
|
-
Delete all versions of the named entity.
|
|
288
|
-
|
|
289
|
-
Parameters to pass to the API call.
|
|
329
|
+
Delete all versions of the named entity.
|
|
330
|
+
If True, use entity name instead of entity key as identifier.
|
|
290
331
|
|
|
291
332
|
Returns
|
|
292
333
|
-------
|
|
@@ -309,5 +350,4 @@ def delete_trigger(
|
|
|
309
350
|
project=project,
|
|
310
351
|
entity_id=entity_id,
|
|
311
352
|
delete_all_versions=delete_all_versions,
|
|
312
|
-
**kwargs,
|
|
313
353
|
)
|
|
@@ -8,7 +8,7 @@ import typing
|
|
|
8
8
|
|
|
9
9
|
from digitalhub.entities._base.executable.entity import ExecutableEntity
|
|
10
10
|
from digitalhub.entities._commons.enums import EntityTypes, Relationship
|
|
11
|
-
from digitalhub.factory.
|
|
11
|
+
from digitalhub.factory.entity import entity_factory
|
|
12
12
|
from digitalhub.utils.exceptions import BackendError
|
|
13
13
|
|
|
14
14
|
if typing.TYPE_CHECKING:
|
|
@@ -72,8 +72,8 @@ class Workflow(ExecutableEntity):
|
|
|
72
72
|
Run instance.
|
|
73
73
|
"""
|
|
74
74
|
# Get task and run kind
|
|
75
|
-
task_kind =
|
|
76
|
-
run_kind =
|
|
75
|
+
task_kind = entity_factory.get_task_kind_from_action(self.kind, action)
|
|
76
|
+
run_kind = entity_factory.get_run_kind_from_action(self.kind, action)
|
|
77
77
|
|
|
78
78
|
# Create or update new task
|
|
79
79
|
task = self._get_or_create_task(task_kind)
|