-
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 3 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,65 @@ | ||
| import datetime | ||
| import time | ||
|
|
||
| from threading import Thread | ||
| from tqdm import trange | ||
|
|
||
| from tqdm import trange # type: ignore | ||
|
|
||
|
|
||
| class ProgressBar(Thread): | ||
| """A Thread that displays a tqdm progress bar in the console.""" | ||
| """ | ||
| A Thread that displays a tqdm progress bar in the console. | ||
aron-bram marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def __init__(self, total: float, update_interval: float = 1.0, disable: bool = False): | ||
| """ | ||
| Parameters | ||
| ---------- | ||
| total: the total amount that the progress bar should reach | ||
| update_interval: reduce this to update the progress bar more frequently | ||
| disable: flag that turns on or off the progress bar. If false, then no thread is started or created. | ||
| """ | ||
| 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. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| total: int, | ||
| update_interval: float = 1.0, | ||
| disable: bool = False, | ||
| ): | ||
| self.disable = disable | ||
| if not disable: | ||
| super().__init__(name="_progressbar_") | ||
| self.total = total | ||
| self.update_interval = update_interval | ||
| self.terminated: bool = False | ||
| # start this thread | ||
| self.start() | ||
|
|
||
| def run(self): | ||
| def run(self) -> None: | ||
| """ | ||
| Overrides the run method of Thread. It displays a tqdm progress bar in the | ||
| console with useful descriptions about the task. | ||
| """ | ||
| if not self.disable: | ||
| for _ in trange(self.total, colour="green"): | ||
| for _ in trange( | ||
| self.total, | ||
| colour="green", | ||
| desc="Fitting to the training data", | ||
| postfix=f"The total time budget for this task is" | ||
| f" {datetime.timedelta(seconds=self.total)}", | ||
| ): | ||
| if not self.terminated: | ||
| time.sleep(self.update_interval) | ||
| else: | ||
| pass # max out the bar | ||
| print("Finishing up the task...") | ||
|
|
||
| def stop(self): | ||
| def stop(self) -> None: | ||
| """ | ||
| Terminates the thread. | ||
| """ | ||
aron-bram marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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
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.