Skip to content

Commit

Permalink
Splitting logic into more digestable chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanFauble committed Feb 20, 2025
1 parent d6421c2 commit d1e082d
Show file tree
Hide file tree
Showing 2 changed files with 418 additions and 287 deletions.
54 changes: 29 additions & 25 deletions synapseclient/core/upload/multipart_upload_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import requests
from opentelemetry import trace
from tqdm import tqdm
from tqdm.contrib.logging import logging_redirect_tqdm

from synapseclient.api import (
AddPartResponse,
Expand Down Expand Up @@ -684,15 +685,16 @@ def part_fn(part_number: int) -> bytes:
"""Return the nth chunk of a file."""
return get_file_chunk(file_path, part_number, part_size)

return await _multipart_upload_async(
syn,
dest_file_name,
upload_request,
part_fn,
md5_fn_util,
force_restart=force_restart,
storage_str=storage_str,
)
with logging_redirect_tqdm(loggers=[syn.logger]):
return await _multipart_upload_async(
syn,
dest_file_name,
upload_request,
part_fn,
md5_fn_util,
force_restart=force_restart,
storage_str=storage_str,
)


async def _multipart_upload_async(
Expand Down Expand Up @@ -813,14 +815,15 @@ def part_fn(part_number: int) -> bytes:
part_size = get_part_size(
part_size or DEFAULT_PART_SIZE, file_size, MIN_PART_SIZE, MAX_NUMBER_OF_PARTS
)
return await _multipart_upload_async(
syn,
dest_file_name,
upload_request,
part_fn,
md5_fn_util,
force_restart=force_restart,
)
with logging_redirect_tqdm(loggers=[syn.logger]):
return await _multipart_upload_async(
syn,
dest_file_name,
upload_request,
part_fn,
md5_fn_util,
force_restart=force_restart,
)


async def multipart_copy_async(
Expand Down Expand Up @@ -864,11 +867,12 @@ async def multipart_copy_async(
"storageLocationId": storage_location_id,
}

return await _multipart_upload_async(
syn,
dest_file_name,
upload_request,
copy_part_request_body_provider_fn,
copy_md5_fn,
force_restart=force_restart,
)
with logging_redirect_tqdm(loggers=[syn.logger]):
return await _multipart_upload_async(
syn,
dest_file_name,
upload_request,
copy_part_request_body_provider_fn,
copy_md5_fn,
force_restart=force_restart,
)
Loading

0 comments on commit d1e082d

Please sign in to comment.