-
Notifications
You must be signed in to change notification settings - Fork 345
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
Display download and installation completion using Reporter
#3099
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
use std::fmt::Write; | ||
use std::sync::{Arc, Mutex}; | ||
use std::time::Duration; | ||
use std::time::{Duration, Instant}; | ||
|
||
use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; | ||
use owo_colors::OwoColorize; | ||
|
@@ -11,6 +12,7 @@ use distribution_types::{ | |
}; | ||
use uv_normalize::PackageName; | ||
|
||
use crate::commands::elapsed; | ||
use crate::printer::Printer; | ||
|
||
#[derive(Debug)] | ||
|
@@ -19,6 +21,7 @@ pub(crate) struct DownloadReporter { | |
multi_progress: MultiProgress, | ||
progress: ProgressBar, | ||
bars: Arc<Mutex<Vec<ProgressBar>>>, | ||
start_time: Instant, | ||
} | ||
|
||
impl From<Printer> for DownloadReporter { | ||
|
@@ -36,6 +39,8 @@ impl From<Printer> for DownloadReporter { | |
multi_progress, | ||
progress, | ||
bars: Arc::new(Mutex::new(Vec::new())), | ||
// TODO(zanieb): Consider setting the start time on the start of the first download insteasd | ||
start_time: Instant::now(), | ||
} | ||
} | ||
} | ||
|
@@ -78,6 +83,20 @@ impl uv_installer::DownloadReporter for DownloadReporter { | |
|
||
fn on_complete(&self) { | ||
self.progress.finish_and_clear(); | ||
if let Some(length) = self.progress.length() { | ||
let s = if length == 1 { "" } else { "s" }; | ||
writeln!( | ||
self.printer.stderr(), | ||
"{}", | ||
format!( | ||
"Downloaded {} in {}", | ||
format!("{} package{}", length, s).bold(), | ||
elapsed(self.start_time.elapsed()) | ||
) | ||
.dimmed() | ||
) | ||
.unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does the progress bar implementation get around this? Do they just eat errors? |
||
}; | ||
} | ||
|
||
fn on_build_start(&self, source: &BuildableSource) -> usize { | ||
|
@@ -130,7 +149,9 @@ impl uv_installer::DownloadReporter for DownloadReporter { | |
|
||
#[derive(Debug)] | ||
pub(crate) struct InstallReporter { | ||
printer: Printer, | ||
progress: ProgressBar, | ||
start_time: Instant, | ||
} | ||
|
||
impl From<Printer> for InstallReporter { | ||
|
@@ -140,7 +161,11 @@ impl From<Printer> for InstallReporter { | |
ProgressStyle::with_template("{bar:20} [{pos}/{len}] {wide_msg:.dim}").unwrap(), | ||
); | ||
progress.set_message("Installing wheels..."); | ||
Self { progress } | ||
Self { | ||
printer, | ||
progress, | ||
start_time: Instant::now(), | ||
} | ||
} | ||
} | ||
|
||
|
@@ -160,6 +185,20 @@ impl uv_installer::InstallReporter for InstallReporter { | |
|
||
fn on_install_complete(&self) { | ||
self.progress.finish_and_clear(); | ||
if let Some(length) = self.progress.length() { | ||
let s = if length == 1 { "" } else { "s" }; | ||
writeln!( | ||
self.printer.stderr(), | ||
"{}", | ||
format!( | ||
"Installed {} in {}", | ||
format!("{} package{}", length, s).bold(), | ||
elapsed(self.start_time.elapsed()) | ||
) | ||
.dimmed() | ||
) | ||
.unwrap(); | ||
}; | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We never called this apparently.