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

Reset current_fx properties on lightning module in teardown #7247

Merged
merged 7 commits into from
Apr 28, 2021

Conversation

ananthsub
Copy link
Contributor

@ananthsub ananthsub commented Apr 28, 2021

What does this PR do?

This isn't an issue with master, but it's extra precaution that these fields are reset before control returns back to the caller

Fixes #<issue_number>

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 Apr 28, 2021

Hello @ananthsub! Thanks for updating this PR.

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

Comment last updated at 2021-04-28 18:27:27 UTC

@codecov
Copy link

codecov bot commented Apr 28, 2021

Codecov Report

Merging #7247 (afb50bd) into master (94fcaaf) will decrease coverage by 6%.
The diff coverage is 90%.

@@           Coverage Diff           @@
##           master   #7247    +/-   ##
=======================================
- Coverage      91%     85%    -6%     
=======================================
  Files         199     199            
  Lines       12783   13342   +559     
=======================================
- Hits        11662   11331   -331     
- Misses       1121    2011   +890     

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.

good catch !

@ananthsub ananthsub added this to the v1.3 milestone Apr 28, 2021
Comment on lines 2065 to 2071
assert model._current_fx_name == "", f"_current_fx_name not reset after fit: {model._current_fx_name}"
assert model._current_hook_fx_name is None, f"_current_hook_fx_name not reset after fit: {model._current_hook_fx_name}"
assert model._current_dataloader_idx is None, f"_current_dataloader_idx not reset after fit: {model._current_dataloader_idx}"
trainer.test(model)
assert model._current_fx_name == "", f"_current_fx_name not reset after test: {model._current_fx_name}"
assert model._current_hook_fx_name is None, f"_current_hook_fx_name not reset after test: {model._current_hook_fx_name}"
assert model._current_dataloader_idx is None, f"_current_dataloader_idx not reset after test: {model._current_dataloader_idx}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Borda I ran yapf and pre-commit on this file but it looks like they didn't take effect based on the failing test

Copy link
Contributor

Choose a reason for hiding this comment

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

In these cases where yapf fails or produces bad output, I usually run black -S -l120 and then yapf to fix it.

The output was: dd6cf9d

pytorch_lightning/trainer/trainer.py Show resolved Hide resolved
pytorch_lightning/core/lightning.py Show resolved Hide resolved
Comment on lines 2065 to 2071
assert model._current_fx_name == "", f"_current_fx_name not reset after fit: {model._current_fx_name}"
assert model._current_hook_fx_name is None, f"_current_hook_fx_name not reset after fit: {model._current_hook_fx_name}"
assert model._current_dataloader_idx is None, f"_current_dataloader_idx not reset after fit: {model._current_dataloader_idx}"
trainer.test(model)
assert model._current_fx_name == "", f"_current_fx_name not reset after test: {model._current_fx_name}"
assert model._current_hook_fx_name is None, f"_current_hook_fx_name not reset after test: {model._current_hook_fx_name}"
assert model._current_dataloader_idx is None, f"_current_dataloader_idx not reset after test: {model._current_dataloader_idx}"
Copy link
Contributor

Choose a reason for hiding this comment

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

In these cases where yapf fails or produces bad output, I usually run black -S -l120 and then yapf to fix it.

The output was: dd6cf9d

@ananthsub ananthsub added the ready PRs ready to be merged label Apr 28, 2021
@ananthsub ananthsub merged commit 075de93 into Lightning-AI:master Apr 28, 2021
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.

5 participants