-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 DataModule lifecycle properties #7657
Deprecate DataModule lifecycle properties #7657
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7657 +/- ##
=======================================
- Coverage 91% 86% -5%
=======================================
Files 204 204
Lines 13659 13669 +10
=======================================
- Hits 12435 11819 -616
- Misses 1224 1850 +626 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These warnings will appear every time these functions are called (every setup, teardown, prepare_data call)
Considering these are properties out of the reach of users, they can get very annoying as users won't be able to disable them or update their code.
What's your plan to carry out the complete deprecation?
Good catch. What do you think about the trainer directly accessing the private attribute on the module, or wrapping this in a warning cache?
After this PR is merged, in v1.6 we can remove all the tracking code and properties listed in the issue. Are there items in the issue that aren't covered which we should discuss further? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is, usually when something is deprecated, you can do two things as an user:
- Stop using the deprecated feature
- Upgrade to the alternative.
The issue here is that none of them can be done in this case, leading to frustration (nobody likes warnings!)
What if instead of deprecating these properties which are pretty much internal (I haven't seen any user example relying on them), we print a warning when one of these functions is called twice?
(1) and (2) still won't be possible with this solution, but at least the number of users who are relying on the "do not call me again logic" should be much smaller than the number of users who would see these deprecation messages implemented in this PR (all datamodule users)
I talked to @carmocca around the warnings and deprecation:
to this:
In this use case:
It is not worth adding a
|
How easy do we think it will be for users to write idempotent For example, a basic user might have:
In this case, Now, what if you have some complex pre-processing code where knowing whether it has been applied or not is not as simple as a file existence check. In this case, the Are we okay with this? |
@carmocca the implementation can check for whether the side-effect has already taken place. Another reason is what came up in the slack questions channel today. Users can use the datamodule outside of the Lightning Trainer: https://pytorch-lightning.readthedocs.io/en/latest/extensions/datamodules.html#datamodules-without-lightning In these cases, |
2b87b08
to
553f076
Compare
Co-authored-by: Justus Schock <12886177+justusschock@users.noreply.github.com>
for more information, see https://pre-commit.ci
b48a694
to
066571b
Compare
@carmocca do you think this PR is ready to go now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry! Forgot I had requested changes
Great job!
What does this PR do?
Fixes #7301
This is the first change required, since this will be a breaking change in the API.
First, we mark the properties as deprecated. Then in v1.6, we can remove them completely, along with all the tracking code outlined in #7301, and change the Trainer behavior to unconditionally call these hooks.
This makes it so that the DataModule is in full control of the state, not the Trainer, giving more flexibility and predictability to users.
Before submitting
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:
Did you have fun?
Make sure you had fun coding 🙃