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

chore: Build progress bar only on first update #3626

Merged
merged 4 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
32 changes: 21 additions & 11 deletions daft/runners/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,35 @@
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.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:
pbar_id = len(self.pbars)
self.pbars[pbar_id] = self.tqdm_mod(
bar_format=bar_format,
desc=initial_message,
position=pbar_id,
leave=False,
mininterval=1.0,
maxinterval=self._maxinterval,
)
pbar_id = self.next_id
self.next_id += 1
self.bar_configs[pbar_id] = (bar_format, initial_message)

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]
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,
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like initial_message isn't really used? It gets added for a brief moment during the first update, but is superceded shortly after.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch

position=pbar_id,
leave=False,
mininterval=1.0,
maxinterval=self._maxinterval,
)
del self.bar_configs[pbar_id]

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

View check run for this annotation

Codecov / codecov/patch

daft/runners/progress_bar.py#L139

Added line #L139 was not covered by tests
self.pbars[pbar_id].set_description_str(message)

def close_bar(self, pbar_id: int) -> None:
self.pbars[pbar_id].close()
del self.pbars[pbar_id]
if pbar_id in self.pbars:
self.pbars[pbar_id].close()
del self.pbars[pbar_id]

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

View check run for this annotation

Codecov / codecov/patch

daft/runners/progress_bar.py#L143-L145

Added lines #L143 - L145 were not covered by tests

def close(self) -> None:
for p in self.pbars.values():
Expand Down
4 changes: 2 additions & 2 deletions src/daft-local-execution/src/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ pub struct OperatorProgressBar {
}

impl OperatorProgressBar {
// 100ms = 100_000_000ns
const UPDATE_INTERVAL: u64 = 100_000_000;
// 500ms = 500_000_000ns
const UPDATE_INTERVAL: u64 = 500_000_000;

pub fn new(
progress_bar: Box<dyn ProgressBar>,
Expand Down
Loading