Skip to content

Commit 396336c

Browse files
committed
use parameter to be compatible with CEPH S3
1 parent 1d581a9 commit 396336c

File tree

2 files changed

+17
-9
lines changed
  • packages/aws-library/src/aws_library/s3
  • services/dask-sidecar/src/simcore_service_dask_sidecar

2 files changed

+17
-9
lines changed

packages/aws-library/src/aws_library/s3/_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ async def create(
113113
aws_access_key_id=settings.S3_ACCESS_KEY,
114114
aws_secret_access_key=settings.S3_SECRET_KEY,
115115
region_name=settings.S3_REGION,
116-
config=Config(signature_version="s3v4"),
116+
config=Config(
117+
signature_version="s3v4",
118+
request_checksum_calculation="when_required",
119+
),
117120
)
118121
assert isinstance(session_client, ClientCreatorContext) # nosec
119122

services/dask-sidecar/src/simcore_service_dask_sidecar/file_utils.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _file_progress_cb(
3939
asyncio.run_coroutine_threadsafe(
4040
log_publishing_cb(
4141
f"{text_prefix}"
42-
f" {100.0 * float(value or 0)/float(size or 1):.1f}%"
42+
f" {100.0 * float(value or 0) / float(size or 1):.1f}%"
4343
f" ({ByteSize(value).human_readable() if value else 0} / {ByteSize(size).human_readable() if size else 'NaN'})",
4444
logging.DEBUG,
4545
),
@@ -53,6 +53,7 @@ def _file_progress_cb(
5353
class ClientKWArgsDict(TypedDict, total=False):
5454
endpoint_url: str
5555
region_name: str
56+
config: dict[str, str] # For botocore config options
5657

5758

5859
class S3FsSettingsDict(TypedDict):
@@ -68,7 +69,7 @@ def _s3fs_settings_from_s3_settings(s3_settings: S3Settings) -> S3FsSettingsDict
6869
s3fs_settings: S3FsSettingsDict = {
6970
"key": s3_settings.S3_ACCESS_KEY,
7071
"secret": s3_settings.S3_SECRET_KEY,
71-
"client_kwargs": {},
72+
"client_kwargs": {"config": {"request_checksum_calculation": "when_required"}},
7273
}
7374
if s3_settings.S3_REGION != _DEFAULT_AWS_REGION:
7475
# NOTE: see https://github.com/boto/boto3/issues/125 why this is so... (sic)
@@ -96,26 +97,30 @@ async def _copy_file(
9697
):
9798
src_storage_kwargs = src_storage_cfg or {}
9899
dst_storage_kwargs = dst_storage_cfg or {}
99-
with fsspec.open(
100-
f"{src_url}", mode="rb", **src_storage_kwargs
101-
) as src_fp, fsspec.open(f"{dst_url}", "wb", **dst_storage_kwargs) as dst_fp:
100+
with (
101+
fsspec.open(f"{src_url}", mode="rb", **src_storage_kwargs) as src_fp,
102+
fsspec.open(f"{dst_url}", "wb", **dst_storage_kwargs) as dst_fp,
103+
):
102104
assert isinstance(src_fp, IOBase) # nosec
103105
assert isinstance(dst_fp, IOBase) # nosec
104106
file_size = getattr(src_fp, "size", None)
105107
data_read = True
106108
total_data_written = 0
107109
t = time.process_time()
108110
while data_read:
109-
(data_read, data_written,) = await asyncio.get_event_loop().run_in_executor(
111+
(
112+
data_read,
113+
data_written,
114+
) = await asyncio.get_event_loop().run_in_executor(
110115
None, _file_chunk_streamer, src_fp, dst_fp
111116
)
112117
elapsed_time = time.process_time() - t
113118
total_data_written += data_written or 0
114119
await log_publishing_cb(
115120
f"{text_prefix}"
116-
f" {100.0 * float(total_data_written or 0)/float(file_size or 1):.1f}%"
121+
f" {100.0 * float(total_data_written or 0) / float(file_size or 1):.1f}%"
117122
f" ({ByteSize(total_data_written).human_readable() if total_data_written else 0} / {ByteSize(file_size).human_readable() if file_size else 'NaN'})"
118-
f" [{ByteSize(total_data_written).to('MB')/elapsed_time:.2f} MBytes/s (avg)]",
123+
f" [{ByteSize(total_data_written).to('MB') / elapsed_time:.2f} MBytes/s (avg)]",
119124
logging.DEBUG,
120125
)
121126

0 commit comments

Comments
 (0)