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

feat: support display download progress bar #525

Merged
merged 20 commits into from
Jan 11, 2024

Conversation

Halimao
Copy link
Contributor

@Halimao Halimao commented Nov 23, 2023

close #319

Add downloading progress bar to commands that add/install components/toolchains, now we could know wether the executable is still doing work when we met with low bandwidth/slow internet speeds.

See following pictures
image

image

@Halimao
Copy link
Contributor Author

Halimao commented Dec 1, 2023

@sdankel GM sir, looking forward for your review~

@sdankel
Copy link
Member

sdankel commented Dec 1, 2023

Thanks for this! How does it look in the log output (~/.fuelup/log/)? It would be nice to be able to log everything the user sees. This crate may be useful.

@Halimao
Copy link
Contributor Author

Halimao commented Dec 4, 2023

Thanks for this! How does it look in the log output (~/.fuelup/log/)? It would be nice to be able to log everything the user sees. This crate may be useful.

Hi @sdankel , thanks for your review. Currently, progress bar won't be wrote to log file now. As for crate "tracing-indicatif", I didn't find the way to writting progress bar into file, neither through the documents, nor from the source code. I tried some way, but failed.

What would you like to see in the log file, could I make it another way, something like recording the final status about the progress bar?

@Halimao
Copy link
Contributor Author

Halimao commented Dec 12, 2023

Thanks for this! How does it look in the log output (~/.fuelup/log/)? It would be nice to be able to log everything the user sees. This crate may be useful.

@sdankel GM sir, writting progress bar to log file has implemented. Now it will show progress bar in log file after download success or failure.
image

src/download.rs Outdated Show resolved Hide resolved
src/download.rs Outdated Show resolved Hide resolved
Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

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

Tested this out and it's looking good! It makes me think there's a lot more we could do to improve the look and feel of fuelup with spinners and multiline progress bars (if we download in parallel). Left a few comments.

src/download.rs Outdated Show resolved Hide resolved
src/download.rs Outdated Show resolved Hide resolved
downloaded_size += bytes_read as u64;
progress_bar.set_position(downloaded_size);
}
progress_bar.finish_with_message("Download complete");
Copy link
Member

Choose a reason for hiding this comment

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

I think this shows that the download completed even if there was an error. Could you add a unit test where it fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tested in local, when download encount error, won't show "download completed"

src/download.rs Outdated
HumanDuration(progress_bar.eta()),
progress_bar.message(),
);
error!("Something went wrong writing data: {}", e)
Copy link
Member

Choose a reason for hiding this comment

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

Could we still log the path that it failed to write to? I think this should still be a bail! so that we exit if the download failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

src/download.rs Outdated Show resolved Hide resolved
src/download.rs Outdated Show resolved Hide resolved
src/download.rs Outdated
len, body,
);
let res = s.parse::<Response>().unwrap();
assert!(write_response_with_progress_bar(res, &mut mock_writer, String::new()).is_ok());
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe that we need to assert or is_ok() here, no?
If the call fails then the panic will be triggered and the test will fail as expected, or am I misunderstanding?

Copy link
Contributor Author

@Halimao Halimao Dec 20, 2023

Choose a reason for hiding this comment

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

anyhow::bail! doesn't triigger panic
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or we can remove [should_panic], just use assert
image

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. If we are able to catch the exact error and assert that the specific error matches what we expect in the test then we should do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. If we are able to catch the exact error and assert that the specific error matches what we expect in the test then we should do that.

Done

@Halimao
Copy link
Contributor Author

Halimao commented Jan 5, 2024

@Braqzen @sdankel Hi sir, again for this pr, is there anything that needs to be added?

Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@sdankel sdankel merged commit 96d7fb2 into FuelLabs:master Jan 11, 2024
16 checks passed
@Halimao Halimao deleted the feat/dl-progress-bar branch January 11, 2024 11:47
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.

feat: progression indicators for component/toolchain installation
3 participants