Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,21 @@ impl CommandDispatcherProcessor {
.remove(id)
.expect("got a result for a source build that was not pending");

let result = result.into_ok_or_failed();

// Notify the reporter that the solve finished.
if let Some((reporter, id)) = self
.reporter
.as_deref_mut()
.and_then(Reporter::as_backend_source_build_reporter)
.zip(env.reporter_id)
{
reporter.on_finished(id)
let failed = matches!(result, Some(Err(_)));
reporter.on_finished(id, failed)
}

// Notify the command dispatcher that the result is available.
if let Some(result) = result.into_ok_or_failed() {
if let Some(result) = result {
// We can silently ignore the result if the task was cancelled.
let _ = env.tx.send(result);
};
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_command_dispatcher/src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub trait BackendSourceBuildReporter {
);

/// Called when the operation has finished.
fn on_finished(&mut self, id: BackendSourceBuildId);
fn on_finished(&mut self, id: BackendSourceBuildId, failed: bool);
}

/// A trait that is used to report the progress of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ impl BackendSourceBuildReporter for EventReporter {
});
}

fn on_finished(&mut self, id: BackendSourceBuildId) {
fn on_finished(&mut self, id: BackendSourceBuildId, _failed: bool) {
let event = Event::BackendSourceBuildFinished { id };
eprintln!("{}", serde_json::to_string_pretty(&event).unwrap());
self.events.lock().unwrap().push(event);
Expand Down
42 changes: 34 additions & 8 deletions src/reporters/install_reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use pixi_command_dispatcher::{
use pixi_progress::ProgressBarPlacement;
use rattler::install::Transaction;
use rattler_conda_types::{PrefixRecord, RepoDataRecord};
use tokio::sync::mpsc::UnboundedReceiver;

use crate::reporters::{
download_verify_reporter::BuildDownloadVerifyReporter,
Expand All @@ -21,6 +22,7 @@ use crate::reporters::{
pub struct SyncReporter {
multi_progress: MultiProgress,
combined_inner: Arc<Mutex<CombinedInstallReporterInner>>,
build_output_receiver: Option<UnboundedReceiver<String>>,
}

impl SyncReporter {
Expand All @@ -35,6 +37,7 @@ impl SyncReporter {
Self {
multi_progress,
combined_inner,
build_output_receiver: None,
}
}

Expand Down Expand Up @@ -78,21 +81,44 @@ impl BackendSourceBuildReporter for SyncReporter {
mut backend_output_stream: Box<dyn Stream<Item = String> + Unpin + Send>,
) {
// Enable streaming of the logs from the backend
if tracing::event_enabled!(tracing::Level::INFO) {
// Stream the progress of the output to the screen.
let progress_bar = self.multi_progress.clone();
let print_backend_output = tracing::event_enabled!(tracing::Level::INFO);
// Stream the progress of the output to the screen.
let progress_bar = self.multi_progress.clone();
let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<String>();
if !print_backend_output {
self.build_output_receiver = Some(rx);
}

tokio::spawn(async move {
while let Some(line) = backend_output_stream.next().await {
if print_backend_output {
// Suspend the main progress bar while we print the line.
progress_bar.suspend(|| eprintln!("{}", line));
} else {
// Send the line to the receiver
if tx.send(line).is_err() {
// Receiver dropped, exit early
break;
}
}
}
});
}

fn on_finished(&mut self, _id: BackendSourceBuildId, failed: bool) {
let Some(mut build_output_receiver) = self.build_output_receiver.take() else {
return;
};
let progress_bar = self.multi_progress.clone();
if failed {
tokio::spawn(async move {
while let Some(line) = backend_output_stream.next().await {
while let Some(line) = build_output_receiver.recv().await {
// Suspend the main progress bar while we print the line.
progress_bar.suspend(|| eprintln!("{}", line));
}
});
}
}

fn on_finished(&mut self, _id: BackendSourceBuildId) {
// Handled by the parent of this task.
}
}

impl SourceBuildReporter for SyncReporter {
Expand Down
Loading