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

WIP:removed unused Trainer kwargs from init #1180

Closed

Conversation

oplatek
Copy link
Contributor

@oplatek oplatek commented Mar 18, 2020

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
    discussed on slack
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?
    current tests should cover this
  • If you made a notable change (that affects users), did you update the CHANGELOG?

What does this PR do?

It removes kwargs from Trainer which are not used.

My take on using kwargs on function:
All kwargs should have a consumer.

f_ok(a, b, **kwargs):
    # ok
     f2(**kwargs) 

f_ko(a, b, **kwargs):
    # kwargs are just for future convenience for future implementations/ for overriden functions
    # allows passing unsupported arguments and creates confusion that the args are supported
    # if the kwargs are not consumed
     f3(a, b)

f_also_ko(a, b, **kwargs):
     # same arguments as above - all kwargs needs to be consumed
     f4(a, b, kwargs['c'])

Did you have fun?

🙃

@oplatek
Copy link
Contributor Author

oplatek commented Mar 18, 2020

FYI: all other usecases seems to be ok
https://github.com/PyTorchLightning/pytorch-lightning/search?q=kwargs&unscoped_q=kwargs

@Borda Borda added docs Documentation related feature Is an improvement or enhancement labels Mar 18, 2020
@Borda Borda requested a review from a team March 18, 2020 14:04
@Borda
Copy link
Member

Borda commented Mar 18, 2020

@tullie @williamFalcon do you remember why we had it there?

Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@Borda Borda requested a review from a team March 18, 2020 14:07
@oplatek
Copy link
Contributor Author

oplatek commented Mar 18, 2020

@Borda You were right about the inheritance.

The base class needs to pass the arguments to the child class (the base class cannot know the argument at the time of writing).

See search order and practical advice section here
https://rhettinger.wordpress.com/2011/05/26/super-considered-super/

Marking the PR WIP

@oplatek oplatek changed the title removed unused Trainer kwargs from init WIP:removed unused Trainer kwargs from init Mar 18, 2020
@oplatek
Copy link
Contributor Author

oplatek commented Mar 18, 2020

Maybe we can check if the Trainer is a final class i.e. the constructor is not called from derived class and then performed check on arguments

let me think about how to do it properly

@codecov
Copy link

codecov bot commented Mar 18, 2020

Codecov Report

Merging #1180 into master will not change coverage by %.
The diff coverage is n/a.

@@          Coverage Diff           @@
##           master   #1180   +/-   ##
======================================
  Coverage      89%     89%           
======================================
  Files          62      62           
  Lines        3164    3164           
======================================
  Hits         2810    2810           
  Misses        354     354           

@williamFalcon
Copy link
Contributor

i think it’s there to support inheritance. this is kind of a trivial change that might do more harm than good down the road as we keep evolving the package. my suggestion is to keep it as is.

@Borda
Copy link
Member

Borda commented Mar 25, 2020

i think it’s there to support inheritance. this is kind of a trivial change that might do more harm than good down the road as we keep evolving the package. my suggestion is to keep it as is.

exactly it was my justification when we talked about it in slack and later it was verified by @oplatek so I am closing this on...

@Borda Borda closed this Mar 25, 2020
@Borda Borda mentioned this pull request May 13, 2020
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related feature Is an improvement or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants