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

deprecate on_{train/val/test/predict}_dataloader() from DataHooks #9098

Merged

Conversation

ninginthecloud
Copy link
Contributor

@ninginthecloud ninginthecloud commented Aug 24, 2021

What does this PR do?

Context

Fixes #8758

DataHooks has defined on_{train/val/test/predict}_dataloader , but these functions ususally are called right before {train/val/test/predict}_dataloader. It's difficult for users to distinguish these two sets of hooks. As discussed in issue #8758 (detailed discussion here), it's aligned that we can deprecate this set of hooks.

Steps

  • remove on_{train/val/test/predict}_dataloader from DataHooks
  • fix tests test_dataloaders.py and test_hooks.py
  • update fx_validator.py

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 🙃

pytorch_lightning/core/hooks.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 25, 2021

Codecov Report

Merging #9098 (769e8d2) into master (b497fb8) will decrease coverage by 4%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #9098    +/-   ##
=======================================
- Coverage      92%     88%    -4%     
=======================================
  Files         176     176            
  Lines       14804   14828    +24     
=======================================
- Hits        13651   13056   -595     
- Misses       1153    1772   +619     

@ananthsub ananthsub changed the title deprecate on_{train/val/test/predict}_trainer() from DataHooks deprecate on_{train/val/test/predict}_dataloader() from DataHooks Aug 25, 2021
Copy link
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

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

very nice! i only have some minor comments

tests/trainer/test_dataloaders.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
tests/models/test_hooks.py Outdated Show resolved Hide resolved
pytorch_lightning/core/hooks.py Outdated Show resolved Hide resolved
pytorch_lightning/core/hooks.py Outdated Show resolved Hide resolved
pytorch_lightning/core/hooks.py Outdated Show resolved Hide resolved
pytorch_lightning/core/hooks.py Outdated Show resolved Hide resolved
tests/trainer/test_dataloaders.py Outdated Show resolved Hide resolved
@ananthsub ananthsub added the data handling Generic data-related topic label Aug 25, 2021
@ananthsub ananthsub added this to the v1.5 milestone Aug 25, 2021
ninginthecloud and others added 6 commits August 26, 2021 21:23
Summary:
1. remove `on_{train/val/test/predict}_dataloader()`
2. update corrsonding tests

Test Plan:
make test
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:
1. check overridden in configuration_validator.py
2. add unit test to catch deprecation warning
3. update hooks docstring

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@ninginthecloud ninginthecloud force-pushed the deprecation/8758_on_train_dataloader branch from 8dc7a89 to 29474af Compare August 27, 2021 05:21
@ninginthecloud ninginthecloud force-pushed the deprecation/8758_on_train_dataloader branch from 2c35b67 to c2e046c Compare August 27, 2021 05:25
CHANGELOG.md Outdated Show resolved Hide resolved
pytorch_lightning/core/hooks.py Outdated Show resolved Hide resolved
@mergify mergify bot added the ready PRs ready to be merged label Aug 27, 2021
@tchaton
Copy link
Contributor

tchaton commented Aug 27, 2021

Hey @ananthsub @ninginthecloud,

Let's wait a little for this one. I want to make sure we can find an alternative for Flash as those hooks are currently the cleanest way to modify in-place dataloaders on reset.

@ethanwharris Mind looking into this ?

Best,
T.C

Co-authored-by: ananthsub <[email protected]>
Copy link
Contributor

@SeanNaren SeanNaren left a comment

Choose a reason for hiding this comment

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

LGTM! Still awaiting @tchaton's comment

Could we not just migrate to using the val/train/test/predict dataloader hook?

Copy link
Member

@ethanwharris ethanwharris left a comment

Choose a reason for hiding this comment

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

LGTM, flash is no longer dependent on this following: Lightning-Universe/lightning-flash#707

@tchaton tchaton enabled auto-merge (squash) August 27, 2021 18:34
@tchaton tchaton merged commit 1657588 into Lightning-AI:master Aug 28, 2021
ethanwharris added a commit that referenced this pull request Aug 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data handling Generic data-related topic deprecation Includes a deprecation ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate the on_{train/val/test}_dataloader hooks
7 participants