-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Trainer.from_argparse_args fails on unknown kwargs #1929
Comments
@awaelchli let’s add back kwargs? why did we remove them? |
We removed it because The issue described here is not with Trainer. It is with |
For example, in |
Here's how we could do it: from pytorch_lightning import Trainer
variables = Trainer.__init__.__code__.co_varnames
print(variables) We get a list of accepted args |
@awaelchli Yeah, I figured there would be a way to just filter out the good args. It'll mess up your error that you had when passing in bad args...but perhaps that's for the best? Thank you! |
Yes I'm fine with that if in the argparser there is a misspelled arg, but most users will probably anyway construct their parser with In the PR I made it so that the manually passed in override args are forced to be valid, since they don't come from CLI, e.g. # no error even if argparse_args contains unknown args
Trainer.from_argparse_args(argparse_args, checkpoint_callback=False)
# error
Trainer.from_argparse_args(argparse_args, chckpint_calback=False) What do you think? Is it reasonable? |
Ah, I see what you were getting at. I'll try to leave a review today if I have time. On mobile now, but at a quick glance the code looks good :). |
🐛 Bug
Since
**kwargs
was removed from Trainer's init in #1820, initializingTrainer
objects fails if you have any nonTrainer
specific arguments in your parser.If this is the expected behavior, the docs should be updated to reflect the workaround I mention below, as a few of them would currently fail.
To Reproduce
This works
Trainer init fails on unexpected kwarg 'script_specific_arg'
Trainer init fails on unexpected kwarg 'some_argument'
You can get around it if you init Trainer on temp args
Expected behavior
Trainer.from_argparse_args
should ignore unknown kwargs.Environment
0.7.7.dev0
)Additional context
0.7.6
)The text was updated successfully, but these errors were encountered: