mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-09 11:32:07 +08:00
✨ Use store_true for bool args (#1822)
* ✨ Use store_true for bool args * debug Co-authored-by: Nate Raw <nxr9266@g.rit.edu>
This commit is contained in:
co-authored by
Nate Raw
parent
e961f7e344
commit
648d516668
@@ -667,6 +667,16 @@ class Trainer(
|
||||
def allowed_type(x):
|
||||
return bool(parsing.strtobool(x))
|
||||
|
||||
# Bool args with default of True parsed as flags not key value pair
|
||||
if arg_types == (bool,) and arg_default is False:
|
||||
parser.add_argument(
|
||||
f'--{arg}',
|
||||
action='store_true',
|
||||
dest=arg,
|
||||
help='autogenerated by pl.Trainer'
|
||||
)
|
||||
continue
|
||||
|
||||
if arg == 'gpus':
|
||||
allowed_type = Trainer.allowed_type
|
||||
arg_default = Trainer.arg_default
|
||||
|
||||
@@ -30,7 +30,7 @@ def test_default_args(tmpdir):
|
||||
|
||||
@pytest.mark.parametrize('cli_args', [
|
||||
['--accumulate_grad_batches=22'],
|
||||
['--print_nan_grads=1', '--weights_save_path=./'],
|
||||
['--print_nan_grads', '--weights_save_path=./'],
|
||||
[]
|
||||
])
|
||||
def test_add_argparse_args_redefined(cli_args):
|
||||
|
||||
Reference in New Issue
Block a user