digitalhub 0.9.0__py3-none-any.whl → 0.9.0b0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of digitalhub might be problematic. Click here for more details.
- digitalhub/client/_base/client.py +20 -56
- digitalhub/client/dhcore/client.py +13 -16
- digitalhub/client/dhcore/enums.py +1 -2
- digitalhub/client/dhcore/utils.py +13 -13
- digitalhub/client/local/client.py +0 -2
- digitalhub/entities/_base/entity/entity.py +4 -6
- digitalhub/entities/_base/entity/metadata.py +1 -1
- digitalhub/entities/_base/material/entity.py +1 -1
- digitalhub/entities/_base/project/entity.py +1 -1
- digitalhub/entities/_base/unversioned/entity.py +1 -2
- digitalhub/entities/_base/versioned/entity.py +1 -2
- digitalhub/entities/_operations/processor.py +2 -128
- digitalhub/entities/function/_base/entity.py +3 -3
- digitalhub/entities/run/_base/spec.py +0 -4
- digitalhub/entities/task/_base/entity.py +9 -16
- digitalhub/entities/task/_base/models.py +0 -6
- digitalhub/entities/task/_base/spec.py +0 -6
- digitalhub/entities/workflow/_base/entity.py +4 -12
- digitalhub/stores/_base/store.py +2 -6
- digitalhub/stores/local/store.py +2 -6
- digitalhub/stores/remote/store.py +2 -6
- digitalhub/stores/s3/store.py +46 -100
- digitalhub/stores/sql/store.py +2 -10
- digitalhub/utils/s3_utils.py +0 -17
- {digitalhub-0.9.0.dist-info → digitalhub-0.9.0b0.dist-info}/LICENSE.txt +1 -1
- {digitalhub-0.9.0.dist-info → digitalhub-0.9.0b0.dist-info}/METADATA +2 -2
- {digitalhub-0.9.0.dist-info → digitalhub-0.9.0b0.dist-info}/RECORD +29 -34
- digitalhub/client/_base/key_builder.py +0 -52
- digitalhub/client/dhcore/key_builder.py +0 -58
- digitalhub/client/local/key_builder.py +0 -58
- digitalhub/runtimes/enums.py +0 -12
- test/local/instances/test_validate.py +0 -55
- {digitalhub-0.9.0.dist-info → digitalhub-0.9.0b0.dist-info}/WHEEL +0 -0
- {digitalhub-0.9.0.dist-info → digitalhub-0.9.0b0.dist-info}/top_level.txt +0 -0
|
@@ -22,8 +22,6 @@ class TaskSpecFunction(TaskSpec):
|
|
|
22
22
|
envs: list[dict] | None = None,
|
|
23
23
|
secrets: list[str] | None = None,
|
|
24
24
|
profile: str | None = None,
|
|
25
|
-
runtime_class: str | None = None,
|
|
26
|
-
priority_class: str | None = None,
|
|
27
25
|
**kwargs,
|
|
28
26
|
) -> None:
|
|
29
27
|
self.function = function
|
|
@@ -35,8 +33,6 @@ class TaskSpecFunction(TaskSpec):
|
|
|
35
33
|
self.envs = envs
|
|
36
34
|
self.secrets = secrets
|
|
37
35
|
self.profile = profile
|
|
38
|
-
self.runtime_class = runtime_class
|
|
39
|
-
self.priority_class = priority_class
|
|
40
36
|
|
|
41
37
|
|
|
42
38
|
class TaskSpecWorkflow(TaskSpec):
|
|
@@ -53,8 +49,6 @@ class TaskSpecWorkflow(TaskSpec):
|
|
|
53
49
|
envs: list[dict] | None = None,
|
|
54
50
|
secrets: list[str] | None = None,
|
|
55
51
|
profile: str | None = None,
|
|
56
|
-
runtime_class: str | None = None,
|
|
57
|
-
priority_class: str | None = None,
|
|
58
52
|
**kwargs,
|
|
59
53
|
) -> None:
|
|
60
54
|
self.workflow = workflow
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
5
|
from digitalhub.entities._base.executable.entity import ExecutableEntity
|
|
6
|
-
from digitalhub.entities._commons.enums import EntityTypes
|
|
6
|
+
from digitalhub.entities._commons.enums import EntityTypes
|
|
7
7
|
from digitalhub.factory.api import get_run_kind, get_task_kind_from_action
|
|
8
8
|
from digitalhub.utils.exceptions import BackendError
|
|
9
9
|
|
|
@@ -44,7 +44,7 @@ class Workflow(ExecutableEntity):
|
|
|
44
44
|
def run(
|
|
45
45
|
self,
|
|
46
46
|
action: str,
|
|
47
|
-
wait: bool =
|
|
47
|
+
wait: bool = True,
|
|
48
48
|
log_info: bool = True,
|
|
49
49
|
**kwargs,
|
|
50
50
|
) -> Run:
|
|
@@ -55,10 +55,7 @@ class Workflow(ExecutableEntity):
|
|
|
55
55
|
----------
|
|
56
56
|
action : str
|
|
57
57
|
Action to execute.
|
|
58
|
-
|
|
59
|
-
Flag to wait for execution to finish.
|
|
60
|
-
log_info : bool
|
|
61
|
-
Flag to log information while waiting.
|
|
58
|
+
|
|
62
59
|
**kwargs : dict
|
|
63
60
|
Keyword arguments passed to Run builder.
|
|
64
61
|
|
|
@@ -79,12 +76,7 @@ class Workflow(ExecutableEntity):
|
|
|
79
76
|
raise BackendError("Cannot run workflow with local backend.")
|
|
80
77
|
|
|
81
78
|
# Run task
|
|
82
|
-
run = task.run(run_kind,
|
|
83
|
-
|
|
84
|
-
# Set as run's parent
|
|
85
|
-
run.add_relationship(Relationship.RUN_OF.value, self.key)
|
|
86
|
-
run.save()
|
|
87
|
-
|
|
79
|
+
run = task.run(run_kind, local_execution=False, **kwargs)
|
|
88
80
|
if wait:
|
|
89
81
|
return run.wait(log_info=log_info)
|
|
90
82
|
return run
|
digitalhub/stores/_base/store.py
CHANGED
|
@@ -52,17 +52,13 @@ class Store:
|
|
|
52
52
|
"""
|
|
53
53
|
|
|
54
54
|
@abstractmethod
|
|
55
|
-
def upload(self, src: str | list[str], dst: str) -> list[tuple[str, str]]:
|
|
55
|
+
def upload(self, src: str | list[str], dst: str | None = None) -> list[tuple[str, str]]:
|
|
56
56
|
"""
|
|
57
57
|
Method to upload artifact to storage.
|
|
58
58
|
"""
|
|
59
59
|
|
|
60
60
|
@abstractmethod
|
|
61
|
-
def get_file_info(
|
|
62
|
-
self,
|
|
63
|
-
root: str,
|
|
64
|
-
paths: list[tuple[str, str]],
|
|
65
|
-
) -> list[dict]:
|
|
61
|
+
def get_file_info(self, paths: list[str]) -> list[dict]:
|
|
66
62
|
"""
|
|
67
63
|
Method to get file metadata.
|
|
68
64
|
"""
|
digitalhub/stores/local/store.py
CHANGED
|
@@ -61,7 +61,7 @@ class LocalStore(Store):
|
|
|
61
61
|
"""
|
|
62
62
|
raise StoreError("Local store does not support download.")
|
|
63
63
|
|
|
64
|
-
def upload(self, src: str | list[str], dst: str) -> list[tuple[str, str]]:
|
|
64
|
+
def upload(self, src: str | list[str], dst: str | None = None) -> list[tuple[str, str]]:
|
|
65
65
|
"""
|
|
66
66
|
Upload an artifact to storage.
|
|
67
67
|
|
|
@@ -72,11 +72,7 @@ class LocalStore(Store):
|
|
|
72
72
|
"""
|
|
73
73
|
raise StoreError("Local store does not support upload.")
|
|
74
74
|
|
|
75
|
-
def get_file_info(
|
|
76
|
-
self,
|
|
77
|
-
root: str,
|
|
78
|
-
paths: list[tuple[str, str]],
|
|
79
|
-
) -> list[dict]:
|
|
75
|
+
def get_file_info(self, paths: list[str]) -> list[dict]:
|
|
80
76
|
"""
|
|
81
77
|
Method to get file metadata.
|
|
82
78
|
|
|
@@ -69,7 +69,7 @@ class RemoteStore(Store):
|
|
|
69
69
|
|
|
70
70
|
return self._download_file(root, dst, overwrite)
|
|
71
71
|
|
|
72
|
-
def upload(self, src: str | list[str], dst: str) -> list[tuple[str, str]]:
|
|
72
|
+
def upload(self, src: str | list[str], dst: str | None = None) -> list[tuple[str, str]]:
|
|
73
73
|
"""
|
|
74
74
|
Upload an artifact to storage.
|
|
75
75
|
|
|
@@ -80,11 +80,7 @@ class RemoteStore(Store):
|
|
|
80
80
|
"""
|
|
81
81
|
raise StoreError("Remote HTTP store does not support upload.")
|
|
82
82
|
|
|
83
|
-
def get_file_info(
|
|
84
|
-
self,
|
|
85
|
-
root: str,
|
|
86
|
-
paths: list[tuple[str, str]],
|
|
87
|
-
) -> list[dict]:
|
|
83
|
+
def get_file_info(self, paths: list[str]) -> list[dict]:
|
|
88
84
|
"""
|
|
89
85
|
Get file information from HTTP(s) storage.
|
|
90
86
|
|
digitalhub/stores/s3/store.py
CHANGED
|
@@ -13,7 +13,6 @@ from digitalhub.readers.api import get_reader_by_object
|
|
|
13
13
|
from digitalhub.stores._base.store import Store, StoreConfig
|
|
14
14
|
from digitalhub.utils.exceptions import StoreError
|
|
15
15
|
from digitalhub.utils.file_utils import get_file_info_from_s3, get_file_mime_type
|
|
16
|
-
from digitalhub.utils.s3_utils import get_bucket_name
|
|
17
16
|
|
|
18
17
|
# Type aliases
|
|
19
18
|
S3Client = Type["botocore.client.S3"]
|
|
@@ -77,7 +76,7 @@ class S3Store(Store):
|
|
|
77
76
|
str
|
|
78
77
|
Destination path of the downloaded artifact.
|
|
79
78
|
"""
|
|
80
|
-
client, bucket = self._check_factory(
|
|
79
|
+
client, bucket = self._check_factory()
|
|
81
80
|
|
|
82
81
|
# Build destination directory
|
|
83
82
|
if dst.suffix == "":
|
|
@@ -127,18 +126,14 @@ class S3Store(Store):
|
|
|
127
126
|
return str(Path(dst, trees[0]))
|
|
128
127
|
return str(dst)
|
|
129
128
|
|
|
130
|
-
def upload(
|
|
131
|
-
self,
|
|
132
|
-
src: str | list[str],
|
|
133
|
-
dst: str,
|
|
134
|
-
) -> list[tuple[str, str]]:
|
|
129
|
+
def upload(self, src: str | list[str], dst: str | None = None) -> list[tuple[str, str]]:
|
|
135
130
|
"""
|
|
136
131
|
Upload an artifact to storage.
|
|
137
132
|
|
|
138
133
|
Parameters
|
|
139
134
|
----------
|
|
140
|
-
src : str
|
|
141
|
-
|
|
135
|
+
src : str
|
|
136
|
+
List of sources.
|
|
142
137
|
dst : str
|
|
143
138
|
The destination of the artifact on storage.
|
|
144
139
|
|
|
@@ -148,11 +143,18 @@ class S3Store(Store):
|
|
|
148
143
|
Returns the list of destination and source paths of the uploaded artifacts.
|
|
149
144
|
"""
|
|
150
145
|
# Destination handling
|
|
151
|
-
key = self._get_key(dst)
|
|
152
146
|
|
|
153
|
-
#
|
|
154
|
-
|
|
155
|
-
if
|
|
147
|
+
# If no destination is provided, build key from source
|
|
148
|
+
# Otherwise build key from destination
|
|
149
|
+
if dst is None:
|
|
150
|
+
raise StoreError(
|
|
151
|
+
"Destination must be provided. If source is a list of files or a directory, destination must be a partition, e.g. 's3://bucket/partition/' otherwise a destination key, e.g. 's3://bucket/key'"
|
|
152
|
+
)
|
|
153
|
+
else:
|
|
154
|
+
dst = self._get_key(dst)
|
|
155
|
+
|
|
156
|
+
# Source handling
|
|
157
|
+
if not isinstance(src, list):
|
|
156
158
|
self._check_local_src(src)
|
|
157
159
|
src_is_dir = Path(src).is_dir()
|
|
158
160
|
else:
|
|
@@ -163,31 +165,21 @@ class S3Store(Store):
|
|
|
163
165
|
src = src[0]
|
|
164
166
|
|
|
165
167
|
# If source is a directory, destination must be a partition
|
|
166
|
-
if (src_is_dir or
|
|
167
|
-
raise StoreError(
|
|
168
|
-
"If source is a list of files or a directory, "
|
|
169
|
-
"destination must be a partition, e.g. 's3://bucket/partition/'"
|
|
170
|
-
)
|
|
171
|
-
|
|
172
|
-
# S3 client
|
|
173
|
-
client, bucket = self._check_factory(dst)
|
|
168
|
+
if (src_is_dir or isinstance(src, list)) and not dst.endswith("/"):
|
|
169
|
+
raise StoreError("Destination must be a partition if the source is a directory or a list of files.")
|
|
174
170
|
|
|
175
171
|
# Directory
|
|
176
172
|
if src_is_dir:
|
|
177
|
-
return self._upload_dir(src,
|
|
173
|
+
return self._upload_dir(src, dst)
|
|
178
174
|
|
|
179
175
|
# List of files
|
|
180
|
-
elif
|
|
181
|
-
return self._upload_file_list(src,
|
|
176
|
+
elif isinstance(src, list):
|
|
177
|
+
return self._upload_file_list(src, dst)
|
|
182
178
|
|
|
183
179
|
# Single file
|
|
184
|
-
return self._upload_single_file(src,
|
|
180
|
+
return self._upload_single_file(src, dst)
|
|
185
181
|
|
|
186
|
-
def upload_fileobject(
|
|
187
|
-
self,
|
|
188
|
-
src: BytesIO,
|
|
189
|
-
dst: str,
|
|
190
|
-
) -> str:
|
|
182
|
+
def upload_fileobject(self, src: BytesIO, dst: str) -> str:
|
|
191
183
|
"""
|
|
192
184
|
Upload an BytesIO to S3 based storage.
|
|
193
185
|
|
|
@@ -196,23 +188,18 @@ class S3Store(Store):
|
|
|
196
188
|
src : BytesIO
|
|
197
189
|
The source object to be persisted.
|
|
198
190
|
dst : str
|
|
199
|
-
The destination
|
|
191
|
+
The destination partition for the artifact.
|
|
200
192
|
|
|
201
193
|
Returns
|
|
202
194
|
-------
|
|
203
195
|
str
|
|
204
196
|
S3 key of the uploaded artifact.
|
|
205
197
|
"""
|
|
206
|
-
client, bucket = self._check_factory(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return f"s3://{bucket}/{key}"
|
|
198
|
+
client, bucket = self._check_factory()
|
|
199
|
+
self._upload_fileobject(src, dst, client, bucket)
|
|
200
|
+
return f"s3://{bucket}/{dst}"
|
|
210
201
|
|
|
211
|
-
def get_file_info(
|
|
212
|
-
self,
|
|
213
|
-
root: str,
|
|
214
|
-
paths: list[tuple[str, str]],
|
|
215
|
-
) -> list[dict]:
|
|
202
|
+
def get_file_info(self, paths: list[tuple[str, str]]) -> list[dict]:
|
|
216
203
|
"""
|
|
217
204
|
Method to get file metadata.
|
|
218
205
|
|
|
@@ -226,7 +213,7 @@ class S3Store(Store):
|
|
|
226
213
|
list[dict]
|
|
227
214
|
Returns files metadata.
|
|
228
215
|
"""
|
|
229
|
-
client, bucket = self._check_factory(
|
|
216
|
+
client, bucket = self._check_factory()
|
|
230
217
|
|
|
231
218
|
infos = []
|
|
232
219
|
for i in paths:
|
|
@@ -277,13 +264,7 @@ class S3Store(Store):
|
|
|
277
264
|
# Download file
|
|
278
265
|
client.download_file(bucket, key, dst_pth)
|
|
279
266
|
|
|
280
|
-
def _upload_dir(
|
|
281
|
-
self,
|
|
282
|
-
src: str,
|
|
283
|
-
dst: str,
|
|
284
|
-
client: S3Client,
|
|
285
|
-
bucket: str,
|
|
286
|
-
) -> list[tuple[str, str]]:
|
|
267
|
+
def _upload_dir(self, src: str, dst: str) -> list[tuple[str, str]]:
|
|
287
268
|
"""
|
|
288
269
|
Upload directory to storage.
|
|
289
270
|
|
|
@@ -293,16 +274,14 @@ class S3Store(Store):
|
|
|
293
274
|
List of sources.
|
|
294
275
|
dst : str
|
|
295
276
|
The destination of the artifact on storage.
|
|
296
|
-
client : S3Client
|
|
297
|
-
The S3 client object.
|
|
298
|
-
bucket : str
|
|
299
|
-
The name of the S3 bucket.
|
|
300
277
|
|
|
301
278
|
Returns
|
|
302
279
|
-------
|
|
303
280
|
list[tuple[str, str]]
|
|
304
281
|
Returns the list of destination and source paths of the uploaded artifacts.
|
|
305
282
|
"""
|
|
283
|
+
client, bucket = self._check_factory()
|
|
284
|
+
|
|
306
285
|
# Get list of files
|
|
307
286
|
src_pth = Path(src)
|
|
308
287
|
files = [i for i in src_pth.rglob("*") if i.is_file()]
|
|
@@ -320,13 +299,7 @@ class S3Store(Store):
|
|
|
320
299
|
paths.append((k, str(f.relative_to(src_pth))))
|
|
321
300
|
return paths
|
|
322
301
|
|
|
323
|
-
def _upload_file_list(
|
|
324
|
-
self,
|
|
325
|
-
src: list[str],
|
|
326
|
-
dst: str,
|
|
327
|
-
client: S3Client,
|
|
328
|
-
bucket: str,
|
|
329
|
-
) -> list[tuple[str, str]]:
|
|
302
|
+
def _upload_file_list(self, src: list[str], dst: str) -> list[tuple[str, str]]:
|
|
330
303
|
"""
|
|
331
304
|
Upload list of files to storage.
|
|
332
305
|
|
|
@@ -336,16 +309,13 @@ class S3Store(Store):
|
|
|
336
309
|
List of sources.
|
|
337
310
|
dst : str
|
|
338
311
|
The destination of the artifact on storage.
|
|
339
|
-
client : S3Client
|
|
340
|
-
The S3 client object.
|
|
341
|
-
bucket : str
|
|
342
|
-
The name of the S3 bucket.
|
|
343
312
|
|
|
344
313
|
Returns
|
|
345
314
|
-------
|
|
346
315
|
list[tuple[str, str]]
|
|
347
316
|
Returns the list of destination and source paths of the uploaded artifacts.
|
|
348
317
|
"""
|
|
318
|
+
client, bucket = self._check_factory()
|
|
349
319
|
files = src
|
|
350
320
|
keys = []
|
|
351
321
|
for i in files:
|
|
@@ -360,13 +330,7 @@ class S3Store(Store):
|
|
|
360
330
|
paths.append((k, Path(f).name))
|
|
361
331
|
return paths
|
|
362
332
|
|
|
363
|
-
def _upload_single_file(
|
|
364
|
-
self,
|
|
365
|
-
src: str,
|
|
366
|
-
dst: str,
|
|
367
|
-
client: S3Client,
|
|
368
|
-
bucket: str,
|
|
369
|
-
) -> str:
|
|
333
|
+
def _upload_single_file(self, src: str, dst: str) -> str:
|
|
370
334
|
"""
|
|
371
335
|
Upload a single file to storage.
|
|
372
336
|
|
|
@@ -376,16 +340,14 @@ class S3Store(Store):
|
|
|
376
340
|
List of sources.
|
|
377
341
|
dst : str
|
|
378
342
|
The destination of the artifact on storage.
|
|
379
|
-
client : S3Client
|
|
380
|
-
The S3 client object.
|
|
381
|
-
bucket : str
|
|
382
|
-
The name of the S3 bucket.
|
|
383
343
|
|
|
384
344
|
Returns
|
|
385
345
|
-------
|
|
386
346
|
str
|
|
387
347
|
Returns the list of destination and source paths of the uploaded artifacts.
|
|
388
348
|
"""
|
|
349
|
+
client, bucket = self._check_factory()
|
|
350
|
+
|
|
389
351
|
if dst.endswith("/"):
|
|
390
352
|
dst = f"{dst.removeprefix('/')}{Path(src).name}"
|
|
391
353
|
|
|
@@ -395,12 +357,7 @@ class S3Store(Store):
|
|
|
395
357
|
return [(dst, name)]
|
|
396
358
|
|
|
397
359
|
@staticmethod
|
|
398
|
-
def _upload_file(
|
|
399
|
-
src: str,
|
|
400
|
-
key: str,
|
|
401
|
-
client: S3Client,
|
|
402
|
-
bucket: str,
|
|
403
|
-
) -> None:
|
|
360
|
+
def _upload_file(src: str, key: str, client: S3Client, bucket: str) -> None:
|
|
404
361
|
"""
|
|
405
362
|
Upload a file to S3 based storage. The function checks if the
|
|
406
363
|
bucket is accessible.
|
|
@@ -427,12 +384,7 @@ class S3Store(Store):
|
|
|
427
384
|
client.upload_file(Filename=src, Bucket=bucket, Key=key, ExtraArgs=extra_args)
|
|
428
385
|
|
|
429
386
|
@staticmethod
|
|
430
|
-
def _upload_fileobject(
|
|
431
|
-
fileobj: BytesIO,
|
|
432
|
-
key: str,
|
|
433
|
-
client: S3Client,
|
|
434
|
-
bucket: str,
|
|
435
|
-
) -> None:
|
|
387
|
+
def _upload_fileobject(fileobj: BytesIO, key: str, client: S3Client, bucket: str) -> None:
|
|
436
388
|
"""
|
|
437
389
|
Upload a fileobject to S3 based storage. The function checks if the bucket is accessible.
|
|
438
390
|
|
|
@@ -457,13 +409,7 @@ class S3Store(Store):
|
|
|
457
409
|
# Datastore methods
|
|
458
410
|
##############################
|
|
459
411
|
|
|
460
|
-
def write_df(
|
|
461
|
-
self,
|
|
462
|
-
df: Any,
|
|
463
|
-
dst: str,
|
|
464
|
-
extension: str | None = None,
|
|
465
|
-
**kwargs,
|
|
466
|
-
) -> str:
|
|
412
|
+
def write_df(self, df: Any, dst: str, extension: str | None = None, **kwargs) -> str:
|
|
467
413
|
"""
|
|
468
414
|
Write a dataframe to S3 based storage. Kwargs are passed to df.to_parquet().
|
|
469
415
|
|
|
@@ -473,8 +419,6 @@ class S3Store(Store):
|
|
|
473
419
|
The dataframe.
|
|
474
420
|
dst : str
|
|
475
421
|
The destination path on S3 based storage.
|
|
476
|
-
extension : str
|
|
477
|
-
The extension of the file.
|
|
478
422
|
**kwargs : dict
|
|
479
423
|
Keyword arguments.
|
|
480
424
|
|
|
@@ -486,13 +430,15 @@ class S3Store(Store):
|
|
|
486
430
|
fileobj = BytesIO()
|
|
487
431
|
reader = get_reader_by_object(df)
|
|
488
432
|
reader.write_df(df, fileobj, extension=extension, **kwargs)
|
|
489
|
-
|
|
433
|
+
|
|
434
|
+
key = self._get_key(dst)
|
|
435
|
+
return self.upload_fileobject(fileobj, key)
|
|
490
436
|
|
|
491
437
|
##############################
|
|
492
438
|
# Helper methods
|
|
493
439
|
##############################
|
|
494
440
|
|
|
495
|
-
def _get_bucket(self
|
|
441
|
+
def _get_bucket(self) -> str:
|
|
496
442
|
"""
|
|
497
443
|
Get the name of the S3 bucket from the URI.
|
|
498
444
|
|
|
@@ -501,7 +447,7 @@ class S3Store(Store):
|
|
|
501
447
|
str
|
|
502
448
|
The name of the S3 bucket.
|
|
503
449
|
"""
|
|
504
|
-
return
|
|
450
|
+
return str(self.config.bucket_name)
|
|
505
451
|
|
|
506
452
|
def _get_client(self) -> S3Client:
|
|
507
453
|
"""
|
|
@@ -519,7 +465,7 @@ class S3Store(Store):
|
|
|
519
465
|
}
|
|
520
466
|
return boto3.client("s3", **cfg)
|
|
521
467
|
|
|
522
|
-
def _check_factory(self
|
|
468
|
+
def _check_factory(self) -> tuple[S3Client, str]:
|
|
523
469
|
"""
|
|
524
470
|
Check if the S3 bucket is accessible by sending a head_bucket request.
|
|
525
471
|
|
|
@@ -529,7 +475,7 @@ class S3Store(Store):
|
|
|
529
475
|
A tuple containing the S3 client object and the name of the S3 bucket.
|
|
530
476
|
"""
|
|
531
477
|
client = self._get_client()
|
|
532
|
-
bucket = self._get_bucket(
|
|
478
|
+
bucket = self._get_bucket()
|
|
533
479
|
self._check_access_to_storage(client, bucket)
|
|
534
480
|
return client, bucket
|
|
535
481
|
|
digitalhub/stores/sql/store.py
CHANGED
|
@@ -99,11 +99,7 @@ class SqlStore(Store):
|
|
|
99
99
|
table = self._get_table_name(root)
|
|
100
100
|
return self._download_table(schema, table, str(dst))
|
|
101
101
|
|
|
102
|
-
def upload(
|
|
103
|
-
self,
|
|
104
|
-
src: str | list[str],
|
|
105
|
-
dst: str,
|
|
106
|
-
) -> list[tuple[str, str]]:
|
|
102
|
+
def upload(self, src: str | list[str], dst: str | None = None) -> list[tuple[str, str]]:
|
|
107
103
|
"""
|
|
108
104
|
Upload an artifact to storage.
|
|
109
105
|
|
|
@@ -114,11 +110,7 @@ class SqlStore(Store):
|
|
|
114
110
|
"""
|
|
115
111
|
raise StoreError("SQL store does not support upload.")
|
|
116
112
|
|
|
117
|
-
def get_file_info(
|
|
118
|
-
self,
|
|
119
|
-
root: str,
|
|
120
|
-
paths: list[tuple[str, str]],
|
|
121
|
-
) -> list[dict]:
|
|
113
|
+
def get_file_info(self, paths: list[str]) -> list[dict]:
|
|
122
114
|
"""
|
|
123
115
|
Get file information from SQL based storage.
|
|
124
116
|
|
digitalhub/utils/s3_utils.py
CHANGED
|
@@ -7,23 +7,6 @@ from urllib.parse import urlparse
|
|
|
7
7
|
from boto3 import client as boto3_client
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def get_bucket_name(path: str) -> str:
|
|
11
|
-
"""
|
|
12
|
-
Get bucket name from path.
|
|
13
|
-
|
|
14
|
-
Parameters
|
|
15
|
-
----------
|
|
16
|
-
path : str
|
|
17
|
-
The source path to get the key from.
|
|
18
|
-
|
|
19
|
-
Returns
|
|
20
|
-
-------
|
|
21
|
-
str
|
|
22
|
-
The bucket name.
|
|
23
|
-
"""
|
|
24
|
-
return urlparse(path).netloc
|
|
25
|
-
|
|
26
|
-
|
|
27
10
|
def get_bucket_and_key(path: str) -> tuple[str, str]:
|
|
28
11
|
"""
|
|
29
12
|
Get bucket and key from path.
|
|
@@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: digitalhub
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.0b0
|
|
4
4
|
Summary: Python SDK for Digitalhub
|
|
5
5
|
Author-email: Fondazione Bruno Kessler <dslab@fbk.eu>, Matteo Martini <mmartini@fbk.eu>
|
|
6
6
|
License: Apache License
|
|
@@ -191,7 +191,7 @@ License: Apache License
|
|
|
191
191
|
same "printed page" as the copyright notice for easier
|
|
192
192
|
identification within third-party archives.
|
|
193
193
|
|
|
194
|
-
Copyright
|
|
194
|
+
Copyright [yyyy] [name of copyright owner]
|
|
195
195
|
|
|
196
196
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
197
197
|
you may not use this file except in compliance with the License.
|