Skip to content

Commit

Permalink
no initial message
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin Ho authored and Colin Ho committed Dec 21, 2024
1 parent 4ba1200 commit 4404309
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
9 changes: 4 additions & 5 deletions daft/runners/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,22 @@ def __init__(self) -> None:
self._maxinterval = 5.0
self.tqdm_mod = get_tqdm(False)
self.pbars: dict[int, Any] = dict()
self.bar_configs: dict[int, tuple[str, str]] = dict()
self.bar_configs: dict[int, str] = dict()
self.next_id = 0

Check warning on line 118 in daft/runners/progress_bar.py

View check run for this annotation

Codecov / codecov/patch

daft/runners/progress_bar.py#L117-L118

Added lines #L117 - L118 were not covered by tests

def make_new_bar(self, bar_format: str, initial_message: str) -> int:
def make_new_bar(self, bar_format: str) -> int:
pbar_id = self.next_id
self.next_id += 1
self.bar_configs[pbar_id] = (bar_format, initial_message)
self.bar_configs[pbar_id] = bar_format

Check warning on line 123 in daft/runners/progress_bar.py

View check run for this annotation

Codecov / codecov/patch

daft/runners/progress_bar.py#L121-L123

Added lines #L121 - L123 were not covered by tests
return pbar_id

def update_bar(self, pbar_id: int, message: str) -> None:
if pbar_id not in self.pbars:
if pbar_id not in self.bar_configs:
raise ValueError(f"No bar configuration found for id {pbar_id}")
bar_format, initial_message = self.bar_configs[pbar_id]
bar_format = self.bar_configs[pbar_id]
self.pbars[pbar_id] = self.tqdm_mod(

Check warning on line 131 in daft/runners/progress_bar.py

View check run for this annotation

Codecov / codecov/patch

daft/runners/progress_bar.py#L127-L131

Added lines #L127 - L131 were not covered by tests
bar_format=bar_format,
desc=initial_message,
position=pbar_id,
leave=False,
mininterval=1.0,
Expand Down
4 changes: 1 addition & 3 deletions src/daft-local-execution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ impl ExecutionRuntimeContext {
runtime_stats: Arc<RuntimeStatsContext>,
) -> Option<Arc<OperatorProgressBar>> {
if let Some(ref pb_manager) = self.progress_bar_manager {
let pb = pb_manager
.make_new_bar(color, prefix, show_received)
.unwrap();
let pb = pb_manager.make_new_bar(color, prefix).unwrap();
Some(Arc::new(OperatorProgressBar::new(
pb,
runtime_stats,
Expand Down
21 changes: 2 additions & 19 deletions src/daft-local-execution/src/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub trait ProgressBarManager {
&self,
color: ProgressBarColor,
prefix: &str,
show_received: bool,
) -> DaftResult<Box<dyn ProgressBar>>;

fn close_all(&self) -> DaftResult<()>;
Expand Down Expand Up @@ -146,27 +145,19 @@ impl ProgressBarManager for IndicatifProgressBarManager {
&self,
color: ProgressBarColor,
prefix: &str,
show_received: bool,
) -> DaftResult<Box<dyn ProgressBar>> {
let template_str = format!(
"🗡️ 🐟 {{spinner:.green}} {{prefix:.{color}/bold}} | [{{elapsed_precise}}] {{msg}}",
color = color.to_str(),
);

let initial_message = if show_received {
"0 rows received, 0 rows emitted".to_string()
} else {
"0 rows emitted".to_string()
};

let pb = indicatif::ProgressBar::new_spinner()
.with_style(
ProgressStyle::default_spinner()
.template(template_str.as_str())
.unwrap(),
)
.with_prefix(prefix.to_string())
.with_message(initial_message);
.with_prefix(prefix.to_string());

self.multi_progress.add(pb.clone());
DaftResult::Ok(Box::new(IndicatifProgressBar(pb)))
Expand Down Expand Up @@ -263,18 +254,10 @@ mod python {
&self,
_color: ProgressBarColor,
prefix: &str,
show_received: bool,
) -> DaftResult<Box<dyn ProgressBar>> {
let bar_format = format!("🗡️ 🐟 {prefix}: {{elapsed}} {{desc}}", prefix = prefix);
let initial_message = if show_received {
"0 rows received, 0 rows emitted".to_string()
} else {
"0 rows emitted".to_string()
};
let pb_id = Python::with_gil(|py| {
let pb_id =
self.inner
.call_method1(py, "make_new_bar", (bar_format, initial_message))?;
let pb_id = self.inner.call_method1(py, "make_new_bar", (bar_format,))?;

Check warning on line 260 in src/daft-local-execution/src/progress_bar.rs

View check run for this annotation

Codecov / codecov/patch

src/daft-local-execution/src/progress_bar.rs#L260

Added line #L260 was not covered by tests
let pb_id = pb_id.extract::<usize>(py)?;
DaftResult::Ok(pb_id)
})?;
Expand Down

0 comments on commit 4404309

Please sign in to comment.