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

Deprecate LightningModule.get_progress_bar_dict #8985

Merged
merged 34 commits into from
Sep 9, 2021

Conversation

daniellepintz
Copy link
Contributor

@daniellepintz daniellepintz commented Aug 18, 2021

What does this PR do?

Deprecates get_progress_bar_dict from lightning module and moves it to progress bar callback
Fixes #8742

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@codecov
Copy link

codecov bot commented Aug 18, 2021

Codecov Report

Merging #8985 (52a6045) into master (a79c351) will decrease coverage by 4%.
The diff coverage is 96%.

@@           Coverage Diff           @@
##           master   #8985    +/-   ##
=======================================
- Coverage      92%     89%    -4%     
=======================================
  Files         178     179     +1     
  Lines       14899   14924    +25     
=======================================
- Hits        13752   13252   -500     
- Misses       1147    1672   +525     

Copy link
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

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

I don't think we can deprecate the method in this manner. In fact, there's further cleanup we can do, which is kind of related to #8946

LightningModule.get_progress_bar_dict is called here: https://github.com/PyTorchLightning/pytorch-lightning/blob/6de66eb110a63d67dc2ebb74e149981cd93aa431/pytorch_lightning/trainer/properties.py#L296-L313

which is then used here inside the progress bar callback:

https://github.com/PyTorchLightning/pytorch-lightning/blob/6de66eb110a63d67dc2ebb74e149981cd93aa431/pytorch_lightning/callbacks/progress.py#L410-L437

Here's what I think we could do:

  • Make the default implementation of LightningModule.get_progress_bar_dict return an empty dict
  • Carry the existing implementation forward into a private utility function of the progress bar callback, which accepts a LightningModule and trainer as input args
  • Deprecate progress_bar_metrics from the Trainer properties

@awaelchli

To justify these changes, we can argue this is only a temporary state and we will invest efforts in making the trainer less a god class in the future.

this is one of those ways we can start whittling away at this property list and make the trainer less of a god class

@daniellepintz
Copy link
Contributor Author

@ananthsub thanks so much for the helpful feedback! A few questions

Make the default implementation of LightningModule.get_progress_bar_dict return an empty dict

  1. That will make the functionality stop working in the next version, rather than leaving the functionality but giving dep warning, and then later removing it. Is that ok?

Carry the existing implementation forward into a private utility function of the progress bar callback, which accepts a LightningModule and trainer as input args

  1. Does it have to take the trainer as an arg since it already has access to the trainer through the base class ProgressBarBase?
  2. If it is a private function, how can I call it in properties.py?

Deprecate progress_bar_metrics from the Trainer properties

  1. is that just on a separate note, because it isn't used?

@awaelchli awaelchli added design Includes a design discussion feature Is an improvement or enhancement refactor labels Aug 19, 2021
Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

I agree with @ananthsub , an intermediate function that merges the metrics from trainer and get_progress_bar_dict hook is probably the best here

@ananthsub ananthsub added this to the v1.5 milestone Aug 25, 2021
@ananthsub ananthsub added the deprecation Includes a deprecation label Aug 25, 2021
@mergify mergify bot removed the has conflicts label Aug 28, 2021
@daniellepintz
Copy link
Contributor Author

@ananthsub is this ready to be merged?

@mergify mergify bot added the has conflicts label Sep 6, 2021
@tchaton
Copy link
Contributor

tchaton commented Sep 7, 2021

@ananthsub is this ready to be merged?

Some conflicts to be resolved.

@mergify mergify bot removed the has conflicts label Sep 7, 2021
@mergify mergify bot added the ready PRs ready to be merged label Sep 7, 2021
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGTM !

Copy link
Contributor

@kaushikb11 kaushikb11 left a comment

Choose a reason for hiding this comment

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

@daniellepintz Thank you for this PR! But blocking the merge for now, as I would need to take a look at the changes for RichProgressBar and test it locally and think of a better design. Will get back to it by tomorrow morning (IST)!

@mergify mergify bot removed the ready PRs ready to be merged label Sep 8, 2021
Copy link
Contributor

@kaushikb11 kaushikb11 left a comment

Choose a reason for hiding this comment

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

Hi @daniellepintz, the changes were breaking for RichProgressBar callback. I have pushed some updates for it and the PR is good to go. We could have one more iteration to improve the MetricsTextColumn component. Will create an issue around it. Thanks!

@mergify mergify bot added the ready PRs ready to be merged label Sep 9, 2021
@daniellepintz
Copy link
Contributor Author

@kaushikb11 thanks for fixing that and sorry I didn't notice in the first place!

@ananthsub ananthsub enabled auto-merge (squash) September 9, 2021 20:33
@ananthsub ananthsub merged commit 160e7e1 into Lightning-AI:master Sep 9, 2021
@daniellepintz daniellepintz deleted the progress_bar branch September 9, 2021 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation Includes a deprecation design Includes a design discussion feature Is an improvement or enhancement ready PRs ready to be merged refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate LightningModule.get_progress_bar_dict
6 participants