-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Show progress bar while fitting to training data #1606
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a070da4
Show progress bar while fitting to training data
aron-bram 3431de2
Minor fixes for progress bar
aron-bram 292a604
Revert accidental changes to requirements.txt
aron-bram 12d3718
Document changes
aron-bram 62a7d7a
Skip type checks for tqdm
aron-bram 1781d49
Make progress bar more flexible with kwargs
aron-bram e5b1871
Fix link checker make command in CONTRIBUTE.md
aron-bram 3cf305b
Update doc link to be sphinx compatible
aron-bram 143b7c4
Switch to pytets-forked from pytest-xdist
aron-bram aadc457
Merge branch 'development' into progress_bar
eddiebergman 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,68 @@ | ||
from typing import Any | ||
|
||
import datetime | ||
import time | ||
from threading import Thread | ||
|
||
from tqdm import trange | ||
|
||
|
||
class ProgressBar(Thread): | ||
"""A Thread that displays a tqdm progress bar in the console. | ||
|
||
It is specialized to display information relevant to fitting to the training data | ||
with auto-sklearn. | ||
|
||
Parameters | ||
---------- | ||
total : int | ||
The total amount that should be reached by the progress bar once it finishes | ||
update_interval : float | ||
Specifies how frequently the progress bar is updated (in seconds) | ||
disable : bool | ||
Turns on or off the progress bar. If True, this thread won't be started or | ||
initialized. | ||
kwargs : Any | ||
Keyword arguments that are passed into tqdm's constructor. Refer to: | ||
`tqdm <https://tqdm.github.io/docs/tqdm/>`_. Note that postfix can not be | ||
specified in the kwargs since it is already passed into tqdm by this class. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
total: int, | ||
update_interval: float = 1.0, | ||
disable: bool = False, | ||
**kwargs: Any, | ||
): | ||
self.disable = disable | ||
if not disable: | ||
super().__init__(name="_progressbar_") | ||
self.total = total | ||
self.update_interval = update_interval | ||
self.terminated: bool = False | ||
self.kwargs = kwargs | ||
# start this thread | ||
self.start() | ||
|
||
def run(self) -> None: | ||
"""Display a tqdm progress bar in the console. | ||
|
||
Additionally, it shows useful information related to the task. This method | ||
overrides the run method of Thread. | ||
""" | ||
if not self.disable: | ||
for _ in trange( | ||
self.total, | ||
postfix=f"The total time budget for this task is " | ||
f"{datetime.timedelta(seconds=self.total)}", | ||
**self.kwargs, | ||
): | ||
if not self.terminated: | ||
time.sleep(self.update_interval) | ||
|
||
def stop(self) -> None: | ||
"""Terminates the thread.""" | ||
if not self.disable: | ||
self.terminated = True | ||
super().join() |
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.