Skip to content

Commit 9eb645e

Browse files
author
Frederick Morlock (Hinalea)
authored
Replace faulty chunk counting logic (#391)
1 parent c486182 commit 9eb645e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

gradient/commands/datasets.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
import threading
77
import uuid
8-
import json
8+
import math
99
try:
1010
import queue
1111
except ImportError:
@@ -616,12 +616,11 @@ def _put(self, session, path, url, content_type, dataset_version_id=None, key=No
616616

617617
parts = []
618618
with open(path, 'rb') as f:
619-
# we +2 the number of parts since we're doing floor
620-
# division, which will cut off any trailing part
621-
# less than the part_minsize, AND we want to 1-index
622-
# our range to match what AWS expects for part
623-
# numbers
624-
for part in range(1, (size // part_minsize) + 2):
619+
# we +1 the number of parts since we count from zero
620+
# to match what AWS expects for part numbers. We use
621+
# `ceil` to capture any remaining data less than
622+
# part_minsize at the end of upload
623+
for part in range(1, math.ceil(size / part_minsize) + 1):
625624
presigned_url_res = api_client.post(
626625
url=mpu_url,
627626
json={

0 commit comments

Comments
 (0)