Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress Tracker for MultipartUploader & MultipartCopy #2699

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

cintiashamsu
Copy link
Contributor

Issue #, if available:

Description of changes:
'track_upload' config option added to MultipartUploader and MultipartCopy, which allows for tracking the progress of uploads in 1/8th increments.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The strings in the return statement were over the 80 char limit
(1) Set progressThresholds[0] so that I could use array_combine on equal sized arrays
(2) I redefined progressBar in setProgressThresholds after the threshold bar is created. progressBar includes the thresholds as keys and the bar as values
(3) Removed the array_shift in the construct and now that logic is done by displayProgress
(4) Changed assertCount to check for 9 elements instead of 8
(1) testFailedUploadPrintsPartialProgressBar - upload fails at 25% then throws exception
(2) testSetProgressThresholdsThrowsException - checks non-ints
(3) testDisplayProgressThrowsException - checks non-ints
- If config option is true, the total size is sent to upload state and a threshold array is created. DisplayProgress now relies on there being a threshold array, if there is no threshold array (if config = no), nothing prints.
- the progress bar for multipart copy prints halfway for some reason, but the item is still copied (i'll fix this in the next commit)
progressBar and progressThresholds are no longer combined, so that array_key_first could be removed. progressThresholds[0] and array_shift are now used instead.
src/Multipart/UploadState.php Outdated Show resolved Hide resolved
src/Multipart/UploadState.php Outdated Show resolved Hide resolved
src/Multipart/UploadState.php Outdated Show resolved Hide resolved
src/Multipart/UploadState.php Outdated Show resolved Hide resolved
src/S3/MultipartUploadingTrait.php Outdated Show resolved Hide resolved
public function getDisplayProgress($totalUploaded)
{
if (!is_numeric($totalUploaded)) {
throw new \InvalidArgumentException('The size of the bytes being uploaded must be a number.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do a line-wrap on this like:

throw new \InvalidArgumentException(
    'The size of the bytes being uploaded must be a number.'
);

Copy link
Member

@stobrien89 stobrien89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor nit regarding line length. Otherwise LGTM!

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2023

Codecov Report

Merging #2699 (6490fa1) into master (140af6f) will decrease coverage by 2.26%.
The diff coverage is 87.50%.

❗ Current head 6490fa1 differs from pull request most recent head 367bc01. Consider uploading reports for the commit 367bc01 to get more accurate results

@@             Coverage Diff              @@
##             master    #2699      +/-   ##
============================================
- Coverage     92.42%   90.16%   -2.26%     
- Complexity     4453     4605     +152     
============================================
  Files           234      252      +18     
  Lines         11729    14167    +2438     
============================================
+ Hits          10840    12774    +1934     
- Misses          889     1393     +504     
Impacted Files Coverage Δ
src/Api/DocModel.php 0.00% <0.00%> (ø)
src/CloudFront/CloudFrontClient.php 95.45% <ø> (+77.27%) ⬆️
src/ClientResolver.php 89.93% <77.77%> (-2.75%) ⬇️
src/AwsClient.php 92.69% <83.72%> (-5.76%) ⬇️
src/Api/Serializer/JsonBody.php 97.87% <85.71%> (-2.13%) ⬇️
src/Api/Serializer/RestSerializer.php 94.28% <92.85%> (-1.45%) ⬇️
src/Api/AbstractModel.php 100.00% <100.00%> (ø)
src/Api/ErrorParser/JsonParserTrait.php 100.00% <100.00%> (ø)
src/Api/ErrorParser/JsonRpcErrorParser.php 93.75% <100.00%> (+0.41%) ⬆️
src/Api/Operation.php 100.00% <100.00%> (ø)
... and 12 more

... and 177 files with indirect coverage changes

src/S3/MultipartCopy.php Outdated Show resolved Hide resolved
src/S3/MultipartUploader.php Outdated Show resolved Hide resolved
src/Multipart/AbstractUploader.php Outdated Show resolved Hide resolved
public function setDisplayProgress($totalSize)
{
$this->setProgressThresholds($totalSize);
$this->displayProgress = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this set here? If we have made it to this function, shouldn't it already be set?

.changes/nextrelease/test.json Outdated Show resolved Hide resolved
src/Multipart/UploadState.php Show resolved Hide resolved
@stobrien89 stobrien89 force-pushed the new-feature branch 2 times, most recently from 3cf2918 to f866568 Compare July 2, 2024 22:06
@stobrien89 stobrien89 force-pushed the new-feature branch 2 times, most recently from fbec615 to 66c0f96 Compare August 20, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants