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

fix incomplete progress bar when refresh_rate > num batches #4577

Merged
merged 7 commits into from
Nov 23, 2020

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Nov 8, 2020

What does this PR do?

Fixes #4565

Fixes edge cases with num batches not being divisibale by refresh rate, leading to an incomplete the progress bar.
Tests here fail on master.

Example:

train_batches: 5, refresh_rate: 3

(master)
Epoch 0: 60%|██████ | 3/5 [00:00<00:00, 111.11it/s, loss=0.131]

(this branch)
Epoch 0: 100%|██████████| 5/5 [00:00<00:00, 125.00it/s, loss=0.124]

@awaelchli awaelchli added bug Something isn't working feature Is an improvement or enhancement priority: 2 Low priority task labels Nov 8, 2020
@awaelchli awaelchli added this to the 1.0.x milestone Nov 8, 2020
@awaelchli
Copy link
Contributor Author

this bugfix is a visual fix, I need to figure out how to write the unit test. somehow counting the number of times update is called.

@SkafteNicki
Copy link
Member

@awaelchli would it be idea for testing to subclass ProgressBar and then decorate the update method? Something like:

class MyProgressBar(ProgressBar):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._update_counter = 0

    def init_train_tqdm(self):
        bar = super().init_train_tqdm()
        bar.update = self.counter_wrap(bar.update)
        return bar

    def counter_wrap(self, update):
        def wrap(*args, **kwargs):
            self._update_counter += 1
            return update(*args, **kwargs)
        return wrap

@edenlightning edenlightning modified the milestones: 1.0.x, 1.0.7 Nov 10, 2020
@Borda Borda modified the milestones: 1.0.7, 1.0.x Nov 11, 2020
@edenlightning edenlightning modified the milestones: 1.0.x, 1.0.7 Nov 13, 2020
@Borda Borda modified the milestones: 1.0.7, 1.0.x, 1.1 Nov 13, 2020
@codecov
Copy link

codecov bot commented Nov 23, 2020

Codecov Report

Merging #4577 (00a24b4) into master (9186abe) will increase coverage by 0%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #4577    +/-   ##
=======================================
  Coverage      93%     93%            
=======================================
  Files         118     118            
  Lines        8911    9030   +119     
=======================================
+ Hits         8285    8403   +118     
- Misses        626     627     +1     

@awaelchli awaelchli changed the title fix progress bar overshoot when refresh_rate > num batches fix progress bar overshoot/incomplete when refresh_rate > num batches Nov 23, 2020
@awaelchli awaelchli marked this pull request as ready for review November 23, 2020 00:48
@awaelchli awaelchli changed the title fix progress bar overshoot/incomplete when refresh_rate > num batches fix progress bar incomplete when refresh_rate > num batches Nov 23, 2020
@awaelchli awaelchli changed the title fix progress bar incomplete when refresh_rate > num batches fix incomplete progress bar when refresh_rate > num batches Nov 23, 2020
@awaelchli awaelchli added the ready PRs ready to be merged label Nov 23, 2020
Copy link
Member

@SkafteNicki SkafteNicki left a comment

Choose a reason for hiding this comment

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

LGTM

@ananyahjha93
Copy link
Contributor

@awaelchli can you resolve the conflict?

@awaelchli
Copy link
Contributor Author

@ananyahjha93 resolved, thanks!

@awaelchli awaelchli merged commit 89e8796 into master Nov 23, 2020
@awaelchli awaelchli deleted the bugfix/overshoot branch November 23, 2020 23:01
@Borda Borda modified the milestones: 1.1, 1.0.x Nov 24, 2020
Borda pushed a commit that referenced this pull request Nov 24, 2020
* fix progress bar overshoot

* fix updates for partially incomplete main  progress bar when val loop starts

* add tests

* chlog

(cherry picked from commit 89e8796)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature Is an improvement or enhancement priority: 2 Low priority task ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

progress bar refresh_rate prevents old bars being cleared
7 participants