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

Should the Trainer attributes be protected? #1497

Closed
awaelchli opened this issue Apr 15, 2020 · 10 comments
Closed

Should the Trainer attributes be protected? #1497

awaelchli opened this issue Apr 15, 2020 · 10 comments
Labels
feature Is an improvement or enhancement question Further information is requested won't fix This will not be worked on

Comments

@awaelchli
Copy link
Member

❓ Why are the Trainer attributes not protected?

Sorry if this was already discussed before, but I was wondering.
Currently, the following code works and doesn't complain:

trainer = Trainer()
trainer.checkpoint_callback = 'bad manners'

Is there a reason why attributes like these are not protected? For example this

class Trainer:
    def __init__(self):
        self._checkpoint_callback = ...

    @property
    def checkpoint_callback:
        return self._checkpoint_callback

would make the attribute read only and prevent anyone from accidentally changing the state of The trainer.

Is the callback system possibly the reason for this, so that the callback method has full access to trainer variables? If so, I feel a property + setter approach would still be better.

@awaelchli awaelchli added the question Further information is requested label Apr 15, 2020
@Borda
Copy link
Member

Borda commented Apr 17, 2020

I agree that some shall be protected as well as some methods which are not meant to be used by user shall be protected too...

@Borda Borda added the feature Is an improvement or enhancement label Apr 17, 2020
@stale
Copy link

stale bot commented Jun 16, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the won't fix This will not be worked on label Jun 16, 2020
@Evpok
Copy link

Evpok commented Jun 17, 2020

This is marked as wontfix so it probably won't be done, but for the record that would be a very unusual behavior for Python, “we are all consenting adults here” and I don't think that a lib going out of its way to do that kind of thing would be a good thing.

@stale stale bot removed the won't fix This will not be worked on label Jun 17, 2020
@awaelchli
Copy link
Member Author

awaelchli commented Jun 17, 2020

totally agree :)
the bot added this wontfix label and wanted to close the issue due to inactivity.
these robots... always trying to take over the world

@Borda
Copy link
Member

Borda commented Jun 18, 2020

This is marked as wontfix so it probably won't be done

sorry for the confusion, it was an automatic bot marking non-active issues...
Agree with @awaelchli we ll do it, just did not have time yet 🐰
@Evpok mind take it over and draft a PR with these changes?

@Evpok
Copy link

Evpok commented Jun 18, 2020

Well, I was trying to argue that it should not be done, since it adds unnecessary complexity and makes it harder to monkey patch if needed :-)

@Borda
Copy link
Member

Borda commented Jun 18, 2020

the point of protected is to clearly separate what is the recommended API and what is internal staff so you can still use it but to be aware that you are using something that is meant to be just internal PL use and you need to know how to use it correctly... so it does not add any complexity, all functions/classes stay as they are just minor rename with _

@Evpok
Copy link

Evpok commented Jun 18, 2020

Right, that makes sense, sorry for being dense :-)

@stale
Copy link

stale bot commented Aug 17, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the won't fix This will not be worked on label Aug 17, 2020
@awaelchli awaelchli removed the won't fix This will not be worked on label Aug 17, 2020
@stale
Copy link

stale bot commented Oct 22, 2020

This issue has been automatically marked as stale because it hasn't had any recent activity. This issue will be closed in 7 days if no further activity occurs. Thank you for your contributions, Pytorch Lightning Team!

@stale stale bot added the won't fix This will not be worked on label Oct 22, 2020
@stale stale bot closed this as completed Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement question Further information is requested won't fix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants