digitalhub 0.12.0__py3-none-any.whl → 0.13.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 +1 -1
- digitalhub/context/api.py +5 -5
- digitalhub/context/builder.py +3 -5
- digitalhub/context/context.py +9 -1
- digitalhub/entities/_base/executable/entity.py +105 -57
- digitalhub/entities/_base/material/entity.py +11 -18
- digitalhub/entities/_base/material/utils.py +1 -1
- digitalhub/entities/_commons/metrics.py +64 -30
- digitalhub/entities/_commons/utils.py +36 -9
- digitalhub/entities/_processors/base.py +150 -79
- digitalhub/entities/_processors/context.py +366 -215
- digitalhub/entities/_processors/utils.py +74 -30
- digitalhub/entities/artifact/crud.py +4 -0
- digitalhub/entities/artifact/utils.py +28 -13
- digitalhub/entities/dataitem/crud.py +14 -2
- digitalhub/entities/dataitem/table/entity.py +3 -3
- digitalhub/entities/dataitem/utils.py +84 -35
- digitalhub/entities/model/crud.py +4 -0
- digitalhub/entities/model/utils.py +28 -13
- digitalhub/entities/project/_base/entity.py +0 -2
- digitalhub/entities/run/_base/entity.py +2 -2
- digitalhub/entities/task/_base/models.py +12 -3
- digitalhub/entities/trigger/_base/entity.py +11 -0
- digitalhub/factory/factory.py +25 -3
- digitalhub/factory/utils.py +11 -3
- digitalhub/runtimes/_base.py +1 -1
- digitalhub/runtimes/builder.py +18 -1
- digitalhub/stores/client/__init__.py +12 -0
- digitalhub/stores/client/_base/api_builder.py +14 -0
- digitalhub/stores/client/_base/client.py +93 -0
- digitalhub/stores/client/_base/key_builder.py +28 -0
- digitalhub/stores/client/_base/params_builder.py +14 -0
- digitalhub/stores/client/api.py +10 -5
- digitalhub/stores/client/builder.py +3 -1
- digitalhub/stores/client/dhcore/api_builder.py +17 -0
- digitalhub/stores/client/dhcore/client.py +325 -70
- digitalhub/stores/client/dhcore/configurator.py +485 -193
- digitalhub/stores/client/dhcore/enums.py +3 -0
- digitalhub/stores/client/dhcore/error_parser.py +35 -1
- digitalhub/stores/client/dhcore/params_builder.py +113 -17
- digitalhub/stores/client/dhcore/utils.py +40 -22
- digitalhub/stores/client/local/api_builder.py +17 -0
- digitalhub/stores/client/local/client.py +6 -8
- digitalhub/stores/credentials/api.py +35 -0
- digitalhub/stores/credentials/configurator.py +210 -0
- digitalhub/stores/credentials/enums.py +68 -0
- digitalhub/stores/credentials/handler.py +176 -0
- digitalhub/stores/{configurator → credentials}/ini_module.py +60 -28
- digitalhub/stores/credentials/store.py +81 -0
- digitalhub/stores/data/_base/store.py +27 -9
- digitalhub/stores/data/api.py +49 -9
- digitalhub/stores/data/builder.py +90 -41
- digitalhub/stores/data/local/store.py +4 -7
- digitalhub/stores/data/remote/store.py +4 -7
- digitalhub/stores/data/s3/configurator.py +65 -80
- digitalhub/stores/data/s3/store.py +69 -81
- digitalhub/stores/data/s3/utils.py +10 -10
- digitalhub/stores/data/sql/configurator.py +76 -73
- digitalhub/stores/data/sql/store.py +191 -102
- digitalhub/utils/exceptions.py +6 -0
- digitalhub/utils/file_utils.py +53 -30
- digitalhub/utils/generic_utils.py +41 -33
- digitalhub/utils/git_utils.py +24 -14
- digitalhub/utils/io_utils.py +19 -18
- digitalhub/utils/uri_utils.py +31 -31
- {digitalhub-0.12.0.dist-info → digitalhub-0.13.0.dist-info}/METADATA +1 -1
- {digitalhub-0.12.0.dist-info → digitalhub-0.13.0.dist-info}/RECORD +71 -74
- digitalhub/entities/_commons/types.py +0 -9
- digitalhub/stores/configurator/api.py +0 -35
- digitalhub/stores/configurator/configurator.py +0 -202
- digitalhub/stores/configurator/credentials_store.py +0 -69
- digitalhub/stores/configurator/enums.py +0 -25
- digitalhub/stores/data/s3/enums.py +0 -20
- digitalhub/stores/data/sql/enums.py +0 -20
- digitalhub/stores/data/utils.py +0 -38
- /digitalhub/stores/{configurator → credentials}/__init__.py +0 -0
- {digitalhub-0.12.0.dist-info → digitalhub-0.13.0.dist-info}/WHEEL +0 -0
- {digitalhub-0.12.0.dist-info → digitalhub-0.13.0.dist-info}/licenses/AUTHORS +0 -0
- {digitalhub-0.12.0.dist-info → digitalhub-0.13.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
import os
|
|
8
|
-
|
|
9
|
-
from digitalhub.stores.configurator.credentials_store import CredentialsStore
|
|
10
|
-
from digitalhub.stores.configurator.enums import SetCreds
|
|
11
|
-
from digitalhub.stores.configurator.ini_module import load_from_file, read_env_from_file, set_current_env, write_config
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class EnvConfigurator:
|
|
15
|
-
"""
|
|
16
|
-
Configurator object used to configure clients and store credentials.
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
def __init__(self) -> None:
|
|
20
|
-
# Store
|
|
21
|
-
self._creds_store = CredentialsStore()
|
|
22
|
-
|
|
23
|
-
# Current credentials set (__default by default)
|
|
24
|
-
self._environment = os.getenv(SetCreds.DH_ENV.value, SetCreds.DEFAULT.value)
|
|
25
|
-
|
|
26
|
-
##############################
|
|
27
|
-
# Public methods
|
|
28
|
-
##############################
|
|
29
|
-
|
|
30
|
-
def set_current_env(self, creds_set: str) -> None:
|
|
31
|
-
"""
|
|
32
|
-
Set the current credentials set.
|
|
33
|
-
|
|
34
|
-
Parameters
|
|
35
|
-
----------
|
|
36
|
-
creds_set : str
|
|
37
|
-
Credentials set name.
|
|
38
|
-
|
|
39
|
-
Returns
|
|
40
|
-
-------
|
|
41
|
-
None
|
|
42
|
-
"""
|
|
43
|
-
self._environment = creds_set
|
|
44
|
-
set_current_env(creds_set)
|
|
45
|
-
|
|
46
|
-
def get_current_env(self) -> str:
|
|
47
|
-
"""
|
|
48
|
-
Get the current credentials set.
|
|
49
|
-
|
|
50
|
-
Returns
|
|
51
|
-
-------
|
|
52
|
-
str
|
|
53
|
-
Credentials set name.
|
|
54
|
-
"""
|
|
55
|
-
return self._environment
|
|
56
|
-
|
|
57
|
-
##############################
|
|
58
|
-
# Private methods
|
|
59
|
-
##############################
|
|
60
|
-
|
|
61
|
-
def load_var(self, var_name: str) -> str | None:
|
|
62
|
-
"""
|
|
63
|
-
Get env variable from credentials store, env or file (in order).
|
|
64
|
-
|
|
65
|
-
Parameters
|
|
66
|
-
----------
|
|
67
|
-
var_name : str
|
|
68
|
-
Environment variable name.
|
|
69
|
-
|
|
70
|
-
Returns
|
|
71
|
-
-------
|
|
72
|
-
str | None
|
|
73
|
-
Environment variable value.
|
|
74
|
-
"""
|
|
75
|
-
var = self.get_credential(var_name)
|
|
76
|
-
if var is None:
|
|
77
|
-
var = self.load_from_env(var_name)
|
|
78
|
-
if var is None:
|
|
79
|
-
var = self.load_from_file(var_name)
|
|
80
|
-
return var
|
|
81
|
-
|
|
82
|
-
def load_from_env(self, var: str) -> str | None:
|
|
83
|
-
"""
|
|
84
|
-
Load variable from env.
|
|
85
|
-
|
|
86
|
-
Parameters
|
|
87
|
-
----------
|
|
88
|
-
var : str
|
|
89
|
-
Environment variable name.
|
|
90
|
-
|
|
91
|
-
Returns
|
|
92
|
-
-------
|
|
93
|
-
str | None
|
|
94
|
-
Environment variable value.
|
|
95
|
-
"""
|
|
96
|
-
env_var = os.getenv(var)
|
|
97
|
-
if env_var != "":
|
|
98
|
-
return env_var
|
|
99
|
-
|
|
100
|
-
def load_from_file(self, var: str) -> str | None:
|
|
101
|
-
"""
|
|
102
|
-
Load variable from config file.
|
|
103
|
-
|
|
104
|
-
Parameters
|
|
105
|
-
----------
|
|
106
|
-
var : str
|
|
107
|
-
Environment variable name.
|
|
108
|
-
|
|
109
|
-
Returns
|
|
110
|
-
-------
|
|
111
|
-
str | None
|
|
112
|
-
Environment variable value.
|
|
113
|
-
"""
|
|
114
|
-
self._environment = read_env_from_file()
|
|
115
|
-
return load_from_file(var)
|
|
116
|
-
|
|
117
|
-
def write_env(self, key_to_include: list[str] | None = None) -> None:
|
|
118
|
-
"""
|
|
119
|
-
Write the env variables to the .dhcore file.
|
|
120
|
-
It will overwrite any existing env variables.
|
|
121
|
-
|
|
122
|
-
Parameters
|
|
123
|
-
----------
|
|
124
|
-
key_to_include : list[str]
|
|
125
|
-
List of keys to include.
|
|
126
|
-
|
|
127
|
-
Returns
|
|
128
|
-
-------
|
|
129
|
-
None
|
|
130
|
-
"""
|
|
131
|
-
if key_to_include is None:
|
|
132
|
-
key_to_include = []
|
|
133
|
-
creds = self.get_credential_list(key_to_include)
|
|
134
|
-
write_config(creds, self._environment)
|
|
135
|
-
|
|
136
|
-
##############################
|
|
137
|
-
# Credentials store methods
|
|
138
|
-
##############################
|
|
139
|
-
|
|
140
|
-
def set_credential(self, key: str, value: str) -> None:
|
|
141
|
-
"""
|
|
142
|
-
Register a credential value.
|
|
143
|
-
|
|
144
|
-
Parameters
|
|
145
|
-
----------
|
|
146
|
-
key : str
|
|
147
|
-
The key.
|
|
148
|
-
value : str
|
|
149
|
-
The value.
|
|
150
|
-
|
|
151
|
-
Returns
|
|
152
|
-
-------
|
|
153
|
-
None
|
|
154
|
-
"""
|
|
155
|
-
self._creds_store.set(self._environment, key, value)
|
|
156
|
-
|
|
157
|
-
def get_credential(self, key: str) -> dict:
|
|
158
|
-
"""
|
|
159
|
-
Get single credential value from key.
|
|
160
|
-
|
|
161
|
-
Parameters
|
|
162
|
-
----------
|
|
163
|
-
key : str
|
|
164
|
-
The key.
|
|
165
|
-
|
|
166
|
-
Returns
|
|
167
|
-
-------
|
|
168
|
-
dict
|
|
169
|
-
The credential.
|
|
170
|
-
"""
|
|
171
|
-
return self._creds_store.get(self._environment, key)
|
|
172
|
-
|
|
173
|
-
def get_all_credentials(self) -> dict:
|
|
174
|
-
"""
|
|
175
|
-
Get all the credentials from the current credentials set.
|
|
176
|
-
|
|
177
|
-
Returns
|
|
178
|
-
-------
|
|
179
|
-
dict
|
|
180
|
-
The credentials.
|
|
181
|
-
"""
|
|
182
|
-
return self._creds_store.get_all(self._environment)
|
|
183
|
-
|
|
184
|
-
def get_credential_list(self, keys: list[str]) -> list[str]:
|
|
185
|
-
"""
|
|
186
|
-
Get the list of credentials.
|
|
187
|
-
|
|
188
|
-
Parameters
|
|
189
|
-
----------
|
|
190
|
-
keys : list[str]
|
|
191
|
-
The list of keys.
|
|
192
|
-
|
|
193
|
-
Returns
|
|
194
|
-
-------
|
|
195
|
-
list[str]
|
|
196
|
-
The list of credentials.
|
|
197
|
-
"""
|
|
198
|
-
return {k: v for k, v in self.get_all_credentials().items() if k in keys}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
# Define global configurator
|
|
202
|
-
configurator = EnvConfigurator()
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class CredentialsStore:
|
|
9
|
-
"""
|
|
10
|
-
Credentials store to store and retrieve credentials.
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
def __init__(self) -> None:
|
|
14
|
-
self._credentials: dict[str, dict] = {}
|
|
15
|
-
|
|
16
|
-
def set(self, profile: str, key: str, value: str) -> None:
|
|
17
|
-
"""
|
|
18
|
-
Set credentials.
|
|
19
|
-
|
|
20
|
-
Parameters
|
|
21
|
-
----------
|
|
22
|
-
profile : str
|
|
23
|
-
The profile of the credentials.
|
|
24
|
-
key : str
|
|
25
|
-
The key of the credentials.
|
|
26
|
-
value : str
|
|
27
|
-
The value of the credentials.
|
|
28
|
-
|
|
29
|
-
Returns
|
|
30
|
-
-------
|
|
31
|
-
None
|
|
32
|
-
"""
|
|
33
|
-
if profile not in self._credentials:
|
|
34
|
-
self._credentials[profile] = {}
|
|
35
|
-
self._credentials[profile][key] = value
|
|
36
|
-
|
|
37
|
-
def get(self, profile: str, key: str) -> str | None:
|
|
38
|
-
"""
|
|
39
|
-
Get credentials.
|
|
40
|
-
|
|
41
|
-
Parameters
|
|
42
|
-
----------
|
|
43
|
-
profile : str
|
|
44
|
-
The profile of the credentials.
|
|
45
|
-
key : str
|
|
46
|
-
The key of the credentials.
|
|
47
|
-
|
|
48
|
-
Returns
|
|
49
|
-
-------
|
|
50
|
-
str | None
|
|
51
|
-
The value of the credentials.
|
|
52
|
-
"""
|
|
53
|
-
return self._credentials.get(profile, {}).get(key)
|
|
54
|
-
|
|
55
|
-
def get_all(self, profile: str) -> dict[str, str]:
|
|
56
|
-
"""
|
|
57
|
-
Get all credentials.
|
|
58
|
-
|
|
59
|
-
Parameters
|
|
60
|
-
----------
|
|
61
|
-
profile : str
|
|
62
|
-
The profile of the credentials.
|
|
63
|
-
|
|
64
|
-
Returns
|
|
65
|
-
-------
|
|
66
|
-
dict[str, str]
|
|
67
|
-
The credentials.
|
|
68
|
-
"""
|
|
69
|
-
return self._credentials.get(profile, {})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
from enum import Enum
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class CredsOrigin(Enum):
|
|
11
|
-
"""
|
|
12
|
-
List credential origins.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
ENV = "env"
|
|
16
|
-
FILE = "file"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class SetCreds(Enum):
|
|
20
|
-
"""
|
|
21
|
-
List supported environments.
|
|
22
|
-
"""
|
|
23
|
-
|
|
24
|
-
DEFAULT = "__default"
|
|
25
|
-
DH_ENV = "DH_NAME"
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
from enum import Enum
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class S3StoreEnv(Enum):
|
|
11
|
-
"""
|
|
12
|
-
S3Store environment
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
ENDPOINT_URL = "AWS_ENDPOINT_URL"
|
|
16
|
-
ACCESS_KEY_ID = "AWS_ACCESS_KEY_ID"
|
|
17
|
-
SECRET_ACCESS_KEY = "AWS_SECRET_ACCESS_KEY"
|
|
18
|
-
SESSION_TOKEN = "AWS_SESSION_TOKEN"
|
|
19
|
-
REGION = "AWS_REGION"
|
|
20
|
-
SIGNATURE_VERSION = "S3_SIGNATURE_VERSION"
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
from enum import Enum
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class SqlStoreEnv(Enum):
|
|
11
|
-
"""
|
|
12
|
-
SqlStore environment
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
HOST = "DB_HOST"
|
|
16
|
-
PORT = "DB_PORT"
|
|
17
|
-
USERNAME = "DB_USERNAME"
|
|
18
|
-
PASSWORD = "DB_PASSWORD"
|
|
19
|
-
DATABASE = "DB_DATABASE"
|
|
20
|
-
PG_SCHEMA = "DB_SCHEMA"
|
digitalhub/stores/data/utils.py
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: © 2025 DSLab - Fondazione Bruno Kessler
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
from digitalhub.context.api import get_context
|
|
8
|
-
from digitalhub.stores.configurator.configurator import configurator
|
|
9
|
-
from digitalhub.stores.data.enums import StoreEnv
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def get_default_store(project: str) -> str:
|
|
13
|
-
"""
|
|
14
|
-
Get default store URI.
|
|
15
|
-
|
|
16
|
-
Parameters
|
|
17
|
-
----------
|
|
18
|
-
project : str
|
|
19
|
-
Project name.
|
|
20
|
-
|
|
21
|
-
Returns
|
|
22
|
-
-------
|
|
23
|
-
str
|
|
24
|
-
Default store URI.
|
|
25
|
-
"""
|
|
26
|
-
context = get_context(project)
|
|
27
|
-
store = context.config.get(StoreEnv.DEFAULT_FILES_STORE.value.lower())
|
|
28
|
-
if store is not None:
|
|
29
|
-
return store
|
|
30
|
-
store = configurator.load_var(StoreEnv.DEFAULT_FILES_STORE.value)
|
|
31
|
-
if store is None or store == "":
|
|
32
|
-
raise ValueError(
|
|
33
|
-
"No default store found. "
|
|
34
|
-
"Please set a default store "
|
|
35
|
-
f"in your environment (e.g. export {StoreEnv.DEFAULT_FILES_STORE.value}=) "
|
|
36
|
-
"or set it in project config."
|
|
37
|
-
)
|
|
38
|
-
return store
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|