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 the case where logger=None is passed to Trainer #12249

Merged
merged 8 commits into from Mar 18, 2022

Conversation

daniellepintz
Copy link
Contributor

@daniellepintz daniellepintz commented Mar 6, 2022

What does this PR do?

Fixes a small bug introduced in #11920 for the case where logger=None is passed to the Trainer.

Before this PR, when logger=None is passed to the Trainer, we see this error:

    @property
    def log_dir(self) -> Optional[str]:
        if len(self.loggers) == 1:
            if isinstance(self.logger, TensorBoardLogger):
                dirpath = self.logger.log_dir
            else:
>               dirpath = self.logger.save_dir
E               AttributeError: 'NoneType' object has no attribute 'save_dir'

full output: https://gist.github.com/daniellepintz/f603473b82c1f21d8299eaae56b33001

This is because trainer.loggers is being set to [None] here: https://github.com/PyTorchLightning/pytorch-lightning/blob/5df519572f78ae5e23b0aab18fcbda06df7ff8dd/pytorch_lightning/trainer/connectors/logger_connector/logger_connector.py#L101
so in the log_dir property it thinks len(self.loggers) == 1.

Does your PR introduce any breaking changes? If yes, please list them.

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 🙃

@daniellepintz daniellepintz added bug Something isn't working logger Related to the Loggers labels Mar 6, 2022
@daniellepintz daniellepintz added this to the 1.6 milestone Mar 6, 2022
tests/loggers/test_all.py Outdated Show resolved Hide resolved
tests/loggers/test_all.py Outdated Show resolved Hide resolved
tests/loggers/test_all.py Outdated Show resolved Hide resolved
Copy link
Contributor

@krshrimali krshrimali left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for fixing this. ⚡ Before we forget about this, can you also create an issue from this comment?

@mergify mergify bot added the ready PRs ready to be merged label Mar 7, 2022
tests/loggers/test_all.py Outdated Show resolved Hide resolved
Copy link
Member

@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.

add chlog

@daniellepintz
Copy link
Contributor Author

@carmocca @tchaton mind taking a look? Your review is needed to merge

CHANGELOG.md Outdated Show resolved Hide resolved
@daniellepintz
Copy link
Contributor Author

Ready to be merged!

@ananthsub ananthsub enabled auto-merge (squash) March 14, 2022 16:28
@ananthsub ananthsub merged commit f8e50f9 into Lightning-AI:master Mar 18, 2022
@daniellepintz daniellepintz deleted the fix_logger_none branch March 18, 2022 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working logger Related to the Loggers ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants