-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Mark trainer.data_connector
as protected
#10031
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
Conversation
We are getting the Python error "Protected member accessed from outside the class", as expected. What should we do about this? |
Codecov Report
@@ Coverage Diff @@
## master #10031 +/- ##
========================================
- Coverage 92% 89% -4%
========================================
Files 182 180 -2
Lines 16113 15870 -243
========================================
- Hits 14896 14075 -821
- Misses 1217 1795 +578 |
Where's the error? |
curious why we want to make it protected if we want to access trainer._accelerator_connector outside trainer? |
@carmocca DeepSource compains it. https://deepsource.io/gh/PyTorchLightning/pytorch-lightning/run/495b4588-7aa7-4aa7-b300-c1997b68c96d/python/ |
@four4fish we don't want it to be part of the public API, i.e. we don't want users to use it. more details in the issue #9778. @carmocca Regarding the DeepSource error, we can still merge the PR with this error, but it's a bit strange that we are accessing the protected member outside of the class. still I think it's best to merge this PR so that the connectors are no longer part of the public API |
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.
Approving, but I am not a huge fan of this. Some users have replaced the connectors in the past to add some custom behaviours.
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.
Same here, not a fan of this either for this reason: #9778 (comment)
Lightning is not properly respecting encapsulation in many places. Adding underscore to members does not really make them protected if we keep using them outside as if they are part of the public interface. It's an excuse to break backward compatibility (my words, my opinion, a major complaint of mine since a long time 😅 , it's really hard to get rid of though).
@tchaton @awaelchli I hear your concerns, and just reread @awaelchli's comment on this issue. If you prefer I can mark this PR as draft until we refactor things so that we don't violate the protected rule and access it outside of trainer class. |
I'm fine with moving forward if we want to change the internals of the DataConnector. But it seems we don't actually have any concrete plans (see section about Connectors in https://docs.google.com/document/d/1xHU7-iQSpp9KJTjI3As2EM0mfNHHr37WZYpDpwLkivA/edit#). In the past we have expressed some ideas to better define and restrict the responsibilities of the connectors. I will add more ideas there in the document. |
Sounds good, I propose we move forward with this, and in parallel work on improving the connectors in the arch doc |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
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 !
What does this PR do?
Part of #9778
Does your PR introduce any breaking changes? If yes, please list them.
Before submitting
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:
Did you have fun?
Make sure you had fun coding 🙃