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

protect progress bar callback #1855

Merged
merged 4 commits into from
May 25, 2020
Merged

protect progress bar callback #1855

merged 4 commits into from
May 25, 2020

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented May 16, 2020

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs? no changes required
  • Did you write any new necessary tests?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

What does this PR do?

Follow up to #1450. The progress bar callback is supposed to be passed in via the callbacks Trainer arg if overriding the default is desired and it should not be mutable after initialization of the Trainer.
Someone on slack already commented that the progress_bar_callback Trainer arg has no effect. It was a left-over and I did not remove it in the original PR.
Since it was not documented at all, this should not break anybody's code.

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented May 16, 2020

Hello @awaelchli! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-05-24 23:38:03 UTC

@awaelchli awaelchli added the feature Is an improvement or enhancement label May 16, 2020
@mergify mergify bot requested a review from a team May 16, 2020 19:52
@awaelchli awaelchli marked this pull request as ready for review May 18, 2020 03:41
Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

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

LGTM :)

Just one small question

pytorch_lightning/trainer/deprecated_api.py Show resolved Hide resolved
@mergify mergify bot requested a review from a team May 19, 2020 06:08
@@ -109,20 +107,22 @@ def configure_early_stopping(self, early_stop_callback):
self.early_stop_callback = early_stop_callback
self.enable_early_stop = True

def configure_progress_bar(self):
def configure_progress_bar(self, refresh_rate=1, process_position=0):
progress_bars = [c for c in self.callbacks if isinstance(c, ProgressBarBase)]
if len(progress_bars) > 1:
raise MisconfigurationException(
Copy link
Member

Choose a reason for hiding this comment

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

I ques we can allow multiple in future, just check that each is different, meaning another monitor event, frequency, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes agree that would be good. the only reason why we currently have a limit of 1 is because Trainer needs to be able to disable the progress bar temporarily, for example in LRFinder.

@@ -754,6 +749,10 @@ def num_gpus(self) -> int:
def data_parallel(self) -> bool:
return self.use_dp or self.use_ddp or self.use_ddp2

@property
def progress_bar_callback(self):
return self._progress_bar_callback
Copy link
Member

Choose a reason for hiding this comment

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

not sure how much it protects as it handles pointer to the same object so edit in the return will appear in the original one...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I think that's fine. the goal was to make the reference read-only so that you can't change the reference to anything other than a progress bar.

@mergify mergify bot requested a review from a team May 19, 2020 06:48
@mergify mergify bot requested a review from a team May 19, 2020 06:51
@Borda Borda added the ready PRs ready to be merged label May 21, 2020
@codecov
Copy link

codecov bot commented May 25, 2020

Codecov Report

Merging #1855 into master will decrease coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #1855   +/-   ##
======================================
- Coverage      88%     88%   -0%     
======================================
  Files          74      74           
  Lines        4621    4617    -4     
======================================
- Hits         4050    4046    -4     
  Misses        571     571           

@williamFalcon williamFalcon merged commit 8ca8336 into Lightning-AI:master May 25, 2020
@awaelchli awaelchli deleted the feat/protected_progress_bar_callback branch May 25, 2020 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants