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

[feat] Enable self.log in callbacks #5094

Merged
merged 6 commits into from
Dec 16, 2020

Conversation

tchaton
Copy link
Contributor

@tchaton tchaton commented Dec 11, 2020

What does this PR do?

This PR enables user to call self.log directly from the callbacks and not pl_module.log.

Fixes # (issue)

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 your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

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; Bugfixes should be including in bug-fix release milestones (m.f.X) and features should be included in (m.X.b) releases.

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Dec 11, 2020

Hello @tchaton! Thanks for updating this PR.

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

Comment last updated at 2020-12-14 07:15:11 UTC

@tchaton tchaton marked this pull request as ready for review December 11, 2020 18:00
@tchaton tchaton self-assigned this Dec 11, 2020
@tchaton tchaton added the logger Related to the Loggers label Dec 11, 2020
@tchaton tchaton added this to the 1.1.x milestone Dec 11, 2020
@codecov
Copy link

codecov bot commented Dec 11, 2020

Codecov Report

Merging #5094 (8a76bbc) into release/1.2-dev (16feb51) will decrease coverage by 1%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##           release/1.2-dev   #5094    +/-   ##
================================================
- Coverage               93%     92%    -1%     
================================================
  Files                  134     134            
  Lines                 9907   10023   +116     
================================================
+ Hits                  9205    9250    +45     
- Misses                 702     773    +71     

@mergify
Copy link
Contributor

mergify bot commented Dec 12, 2020

This pull request is now in conflict... :(

@mergify mergify bot requested a review from a team December 12, 2020 14:55
@tchaton tchaton modified the milestones: 1.1.x, 1.2 Dec 14, 2020
@tchaton tchaton changed the title enable to use self.log in callbacks [feat] Enable self.log in callbacks Dec 14, 2020
@tchaton tchaton changed the base branch from master to release/1.2 December 14, 2020 08:10
@Borda Borda changed the base branch from release/1.2 to release/1.2-dev December 14, 2020 08:27
def attach_model_logging_functions(self, model):
for callback in self.trainer.callbacks:
callback.log = model.log
callback.log_dict = model.log_dict
Copy link
Member

Choose a reason for hiding this comment

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

Question: should we also allow for callbacks to write predictions aka self.write_prediction and self.write_prediction_dict?

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, but within another PR :)

@williamFalcon williamFalcon merged commit f3748ba into release/1.2-dev Dec 16, 2020
@Borda Borda deleted the enable_self_log_in_callback branch December 16, 2020 21:21
@awaelchli
Copy link
Contributor

This PR breaks some of my callbacks.
I advise against dynamically binding methods like this. This will be extremely difficult to debug, both on the side of the user and on the side of the developer. I am convinced this is not future-proof.
If it really has to be like this, can we at least add an empty stub to the callback class, so that there is at least some indication for a name clash?

@indigoviolet
Copy link

@tchaton please consider adding the stub as above. this also upsets mypy.

@KeAWang
Copy link

KeAWang commented Apr 27, 2021

Any plans to revert this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logger Related to the Loggers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants