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 TrainerDataLoadingMixin and move logic to DataConnector #11282

Merged
merged 18 commits into from
Jan 5, 2022

Conversation

daniellepintz
Copy link
Contributor

@daniellepintz daniellepintz commented Dec 31, 2021

What does this PR do?

Fixes #11248

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 🙃

@mergify mergify bot added the has conflicts label Jan 3, 2022
@mergify mergify bot removed the has conflicts label Jan 3, 2022
@daniellepintz daniellepintz added the data handling Generic data-related topic label Jan 3, 2022
@awaelchli awaelchli added this to the 1.6 milestone Jan 4, 2022
@awaelchli awaelchli added the deprecation Includes a deprecation label Jan 4, 2022
@@ -2364,6 +2369,151 @@ def terminate_on_nan(self, val: bool) -> None:
)
self._terminate_on_nan = val # : 212

def reset_train_dataloader(self, model: Optional["pl.LightningModule"] = None) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

how about moving the reload logic to data_connector and trainer.reset_train_dataloader just calls trainer._data_connector._reset_train_dataloader? not sure if it's a good idea, but just trying to avoid all the logic being kept inside the single Trainer module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't feel strongly either way. I probably have a slight preference for keeping it as it is now, since I feel like having a function that just calls the private function adds a bit of unnecessary abstraction/complexity. If others feel strongly we can change it

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say it's fine as it is. I'd only do that if it aids in testing, but we don't have unit tests for each of these separate methods.

Copy link
Contributor

@awaelchli awaelchli Jan 5, 2022

Choose a reason for hiding this comment

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

It is fine because the trainer owns the dataloaders, so resetting is her responsibility. But this won't be the case in the future, pretty sure. Which is why I also suggested in my previous comment to map the public property to the protected one in the connector.

In any case, let's just please not mix properties and methods like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

n any case, let's just please not mix properties and methods like this.

@daniellepintz I believe my comment was missed here. Could you send a follow up PR? I believe reviewers did not catch this properly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@awaelchli sorry I am confused by that line. Could you clarify which property you are talking about?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the disorganization that this has caused. Previously, methods and properties were organized, but now new methods have been added and now it's mixed up:

method
method
property
property
new method
new method

It should be

method
method
new method
new method
property
property

given that Trainer wants to have all properties at the bottom.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see good point. Will send a follow up PR

@@ -2364,6 +2369,151 @@ def terminate_on_nan(self, val: bool) -> None:
)
self._terminate_on_nan = val # : 212

def reset_train_dataloader(self, model: Optional["pl.LightningModule"] = None) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say it's fine as it is. I'd only do that if it aids in testing, but we don't have unit tests for each of these separate methods.

@mergify mergify bot added the ready PRs ready to be merged label Jan 5, 2022
Copy link
Contributor

@rohitgr7 rohitgr7 left a comment

Choose a reason for hiding this comment

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

nit:

@daniellepintz
Copy link
Contributor Author

Ready to be merged!

@carmocca carmocca merged commit 5b59c95 into Lightning-AI:master Jan 5, 2022
@daniellepintz daniellepintz deleted the TrainerDataLoadingMixin branch January 5, 2022 20:25
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 TrainerDataLoadingMixin and move logic to DataConnector
6 participants