diff --git a/crates/uv-distribution/src/metadata/lowering.rs b/crates/uv-distribution/src/metadata/lowering.rs index 919767c6d..02934c8e5 100644 --- a/crates/uv-distribution/src/metadata/lowering.rs +++ b/crates/uv-distribution/src/metadata/lowering.rs @@ -43,7 +43,6 @@ impl LoweredRequirement { group: Option<&GroupName>, locations: &'data IndexLocations, workspace: &'data Workspace, - git_member: Option<&'data GitWorkspaceMember<'data>>, ) -> impl Iterator> + 'data { // Identify the source from the `tool.uv.sources` table. diff --git a/crates/uv-publish/src/lib.rs b/crates/uv-publish/src/lib.rs index adebe4dec..ac0fcfa14 100644 --- a/crates/uv-publish/src/lib.rs +++ b/crates/uv-publish/src/lib.rs @@ -117,9 +117,9 @@ pub enum PublishSendError { pub trait Reporter: Send + Sync + 'static { fn on_progress(&self, name: &str, id: usize); - fn on_download_start(&self, name: &str, size: Option) -> usize; - fn on_download_progress(&self, id: usize, inc: u64); - fn on_download_complete(&self, id: usize); + fn on_upload_start(&self, name: &str, size: Option) -> usize; + fn on_upload_progress(&self, id: usize, inc: u64); + fn on_upload_complete(&self, id: usize); } /// Context for using a fresh registry client for check URL requests. @@ -400,7 +400,7 @@ pub async fn upload( let retry_decision = retry_policy.should_retry(start_time, n_past_retries); if let reqwest_retry::RetryDecision::Retry { execute_after } = retry_decision { warn_user!("Transient failure while handling response for {registry}; retrying..."); - reporter.on_download_complete(idx); + reporter.on_upload_complete(idx); let duration = execute_after .duration_since(SystemTime::now()) .unwrap_or_else(|_| Duration::default()); @@ -751,9 +751,9 @@ async fn build_request( } let file = File::open(file).await?; - let idx = reporter.on_download_start(&filename.to_string(), Some(file.metadata().await?.len())); + let idx = reporter.on_upload_start(&filename.to_string(), Some(file.metadata().await?.len())); let reader = ProgressReader::new(file, move |read| { - reporter.on_download_progress(idx, read as u64); + reporter.on_upload_progress(idx, read as u64); }); // Stream wrapping puts a static lifetime requirement on the reader (so the request doesn't have // a lifetime) -> callback needs to be static -> reporter reference needs to be Arc'd. @@ -877,11 +877,11 @@ mod tests { impl Reporter for DummyReporter { fn on_progress(&self, _name: &str, _id: usize) {} - fn on_download_start(&self, _name: &str, _size: Option) -> usize { + fn on_upload_start(&self, _name: &str, _size: Option) -> usize { 0 } - fn on_download_progress(&self, _id: usize, _inc: u64) {} - fn on_download_complete(&self, _id: usize) {} + fn on_upload_progress(&self, _id: usize, _inc: u64) {} + fn on_upload_complete(&self, _id: usize) {} } /// Snapshot the data we send for an upload request for a source distribution. diff --git a/crates/uv/src/commands/reporters.rs b/crates/uv/src/commands/reporters.rs index 289e1e09a..e27286eea 100644 --- a/crates/uv/src/commands/reporters.rs +++ b/crates/uv/src/commands/reporters.rs @@ -52,7 +52,7 @@ struct BarState { /// A map of progress bars, by ID. bars: FxHashMap, /// The download size, if known, by ID. - download_size: FxHashMap>, + size: FxHashMap>, /// A monotonic counter for bar IDs. id: usize, } @@ -65,6 +65,12 @@ impl BarState { } } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum Direction { + Upload, + Download, +} + impl ProgressReporter { fn new(root: ProgressBar, multi_progress: MultiProgress, printer: Printer) -> ProgressReporter { let mode = if env::var(EnvVars::JPY_SESSION_NAME).is_ok() { @@ -145,7 +151,7 @@ impl ProgressReporter { progress.finish_with_message(message); } - fn on_download_start(&self, name: String, size: Option) -> usize { + fn on_request_start(&self, direction: Direction, name: String, size: Option) -> usize { let ProgressMode::Multi { multi_progress, state, @@ -175,14 +181,19 @@ impl ProgressReporter { .unwrap() .progress_chars("--"), ); - // If the download is larger than 1MB, show a message to indicate that this may take + // If the file is larger than 1MB, show a message to indicate that this may take // a while keeping the log concise. if multi_progress.is_hidden() && !*HAS_UV_TEST_NO_CLI_PROGRESS && size > 1024 * 1024 { let (bytes, unit) = human_readable_bytes(size); let _ = writeln!( self.printer.stderr(), "{} {} {}", - "Downloading".bold().cyan(), + match direction { + Direction::Download => "Downloading", + Direction::Upload => "Uploading", + } + .bold() + .cyan(), name, format!("({bytes:.1}{unit})").dimmed() ); @@ -194,7 +205,12 @@ impl ProgressReporter { let _ = writeln!( self.printer.stderr(), "{} {}", - "Downloading".bold().cyan(), + match direction { + Direction::Download => "Downloading", + Direction::Upload => "Uploading", + } + .bold() + .cyan(), name ); } @@ -204,11 +220,11 @@ impl ProgressReporter { let id = state.id(); state.bars.insert(id, progress); - state.download_size.insert(id, size); + state.size.insert(id, size); id } - fn on_download_progress(&self, id: usize, bytes: u64) { + fn on_request_progress(&self, id: usize, bytes: u64) { let ProgressMode::Multi { state, .. } = &self.mode else { return; }; @@ -216,7 +232,7 @@ impl ProgressReporter { state.lock().unwrap().bars[&id].inc(bytes); } - fn on_download_complete(&self, id: usize) { + fn on_request_complete(&self, direction: Direction, id: usize) { let ProgressMode::Multi { state, multi_progress, @@ -227,7 +243,7 @@ impl ProgressReporter { let mut state = state.lock().unwrap(); let progress = state.bars.remove(&id).unwrap(); - let size = state.download_size[&id]; + let size = state.size[&id]; if multi_progress.is_hidden() && !*HAS_UV_TEST_NO_CLI_PROGRESS && size.is_none_or(|size| size > 1024 * 1024) @@ -235,7 +251,12 @@ impl ProgressReporter { let _ = writeln!( self.printer.stderr(), " {} {}", - "Downloaded".bold().green(), + match direction { + Direction::Download => "Downloaded", + Direction::Upload => "Uploaded", + } + .bold() + .green(), progress.message() ); } @@ -243,6 +264,30 @@ impl ProgressReporter { progress.finish_and_clear(); } + fn on_download_progress(&self, id: usize, bytes: u64) { + self.on_request_progress(id, bytes); + } + + fn on_download_complete(&self, id: usize) { + self.on_request_complete(Direction::Download, id); + } + + fn on_download_start(&self, name: String, size: Option) -> usize { + self.on_request_start(Direction::Download, name, size) + } + + fn on_upload_progress(&self, id: usize, bytes: u64) { + self.on_request_progress(id, bytes); + } + + fn on_upload_complete(&self, id: usize) { + self.on_request_complete(Direction::Upload, id); + } + + fn on_upload_start(&self, name: String, size: Option) -> usize { + self.on_request_start(Direction::Upload, name, size) + } + fn on_checkout_start(&self, url: &Url, rev: &str) -> usize { let ProgressMode::Multi { multi_progress, @@ -584,16 +629,16 @@ impl uv_publish::Reporter for PublishReporter { self.reporter.on_download_complete(id); } - fn on_download_start(&self, name: &str, size: Option) -> usize { - self.reporter.on_download_start(name.to_string(), size) + fn on_upload_start(&self, name: &str, size: Option) -> usize { + self.reporter.on_upload_start(name.to_string(), size) } - fn on_download_progress(&self, id: usize, inc: u64) { - self.reporter.on_download_progress(id, inc); + fn on_upload_progress(&self, id: usize, inc: u64) { + self.reporter.on_upload_progress(id, inc); } - fn on_download_complete(&self, id: usize) { - self.reporter.on_download_complete(id); + fn on_upload_complete(&self, id: usize) { + self.reporter.on_upload_complete(id); } }