Skip to content

Commit

Permalink
fix: multipart uploads broken by progress logging
Browse files Browse the repository at this point in the history
  • Loading branch information
thundergolfer committed Jul 22, 2024
1 parent 2e0c474 commit 1b4a7b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
25 changes: 14 additions & 11 deletions modal/_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,18 +462,21 @@ def progress(
reset: Optional[bool] = False,
complete: Optional[bool] = False,
) -> Optional[TaskID]:
if task_id is not None:
if reset:
return self._reset_sub_task(task_id)
try:
if task_id is not None:
if reset:
return self._reset_sub_task(task_id)
elif complete:
return self._complete_sub_task(task_id)
elif advance is not None:
return self._advance_sub_task(task_id, advance)
elif name is not None and size is not None:
return self._add_sub_task(name, size)
elif complete:
return self._complete_sub_task(task_id)
elif advance is not None:
return self._advance_sub_task(task_id, advance)
elif name is not None and size is not None:
return self._add_sub_task(name, size)
elif complete:
return self._complete_progress()

return self._complete_progress()
except Exception as exc:
# Liberal exception handling to avoid crashing downloads and uploads.
logger.error(f"failed progress update: {exc}")
raise NotImplementedError(
"Unknown action to take with args: "
+ f"name={name} "
Expand Down
5 changes: 3 additions & 2 deletions modal/_utils/blob_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ async def safe_read():
await writer.write(chunk)
self.progress_report_cb(advance=len(chunk))

self.progress_report_cb(complete=True)

def remaining_bytes(self):
return self.segment_length - self.num_bytes_read

Expand Down Expand Up @@ -282,6 +280,9 @@ async def _blob_upload(
content_md5_b64=upload_hashes.md5_base64,
)

if progress_report_cb:
progress_report_cb(complete=True)

return blob_id


Expand Down

0 comments on commit 1b4a7b0

Please sign in to comment.