Skip to content

Conversation

@awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Feb 17, 2021

What does this PR do?

Follow up to #5743
get_model() returns always the LightningModule
By using the lightning_module property getter, we make it explicit.
The old get_model() is still there. This is fully backward compatible.

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 update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
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 🙃

@pep8speaks
Copy link

pep8speaks commented Feb 17, 2021

Hello @awaelchli! Thanks for updating this PR.

Line 233:17: W503 line break before binary operator

Comment last updated at 2021-02-18 13:55:19 UTC

@codecov
Copy link

codecov bot commented Feb 17, 2021

Codecov Report

Merging #6035 (31706fa) into master (b7c2e0a) will increase coverage by 0%.
The diff coverage is 96%.

@@          Coverage Diff           @@
##           master   #6035   +/-   ##
======================================
  Coverage      93%     93%           
======================================
  Files         160     160           
  Lines       11367   11403   +36     
======================================
+ Hits        10582   10620   +38     
+ Misses        785     783    -2     

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 !

@Borda Borda enabled auto-merge (squash) February 17, 2021 19:44
Copy link
Collaborator

@Borda Borda left a comment

Choose a reason for hiding this comment

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

are we keeping get_model or shall we deprecate it?
cc: @PyTorchLightning/core-contributors

@Borda Borda disabled auto-merge February 17, 2021 19:46
@SkafteNicki
Copy link
Collaborator

are we keeping get_model or shall we deprecate it?
cc: @PyTorchLightning/core-contributors

+1 for deprecating get_model

@carmocca carmocca enabled auto-merge (squash) February 17, 2021 21:34
@carmocca carmocca disabled auto-merge February 17, 2021 21:35
@Borda Borda added the ready PRs ready to be merged label Feb 17, 2021
@awaelchli
Copy link
Contributor Author

Thank you for the reviews. I added the requested deprecation warning + test 74c55c4

"""Called at the end of fit and test"""
for callback in self.callbacks:
callback.teardown(self, self.get_model(), stage)
callback.teardown(self, self.lightning_module, stage)
Copy link
Contributor

Choose a reason for hiding this comment

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

do you want to move this outside of the loop to save on unwrapping per callback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's almost not worth it, because unwrapping doesn't really add any overhead since it's just following references, i.e., model.module in case of DDP for example.
I could be wrong, or it may change in the future. Do you see it as a big overhead?

@Borda Borda enabled auto-merge (squash) February 18, 2021 13:56
@Borda Borda merged commit 02ac4b0 into master Feb 18, 2021
@Borda Borda deleted the refactor/get_model_reference branch February 18, 2021 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready PRs ready to be merged refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants