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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the default_root_dir as the log_dir when the logger is a LoggerCollection #8187

Merged

Conversation

gahdritz
Copy link
Contributor

@gahdritz gahdritz commented Jun 29, 2021

What does this PR do?

Fixes a bug whereby the PyTorch profiler would fail to write to a local file when the Trainer's logger is a LoggerCollection.

Fixes #8157

The way I see it, there are three ways to go about this:

  1. Change the save_dir property of the LoggerCollection to the default_root_dir of the Trainer
  2. What I did here
  3. Some more complex fix, arguably the most natural, where the profiler traces are written to the save_dir of each constituent logger.

The first would probably break code that relies on the property being None to set defaults. The third, since the Lightning wrapper around the PyTorch profiler relies on PyTorch functions that expect a single path, is probably prohibitively complex.

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 Jun 29, 2021

Hello @gahdritz! Thanks for updating this PR.

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

Comment last updated at 2021-07-07 00:26:02 UTC

@gahdritz gahdritz changed the title Bugfix/loggercollection profiler Fix LoggerCollection/Pytorch profiler bug (issue #8157) Jun 29, 2021
@codecov
Copy link

codecov bot commented Jun 29, 2021

Codecov Report

Merging #8187 (6941d93) into master (1afc1ca) will decrease coverage by 5%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #8187    +/-   ##
=======================================
- Coverage      93%     88%    -5%     
=======================================
  Files         212     217     +5     
  Lines       13581   14263   +682     
=======================================
- Hits        12624   12577    -47     
- Misses        957    1686   +729     

@gahdritz gahdritz marked this pull request as draft June 29, 2021 01:33
@gahdritz gahdritz marked this pull request as ready for review June 29, 2021 05:58
@awaelchli awaelchli added logger Related to the Loggers bug Something isn't working labels Jun 29, 2021
@gahdritz gahdritz force-pushed the bugfix/loggercollection_profiler branch from 950342f to 5dd9965 Compare June 30, 2021 21:57
tests/trainer/properties/log_dir.py Show resolved Hide resolved
tests/trainer/properties/log_dir.py Outdated Show resolved Hide resolved
tests/profiler/test_profiler.py Outdated Show resolved Hide resolved
@awaelchli awaelchli changed the title Fix LoggerCollection/Pytorch profiler bug (issue #8157) Fix LoggerCollection/Pytorch profiler bug Jul 1, 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 !

@Borda Borda requested a review from awaelchli July 6, 2021 08:50
pytorch_lightning/trainer/properties.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/properties.py Show resolved Hide resolved
tests/trainer/properties/log_dir.py Outdated Show resolved Hide resolved
tests/trainer/properties/log_dir.py Outdated Show resolved Hide resolved
tests/profiler/test_profiler.py Outdated Show resolved Hide resolved
tests/profiler/test_profiler.py Outdated Show resolved Hide resolved
@edenlightning edenlightning added this to the v1.3.x milestone Jul 6, 2021
gahdritz and others added 6 commits July 6, 2021 20:16
@mergify mergify bot added the ready PRs ready to be merged label Jul 19, 2021
@Borda Borda requested review from Borda and carmocca July 19, 2021 11:53
@carmocca carmocca enabled auto-merge (squash) July 19, 2021 16:05
@carmocca carmocca changed the title Fix LoggerCollection/Pytorch profiler bug Return the default_root_dir as the log_dir when the logger is a LoggerCollection Jul 19, 2021
@carmocca carmocca merged commit 6604fc1 into Lightning-AI:master Jul 19, 2021
@gahdritz gahdritz deleted the bugfix/loggercollection_profiler branch July 19, 2021 22:18
@awaelchli awaelchli mentioned this pull request Aug 25, 2021
11 tasks
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.

LoggerCollection breaks PyTorch profiler
8 participants