digitalhub 0.14.0b5__py3-none-any.whl → 0.14.9__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.
- digitalhub/__init__.py +2 -2
- digitalhub/context/api.py +43 -6
- digitalhub/context/builder.py +1 -1
- digitalhub/context/context.py +3 -6
- digitalhub/entities/_base/context/entity.py +0 -3
- digitalhub/entities/_base/executable/entity.py +29 -11
- digitalhub/entities/_base/material/entity.py +2 -2
- digitalhub/entities/_base/material/utils.py +0 -4
- digitalhub/entities/_commons/enums.py +1 -0
- digitalhub/entities/_commons/utils.py +19 -0
- digitalhub/entities/_processors/base/crud.py +15 -24
- digitalhub/entities/_processors/base/import_export.py +3 -7
- digitalhub/entities/_processors/base/processor.py +4 -7
- digitalhub/entities/_processors/base/special_ops.py +4 -8
- digitalhub/entities/_processors/context/crud.py +27 -29
- digitalhub/entities/_processors/context/import_export.py +7 -7
- digitalhub/entities/_processors/context/material.py +2 -2
- digitalhub/entities/_processors/context/special_ops.py +25 -25
- digitalhub/entities/_processors/utils.py +7 -116
- digitalhub/entities/artifact/crud.py +3 -3
- digitalhub/entities/artifact/utils.py +2 -2
- digitalhub/entities/builders.py +2 -0
- digitalhub/entities/dataitem/crud.py +3 -3
- digitalhub/entities/dataitem/utils.py +10 -14
- digitalhub/entities/function/_base/entity.py +0 -3
- digitalhub/entities/function/crud.py +3 -3
- digitalhub/entities/model/crud.py +3 -3
- digitalhub/entities/model/mlflow/utils.py +29 -20
- digitalhub/entities/model/utils.py +2 -2
- digitalhub/entities/project/_base/builder.py +0 -6
- digitalhub/entities/project/_base/entity.py +264 -114
- digitalhub/entities/project/_base/spec.py +4 -4
- digitalhub/entities/project/crud.py +16 -51
- digitalhub/entities/project/utils.py +7 -3
- digitalhub/entities/secret/crud.py +2 -2
- digitalhub/entities/task/_base/models.py +13 -16
- digitalhub/entities/trigger/crud.py +28 -9
- digitalhub/entities/workflow/_base/entity.py +0 -5
- digitalhub/entities/workflow/crud.py +3 -6
- digitalhub/stores/client/{dhcore/api_builder.py → api_builder.py} +2 -3
- digitalhub/stores/client/builder.py +20 -32
- digitalhub/stores/client/client.py +322 -0
- digitalhub/stores/client/{dhcore/configurator.py → configurator.py} +148 -195
- digitalhub/stores/client/{_base/enums.py → enums.py} +11 -0
- digitalhub/stores/client/header_manager.py +61 -0
- digitalhub/stores/client/http_handler.py +152 -0
- digitalhub/stores/client/{_base/key_builder.py → key_builder.py} +14 -14
- digitalhub/stores/client/{dhcore/params_builder.py → params_builder.py} +51 -12
- digitalhub/stores/client/response_processor.py +102 -0
- digitalhub/stores/client/utils.py +35 -0
- digitalhub/stores/{credentials → configurator}/api.py +5 -9
- digitalhub/stores/configurator/configurator.py +123 -0
- digitalhub/stores/{credentials → configurator}/enums.py +26 -10
- digitalhub/stores/configurator/handler.py +213 -0
- digitalhub/stores/{credentials → configurator}/ini_module.py +31 -6
- digitalhub/stores/data/_base/store.py +0 -4
- digitalhub/stores/data/api.py +4 -6
- digitalhub/stores/data/builder.py +6 -38
- digitalhub/stores/data/s3/configurator.py +30 -114
- digitalhub/stores/data/s3/store.py +9 -22
- digitalhub/stores/data/sql/configurator.py +49 -71
- digitalhub/stores/data/sql/store.py +26 -61
- digitalhub/utils/generic_utils.py +0 -12
- digitalhub/utils/git_utils.py +0 -8
- digitalhub/utils/io_utils.py +0 -8
- digitalhub/utils/store_utils.py +1 -1
- {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/METADATA +3 -3
- {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/RECORD +73 -86
- {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/WHEEL +1 -1
- digitalhub/stores/client/_base/api_builder.py +0 -34
- digitalhub/stores/client/_base/client.py +0 -243
- digitalhub/stores/client/_base/params_builder.py +0 -82
- digitalhub/stores/client/api.py +0 -32
- digitalhub/stores/client/dhcore/__init__.py +0 -3
- digitalhub/stores/client/dhcore/client.py +0 -553
- digitalhub/stores/client/dhcore/enums.py +0 -18
- digitalhub/stores/client/dhcore/key_builder.py +0 -62
- digitalhub/stores/client/dhcore/utils.py +0 -86
- digitalhub/stores/client/local/__init__.py +0 -3
- digitalhub/stores/client/local/api_builder.py +0 -116
- digitalhub/stores/client/local/client.py +0 -605
- digitalhub/stores/client/local/enums.py +0 -15
- digitalhub/stores/client/local/key_builder.py +0 -62
- digitalhub/stores/client/local/params_builder.py +0 -97
- digitalhub/stores/credentials/__init__.py +0 -3
- digitalhub/stores/credentials/configurator.py +0 -185
- digitalhub/stores/credentials/handler.py +0 -164
- digitalhub/stores/credentials/store.py +0 -77
- digitalhub/stores/data/enums.py +0 -15
- /digitalhub/stores/client/{dhcore/error_parser.py → error_parser.py} +0 -0
- /digitalhub/stores/{client/_base → configurator}/__init__.py +0 -0
- {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.14.0b5.dist-info → digitalhub-0.14.9.dist-info}/licenses/LICENSE +0 -0
digitalhub/__init__.py
CHANGED
|
@@ -95,8 +95,8 @@ from digitalhub.entities.workflow.crud import (
|
|
|
95
95
|
new_workflow,
|
|
96
96
|
update_workflow,
|
|
97
97
|
)
|
|
98
|
-
from digitalhub.stores.client.
|
|
99
|
-
from digitalhub.stores.
|
|
98
|
+
from digitalhub.stores.client.utils import get_credentials_and_config, refresh_token
|
|
99
|
+
from digitalhub.stores.configurator.api import get_current_profile, set_current_profile
|
|
100
100
|
from digitalhub.utils.store_utils import get_s3_client, get_sql_engine
|
|
101
101
|
|
|
102
102
|
try:
|
digitalhub/context/api.py
CHANGED
|
@@ -7,6 +7,11 @@ from __future__ import annotations
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
9
|
from digitalhub.context.builder import context_builder
|
|
10
|
+
from digitalhub.entities._commons.enums import EntityTypes
|
|
11
|
+
from digitalhub.factory.entity import entity_factory
|
|
12
|
+
from digitalhub.stores.client.builder import get_client
|
|
13
|
+
from digitalhub.stores.client.enums import ApiCategories, BackendOperations
|
|
14
|
+
from digitalhub.utils.exceptions import ContextError, EntityNotExistsError
|
|
10
15
|
|
|
11
16
|
if typing.TYPE_CHECKING:
|
|
12
17
|
from digitalhub.context.context import Context
|
|
@@ -24,7 +29,7 @@ def build_context(project: Project, overwrite: bool = False) -> Context:
|
|
|
24
29
|
----------
|
|
25
30
|
project : Project
|
|
26
31
|
The project object used to build the context.
|
|
27
|
-
overwrite : bool
|
|
32
|
+
overwrite : bool
|
|
28
33
|
If True, overwrites existing context if it exists. Default is False.
|
|
29
34
|
|
|
30
35
|
Returns
|
|
@@ -49,20 +54,52 @@ def get_context(project: str) -> Context:
|
|
|
49
54
|
Context
|
|
50
55
|
The context for the given project name.
|
|
51
56
|
"""
|
|
52
|
-
|
|
57
|
+
try:
|
|
58
|
+
return context_builder.get(project)
|
|
59
|
+
except ContextError:
|
|
60
|
+
try:
|
|
61
|
+
return get_context_from_remote(project)
|
|
62
|
+
except EntityNotExistsError as e:
|
|
63
|
+
raise ContextError(f"Context '{project}' not found remotely nor locally.") from e
|
|
53
64
|
|
|
54
65
|
|
|
55
|
-
def
|
|
66
|
+
def get_context_from_remote(project: str) -> Context:
|
|
56
67
|
"""
|
|
57
|
-
|
|
68
|
+
Fetch project context from remote backend and create local context.
|
|
69
|
+
|
|
58
70
|
|
|
59
71
|
Parameters
|
|
60
72
|
----------
|
|
61
73
|
project : str
|
|
62
|
-
|
|
74
|
+
The name of the project to fetch from remote.
|
|
63
75
|
|
|
64
76
|
Returns
|
|
65
77
|
-------
|
|
66
|
-
|
|
78
|
+
Context
|
|
79
|
+
The context instance created from the remote project data.
|
|
80
|
+
"""
|
|
81
|
+
try:
|
|
82
|
+
client = get_client()
|
|
83
|
+
api = client.build_api(
|
|
84
|
+
ApiCategories.BASE.value,
|
|
85
|
+
BackendOperations.READ.value,
|
|
86
|
+
entity_type=EntityTypes.PROJECT.value,
|
|
87
|
+
entity_name=project,
|
|
88
|
+
)
|
|
89
|
+
obj = client.read_object(api)
|
|
90
|
+
entity_factory.build_entity_from_dict(obj)
|
|
91
|
+
return context_builder.get(project)
|
|
92
|
+
except EntityNotExistsError:
|
|
93
|
+
raise ContextError(f"Project '{project}' not found.")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def delete_context(project: str) -> None:
|
|
97
|
+
"""
|
|
98
|
+
Delete the context for a given project name.
|
|
99
|
+
|
|
100
|
+
Parameters
|
|
101
|
+
----------
|
|
102
|
+
project : str
|
|
103
|
+
Project name.
|
|
67
104
|
"""
|
|
68
105
|
context_builder.remove(project)
|
digitalhub/context/builder.py
CHANGED
digitalhub/context/context.py
CHANGED
|
@@ -10,12 +10,12 @@ from pathlib import Path
|
|
|
10
10
|
|
|
11
11
|
from digitalhub.entities._commons.enums import EntityTypes
|
|
12
12
|
from digitalhub.runtimes.enums import RuntimeEnvVar
|
|
13
|
-
from digitalhub.stores.client.
|
|
13
|
+
from digitalhub.stores.client.enums import ApiCategories, BackendOperations
|
|
14
14
|
from digitalhub.utils.exceptions import BackendError
|
|
15
15
|
|
|
16
16
|
if typing.TYPE_CHECKING:
|
|
17
17
|
from digitalhub.entities.project._base.entity import Project
|
|
18
|
-
from digitalhub.stores.client.
|
|
18
|
+
from digitalhub.stores.client.client import Client
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class Context:
|
|
@@ -33,8 +33,6 @@ class Context:
|
|
|
33
33
|
The client instance (local or remote) associated with the project.
|
|
34
34
|
config : dict
|
|
35
35
|
Project configuration profile.
|
|
36
|
-
local : bool
|
|
37
|
-
Whether the client is local or remote.
|
|
38
36
|
root : Path
|
|
39
37
|
The local context project path.
|
|
40
38
|
is_running : bool
|
|
@@ -47,8 +45,7 @@ class Context:
|
|
|
47
45
|
self.name: str = project.name
|
|
48
46
|
self.client: Client = project._client
|
|
49
47
|
self.config: dict = project.spec.config
|
|
50
|
-
self.
|
|
51
|
-
self.root: Path = Path(project.spec.context)
|
|
48
|
+
self.root: Path = Path(project.spec.source)
|
|
52
49
|
self.root.mkdir(parents=True, exist_ok=True)
|
|
53
50
|
|
|
54
51
|
self.is_running: bool = False
|
|
@@ -9,7 +9,6 @@ import typing
|
|
|
9
9
|
from digitalhub.context.api import get_context
|
|
10
10
|
from digitalhub.entities._base.entity.entity import Entity
|
|
11
11
|
from digitalhub.entities._processors.processors import context_processor
|
|
12
|
-
from digitalhub.utils.generic_utils import get_timestamp
|
|
13
12
|
from digitalhub.utils.io_utils import write_yaml
|
|
14
13
|
|
|
15
14
|
if typing.TYPE_CHECKING:
|
|
@@ -81,8 +80,6 @@ class ContextEntity(Entity):
|
|
|
81
80
|
ContextEntity
|
|
82
81
|
Entity updated.
|
|
83
82
|
"""
|
|
84
|
-
if self._context().local:
|
|
85
|
-
self.metadata.updated = self.metadata.updated = get_timestamp()
|
|
86
83
|
new_obj = context_processor.update_context_entity(self.project, self.ENTITY_TYPE, self.id, self.to_dict())
|
|
87
84
|
self._update_attributes(new_obj)
|
|
88
85
|
return self
|
|
@@ -462,8 +462,9 @@ class ExecutableEntity(VersionedEntity):
|
|
|
462
462
|
def trigger(
|
|
463
463
|
self,
|
|
464
464
|
action: str,
|
|
465
|
-
|
|
466
|
-
|
|
465
|
+
kind: str,
|
|
466
|
+
name: str,
|
|
467
|
+
template: dict | None = None,
|
|
467
468
|
**kwargs,
|
|
468
469
|
) -> Trigger:
|
|
469
470
|
"""
|
|
@@ -473,10 +474,14 @@ class ExecutableEntity(VersionedEntity):
|
|
|
473
474
|
----------
|
|
474
475
|
action : str
|
|
475
476
|
Action to execute.
|
|
476
|
-
|
|
477
|
+
kind : str
|
|
477
478
|
Trigger kind.
|
|
479
|
+
name : str
|
|
480
|
+
Trigger name.
|
|
481
|
+
template : dict
|
|
482
|
+
Template for the trigger.
|
|
478
483
|
**kwargs : dict
|
|
479
|
-
Keyword arguments passed to
|
|
484
|
+
Keyword arguments passed to trigger builder.
|
|
480
485
|
|
|
481
486
|
Returns
|
|
482
487
|
-------
|
|
@@ -487,17 +492,30 @@ class ExecutableEntity(VersionedEntity):
|
|
|
487
492
|
task_kind = entity_factory.get_task_kind_from_action(self.kind, action)
|
|
488
493
|
task = self._get_or_create_task(task_kind)
|
|
489
494
|
task_string = task._get_task_string()
|
|
495
|
+
exec_string = self._get_executable_string()
|
|
490
496
|
|
|
491
497
|
# Get run validator for building trigger template
|
|
492
498
|
run_kind = entity_factory.get_run_kind_from_action(self.kind, action)
|
|
493
499
|
run_validator: SpecValidator = entity_factory.get_spec_validator(run_kind)
|
|
500
|
+
|
|
494
501
|
# Override kwargs
|
|
495
502
|
kwargs["project"] = self.project
|
|
496
|
-
kwargs["kind"] =
|
|
497
|
-
kwargs["name"] =
|
|
498
|
-
|
|
503
|
+
kwargs["kind"] = kind
|
|
504
|
+
kwargs["name"] = name
|
|
505
|
+
|
|
506
|
+
# Template handling
|
|
507
|
+
if template is None:
|
|
508
|
+
template = {}
|
|
509
|
+
if not isinstance(template, dict):
|
|
510
|
+
raise EntityError("Template must be a dictionary")
|
|
511
|
+
|
|
512
|
+
template["task"] = task_string
|
|
513
|
+
template[self.ENTITY_TYPE] = exec_string
|
|
514
|
+
template = run_validator(**template).to_dict()
|
|
515
|
+
|
|
516
|
+
kwargs[self.ENTITY_TYPE] = exec_string
|
|
499
517
|
kwargs["task"] = task_string
|
|
500
|
-
kwargs["template"] =
|
|
518
|
+
kwargs["template"] = template
|
|
501
519
|
|
|
502
520
|
# Create object instance
|
|
503
521
|
trigger: Trigger = entity_factory.build_entity_from_params(**kwargs)
|
|
@@ -535,7 +553,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
535
553
|
user: str | None = None,
|
|
536
554
|
created: str | None = None,
|
|
537
555
|
updated: str | None = None,
|
|
538
|
-
|
|
556
|
+
versions: str | None = None,
|
|
539
557
|
task: str | None = None,
|
|
540
558
|
) -> list[Trigger]:
|
|
541
559
|
"""
|
|
@@ -555,7 +573,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
555
573
|
Creation date filter.
|
|
556
574
|
updated : str
|
|
557
575
|
Update date filter.
|
|
558
|
-
|
|
576
|
+
versions : str
|
|
559
577
|
Object version, default is latest.
|
|
560
578
|
task : str
|
|
561
579
|
Task string filter.
|
|
@@ -572,7 +590,7 @@ class ExecutableEntity(VersionedEntity):
|
|
|
572
590
|
user=user,
|
|
573
591
|
created=created,
|
|
574
592
|
updated=updated,
|
|
575
|
-
|
|
593
|
+
versions=versions,
|
|
576
594
|
task=task,
|
|
577
595
|
)
|
|
578
596
|
|
|
@@ -56,7 +56,7 @@ class MaterialEntity(VersionedEntity):
|
|
|
56
56
|
"""
|
|
57
57
|
# Evaluate files info list length
|
|
58
58
|
files = None
|
|
59
|
-
if self.status.files is not None and len(self.status.files) > 5
|
|
59
|
+
if self.status.files is not None and len(self.status.files) > 5:
|
|
60
60
|
files = self.status.files
|
|
61
61
|
self.status.files = []
|
|
62
62
|
|
|
@@ -222,7 +222,7 @@ class MaterialEntity(VersionedEntity):
|
|
|
222
222
|
"""
|
|
223
223
|
Get files info from backend.
|
|
224
224
|
"""
|
|
225
|
-
if not self.
|
|
225
|
+
if not self.status.files:
|
|
226
226
|
files = context_processor.read_files_info(
|
|
227
227
|
project=self.project,
|
|
228
228
|
entity_type=self.ENTITY_TYPE,
|
|
@@ -33,6 +33,25 @@ def is_valid_key(key: str) -> bool:
|
|
|
33
33
|
return bool(re.fullmatch(KEY_PATTERN_WITH_ID, key) or re.fullmatch(KEY_PATTERN_NO_ID, key))
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
def sanitize_unversioned_key(key: str) -> str:
|
|
37
|
+
"""
|
|
38
|
+
Sanitize an unversioned entity key (from name:id to id).
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
key : str
|
|
43
|
+
The unversioned entity key.
|
|
44
|
+
|
|
45
|
+
Returns
|
|
46
|
+
-------
|
|
47
|
+
str
|
|
48
|
+
The sanitized entity key with version.
|
|
49
|
+
"""
|
|
50
|
+
splt = key.split("/")[2:]
|
|
51
|
+
ent_id = splt[-1].split(":")[0]
|
|
52
|
+
return "store://" + "/".join(splt[:-1] + [ent_id])
|
|
53
|
+
|
|
54
|
+
|
|
36
55
|
def parse_entity_key(key: str) -> tuple[str, str, str, str | None, str]:
|
|
37
56
|
"""
|
|
38
57
|
Parse an entity key into its constituent components.
|
|
@@ -8,12 +8,12 @@ import typing
|
|
|
8
8
|
|
|
9
9
|
from digitalhub.context.api import delete_context
|
|
10
10
|
from digitalhub.factory.entity import entity_factory
|
|
11
|
-
from digitalhub.stores.client.
|
|
12
|
-
from digitalhub.stores.client.
|
|
11
|
+
from digitalhub.stores.client.builder import get_client
|
|
12
|
+
from digitalhub.stores.client.enums import ApiCategories, BackendOperations
|
|
13
13
|
|
|
14
14
|
if typing.TYPE_CHECKING:
|
|
15
15
|
from digitalhub.entities.project._base.entity import Project
|
|
16
|
-
from digitalhub.stores.client.
|
|
16
|
+
from digitalhub.stores.client.client import Client
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class BaseEntityCRUDProcessor:
|
|
@@ -69,17 +69,15 @@ class BaseEntityCRUDProcessor:
|
|
|
69
69
|
Create a project entity in the backend.
|
|
70
70
|
|
|
71
71
|
Creates a new project either from an existing entity object or
|
|
72
|
-
by building one from the provided parameters.
|
|
73
|
-
local and remote backend creation.
|
|
72
|
+
by building one from the provided parameters.
|
|
74
73
|
|
|
75
74
|
Parameters
|
|
76
75
|
----------
|
|
77
|
-
_entity : Project
|
|
76
|
+
_entity : Project
|
|
78
77
|
An existing project entity object to create. If None,
|
|
79
78
|
a new entity will be built from kwargs.
|
|
80
79
|
**kwargs : dict
|
|
81
|
-
Parameters for entity creation
|
|
82
|
-
and entity-specific parameters.
|
|
80
|
+
Parameters for entity creation.
|
|
83
81
|
|
|
84
82
|
Returns
|
|
85
83
|
-------
|
|
@@ -90,10 +88,9 @@ class BaseEntityCRUDProcessor:
|
|
|
90
88
|
client = _entity._client
|
|
91
89
|
obj = _entity
|
|
92
90
|
else:
|
|
93
|
-
client = get_client(
|
|
91
|
+
client = get_client()
|
|
94
92
|
obj = entity_factory.build_entity_from_params(**kwargs)
|
|
95
93
|
ent = self._create_base_entity(client, obj.ENTITY_TYPE, obj.to_dict())
|
|
96
|
-
ent["local"] = client.is_local()
|
|
97
94
|
return entity_factory.build_entity_from_dict(ent)
|
|
98
95
|
|
|
99
96
|
def _read_base_entity(
|
|
@@ -160,9 +157,8 @@ class BaseEntityCRUDProcessor:
|
|
|
160
157
|
Project
|
|
161
158
|
The project entity object populated with backend data.
|
|
162
159
|
"""
|
|
163
|
-
client = get_client(
|
|
160
|
+
client = get_client()
|
|
164
161
|
obj = self._read_base_entity(client, entity_type, entity_name, **kwargs)
|
|
165
|
-
obj["local"] = client.is_local()
|
|
166
162
|
return entity_factory.build_entity_from_dict(obj)
|
|
167
163
|
|
|
168
164
|
def _list_base_entities(
|
|
@@ -215,19 +211,17 @@ class BaseEntityCRUDProcessor:
|
|
|
215
211
|
entity_type : str
|
|
216
212
|
The type of entities to list (typically 'project').
|
|
217
213
|
**kwargs : dict
|
|
218
|
-
Additional parameters
|
|
219
|
-
API call parameters for filtering or pagination.
|
|
214
|
+
Additional parameters.
|
|
220
215
|
|
|
221
216
|
Returns
|
|
222
217
|
-------
|
|
223
218
|
list[Project]
|
|
224
219
|
List of project entity objects.
|
|
225
220
|
"""
|
|
226
|
-
client = get_client(
|
|
221
|
+
client = get_client()
|
|
227
222
|
objs = self._list_base_entities(client, entity_type, **kwargs)
|
|
228
223
|
entities = []
|
|
229
224
|
for obj in objs:
|
|
230
|
-
obj["local"] = client.is_local()
|
|
231
225
|
ent = entity_factory.build_entity_from_dict(obj)
|
|
232
226
|
entities.append(ent)
|
|
233
227
|
return entities
|
|
@@ -294,17 +288,15 @@ class BaseEntityCRUDProcessor:
|
|
|
294
288
|
entity_dict : dict
|
|
295
289
|
The updated project data dictionary.
|
|
296
290
|
**kwargs : dict
|
|
297
|
-
Additional parameters
|
|
298
|
-
API call parameters.
|
|
291
|
+
Additional parameters.
|
|
299
292
|
|
|
300
293
|
Returns
|
|
301
294
|
-------
|
|
302
295
|
Project
|
|
303
296
|
The updated project entity object.
|
|
304
297
|
"""
|
|
305
|
-
client = get_client(
|
|
298
|
+
client = get_client()
|
|
306
299
|
obj = self._update_base_entity(client, entity_type, entity_name, entity_dict, **kwargs)
|
|
307
|
-
obj["local"] = client.is_local()
|
|
308
300
|
return entity_factory.build_entity_from_dict(obj)
|
|
309
301
|
|
|
310
302
|
def _delete_base_entity(
|
|
@@ -360,7 +352,7 @@ class BaseEntityCRUDProcessor:
|
|
|
360
352
|
Delete a project entity from the backend.
|
|
361
353
|
|
|
362
354
|
Deletes a project from the backend and optionally cleans up
|
|
363
|
-
the associated context.
|
|
355
|
+
the associated context.
|
|
364
356
|
|
|
365
357
|
Parameters
|
|
366
358
|
----------
|
|
@@ -371,8 +363,7 @@ class BaseEntityCRUDProcessor:
|
|
|
371
363
|
entity_name : str
|
|
372
364
|
The name identifier of the project to delete.
|
|
373
365
|
**kwargs : dict
|
|
374
|
-
Additional parameters including '
|
|
375
|
-
flag (default True), and API call parameters.
|
|
366
|
+
Additional parameters including 'clean_context'.
|
|
376
367
|
|
|
377
368
|
Returns
|
|
378
369
|
-------
|
|
@@ -381,7 +372,7 @@ class BaseEntityCRUDProcessor:
|
|
|
381
372
|
"""
|
|
382
373
|
if kwargs.pop("clean_context", True):
|
|
383
374
|
delete_context(entity_name)
|
|
384
|
-
client = get_client(
|
|
375
|
+
client = get_client()
|
|
385
376
|
return self._delete_base_entity(
|
|
386
377
|
client,
|
|
387
378
|
entity_type,
|
|
@@ -8,11 +8,11 @@ import typing
|
|
|
8
8
|
from warnings import warn
|
|
9
9
|
|
|
10
10
|
from digitalhub.factory.entity import entity_factory
|
|
11
|
-
from digitalhub.stores.client.api import get_client
|
|
12
11
|
from digitalhub.utils.exceptions import EntityAlreadyExistsError, EntityError, EntityNotExistsError
|
|
13
12
|
from digitalhub.utils.io_utils import read_yaml
|
|
14
13
|
|
|
15
14
|
if typing.TYPE_CHECKING:
|
|
15
|
+
from digitalhub.entities._processors.base.crud import BaseEntityCRUDProcessor
|
|
16
16
|
from digitalhub.entities.project._base.entity import Project
|
|
17
17
|
|
|
18
18
|
|
|
@@ -26,7 +26,7 @@ class BaseEntityImportExportProcessor:
|
|
|
26
26
|
|
|
27
27
|
def import_project_entity(
|
|
28
28
|
self,
|
|
29
|
-
crud_processor,
|
|
29
|
+
crud_processor: BaseEntityCRUDProcessor,
|
|
30
30
|
file: str,
|
|
31
31
|
**kwargs,
|
|
32
32
|
) -> Project:
|
|
@@ -56,10 +56,8 @@ class BaseEntityImportExportProcessor:
|
|
|
56
56
|
EntityError
|
|
57
57
|
If the project already exists in the backend.
|
|
58
58
|
"""
|
|
59
|
-
client = get_client(kwargs.pop("local", False))
|
|
60
59
|
obj: dict = read_yaml(file)
|
|
61
60
|
obj["status"] = {}
|
|
62
|
-
obj["local"] = client.is_local()
|
|
63
61
|
ent: Project = entity_factory.build_entity_from_dict(obj)
|
|
64
62
|
reset_id = kwargs.pop("reset_id", False)
|
|
65
63
|
|
|
@@ -81,7 +79,7 @@ class BaseEntityImportExportProcessor:
|
|
|
81
79
|
|
|
82
80
|
def load_project_entity(
|
|
83
81
|
self,
|
|
84
|
-
crud_processor,
|
|
82
|
+
crud_processor: BaseEntityCRUDProcessor,
|
|
85
83
|
file: str,
|
|
86
84
|
**kwargs,
|
|
87
85
|
) -> Project:
|
|
@@ -106,9 +104,7 @@ class BaseEntityImportExportProcessor:
|
|
|
106
104
|
Project
|
|
107
105
|
The loaded and updated project entity.
|
|
108
106
|
"""
|
|
109
|
-
client = get_client(kwargs.pop("local", False))
|
|
110
107
|
obj: dict = read_yaml(file)
|
|
111
|
-
obj["local"] = client.is_local()
|
|
112
108
|
ent: Project = entity_factory.build_entity_from_dict(obj)
|
|
113
109
|
|
|
114
110
|
try:
|
|
@@ -49,7 +49,7 @@ class BaseEntityOperationsProcessor:
|
|
|
49
49
|
|
|
50
50
|
Parameters
|
|
51
51
|
----------
|
|
52
|
-
_entity : Project
|
|
52
|
+
_entity : Project
|
|
53
53
|
An existing project entity object to create. If None,
|
|
54
54
|
a new entity will be built from kwargs.
|
|
55
55
|
**kwargs : dict
|
|
@@ -212,7 +212,7 @@ class BaseEntityOperationsProcessor:
|
|
|
212
212
|
EntityError
|
|
213
213
|
If the project already exists in the backend.
|
|
214
214
|
"""
|
|
215
|
-
return self.import_export_processor.import_project_entity(file, **kwargs)
|
|
215
|
+
return self.import_export_processor.import_project_entity(self.crud_processor, file, **kwargs)
|
|
216
216
|
|
|
217
217
|
def load_project_entity(
|
|
218
218
|
self,
|
|
@@ -238,7 +238,7 @@ class BaseEntityOperationsProcessor:
|
|
|
238
238
|
Project
|
|
239
239
|
The loaded and updated project entity.
|
|
240
240
|
"""
|
|
241
|
-
return self.import_export_processor.load_project_entity(file, **kwargs)
|
|
241
|
+
return self.import_export_processor.load_project_entity(self.crud_processor, file, **kwargs)
|
|
242
242
|
|
|
243
243
|
##############################
|
|
244
244
|
# Base entity operations
|
|
@@ -247,7 +247,6 @@ class BaseEntityOperationsProcessor:
|
|
|
247
247
|
def build_project_key(
|
|
248
248
|
self,
|
|
249
249
|
entity_id: str,
|
|
250
|
-
**kwargs,
|
|
251
250
|
) -> str:
|
|
252
251
|
"""
|
|
253
252
|
Build a storage key for a project entity.
|
|
@@ -259,15 +258,13 @@ class BaseEntityOperationsProcessor:
|
|
|
259
258
|
----------
|
|
260
259
|
entity_id : str
|
|
261
260
|
The unique identifier of the project entity.
|
|
262
|
-
**kwargs : dict
|
|
263
|
-
Additional parameters including 'local' flag.
|
|
264
261
|
|
|
265
262
|
Returns
|
|
266
263
|
-------
|
|
267
264
|
str
|
|
268
265
|
The constructed project entity key string.
|
|
269
266
|
"""
|
|
270
|
-
return self.special_ops_processor.build_project_key(entity_id
|
|
267
|
+
return self.special_ops_processor.build_project_key(entity_id)
|
|
271
268
|
|
|
272
269
|
def share_project_entity(
|
|
273
270
|
self,
|
|
@@ -6,8 +6,8 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
import typing
|
|
8
8
|
|
|
9
|
-
from digitalhub.stores.client.
|
|
10
|
-
from digitalhub.stores.client.
|
|
9
|
+
from digitalhub.stores.client.builder import get_client
|
|
10
|
+
from digitalhub.stores.client.enums import ApiCategories, BackendOperations
|
|
11
11
|
|
|
12
12
|
if typing.TYPE_CHECKING:
|
|
13
13
|
pass
|
|
@@ -24,7 +24,6 @@ class BaseEntitySpecialOpsProcessor:
|
|
|
24
24
|
def build_project_key(
|
|
25
25
|
self,
|
|
26
26
|
entity_id: str,
|
|
27
|
-
**kwargs,
|
|
28
27
|
) -> str:
|
|
29
28
|
"""
|
|
30
29
|
Build a storage key for a project entity.
|
|
@@ -36,16 +35,13 @@ class BaseEntitySpecialOpsProcessor:
|
|
|
36
35
|
----------
|
|
37
36
|
entity_id : str
|
|
38
37
|
The unique identifier of the project entity.
|
|
39
|
-
**kwargs : dict
|
|
40
|
-
Additional parameters including 'local' flag.
|
|
41
38
|
|
|
42
39
|
Returns
|
|
43
40
|
-------
|
|
44
41
|
str
|
|
45
42
|
The constructed project entity key string.
|
|
46
43
|
"""
|
|
47
|
-
|
|
48
|
-
return client.build_key(ApiCategories.BASE.value, entity_id)
|
|
44
|
+
return get_client().build_key(ApiCategories.BASE.value, entity_id)
|
|
49
45
|
|
|
50
46
|
def share_project_entity(
|
|
51
47
|
self,
|
|
@@ -77,7 +73,7 @@ class BaseEntitySpecialOpsProcessor:
|
|
|
77
73
|
ValueError
|
|
78
74
|
If trying to unshare from a user who doesn't have access.
|
|
79
75
|
"""
|
|
80
|
-
client = get_client(
|
|
76
|
+
client = get_client()
|
|
81
77
|
api = client.build_api(
|
|
82
78
|
ApiCategories.BASE.value,
|
|
83
79
|
BackendOperations.SHARE.value,
|