-
Notifications
You must be signed in to change notification settings - Fork 175
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
[FEAT] Enable Progress Bars for PyRunner and RayRunner #1609
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
43025a0
prototype of tqdm
samster25 e689316
add tqdm to deps
samster25 15fdb67
remove dead code
samster25 b52f6ec
empty
samster25 b9f2b1b
add ray runner
samster25 cb18780
only enable when in interactive mode
samster25 f261cd5
only run in ipython
samster25 187dabf
add tasks to top level
samster25 7ae3538
Update daft/runners/tqdm.py
samster25 8fcf00f
refactor to pbar
samster25 c3c3493
remove print statement
samster25 44770e3
disable global task bar by default
samster25 9ce28b9
dont refresh ray progress bar and set update freq to 1 second
samster25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
from typing import Any | ||
|
||
from tqdm.auto import tqdm | ||
|
||
from daft.execution.execution_step import PartitionTask | ||
|
||
|
||
class ProgressBar: | ||
def __init__(self, use_ray_tqdm: bool, show_tasks_bar: bool = False, disable: bool = False) -> None: | ||
self.use_ray_tqdm = use_ray_tqdm | ||
self.show_tasks_bar = show_tasks_bar | ||
self.tqdm_mod = tqdm | ||
self.pbars: dict[int, tqdm] = dict() | ||
self.disable = ( | ||
disable | ||
or not bool(int(os.environ.get("RAY_TQDM", "1"))) | ||
or not bool(int(os.environ.get("DAFT_PROGRESS_BAR", "1"))) | ||
) | ||
|
||
def _make_new_bar(self, stage_id: int, name: str): | ||
if self.use_ray_tqdm: | ||
self.pbars[stage_id] = self.tqdm_mod(total=1, desc=name, position=len(self.pbars)) | ||
else: | ||
self.pbars[stage_id] = self.tqdm_mod( | ||
total=1, desc=name, position=len(self.pbars), leave=False, mininterval=1.0 | ||
) | ||
|
||
def mark_task_start(self, step: PartitionTask[Any]) -> None: | ||
if self.disable: | ||
return | ||
if self.show_tasks_bar: | ||
if len(self.pbars) == 0: | ||
self._make_new_bar(-1, "Tasks") | ||
else: | ||
task_pbar = self.pbars[-1] | ||
task_pbar.total += 1 | ||
|
||
stage_id = step.stage_id | ||
|
||
if stage_id not in self.pbars: | ||
name = "-".join(i.__class__.__name__ for i in step.instructions) | ||
self._make_new_bar(stage_id, name) | ||
else: | ||
pb = self.pbars[stage_id] | ||
pb.total += 1 | ||
|
||
def mark_task_done(self, step: PartitionTask[Any]) -> None: | ||
if self.disable: | ||
return | ||
|
||
stage_id = step.stage_id | ||
self.pbars[stage_id].update(1) | ||
if self.show_tasks_bar: | ||
self.pbars[-1].update(1) | ||
|
||
def close(self) -> None: | ||
for p in self.pbars.values(): | ||
p.close() | ||
del p |
Oops, something went wrong.
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.
Initialize as
self.pbars = {-1: ...}
? We could also document here that-1
represents the progress for "All tasks".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 actually dont want to initialize the the progress bar until we get a task. Otherwise the total is 0 and it's in a weird state.