Skip to content

Commit

Permalink
Add min size to OCI download (#3044)
Browse files Browse the repository at this point in the history
* add min size

* logs

* log info

* swap

* min 1

* remove log
  • Loading branch information
mvpatel2000 authored Feb 21, 2024
1 parent c2a2b7b commit cda9797
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions composer/utils/object_store/oci_object_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def download_object(
filename: Union[str, pathlib.Path],
overwrite: bool = False,
callback: Optional[Callable[[int, int], None]] = None,
min_part_size: int = 128000000,
num_parts: int = 10,
):
del callback
Expand All @@ -151,11 +152,14 @@ def download_object(
object_size = 0
try:
head_object_response = self.client.head_object(self.namespace, self.bucket, object_name)
object_size = head_object_response.headers['content-length'] # pyright: ignore[reportOptionalMemberAccess]
object_size = int(head_object_response.headers['content-length']) # pyright: ignore[reportOptionalMemberAccess]
except Exception as e:
_reraise_oci_errors(self.get_uri(object_name), e)

# Calculate the part sizes
base_part_size, remainder = divmod(int(object_size), num_parts)
num_parts_from_size = max(object_size // min_part_size, 1)
num_parts = min(num_parts, num_parts_from_size)
base_part_size, remainder = divmod(object_size, num_parts)
part_sizes = [base_part_size] * num_parts
for i in range(remainder):
part_sizes[i] += 1
Expand Down

0 comments on commit cda9797

Please sign in to comment.