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

Clean up Argparse interface with trainer #1606

Merged
merged 15 commits into from
Apr 26, 2020
12 changes: 9 additions & 3 deletions pytorch_lightning/trainer/trainer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import distutils
import inspect
import os
from argparse import ArgumentParser
Expand Down Expand Up @@ -599,7 +598,8 @@ def add_argparse_args(cls, parent_parser: ArgumentParser) -> ArgumentParser:
"""
parser = ArgumentParser(parents=[parent_parser], add_help=False, )

depr_arg_names = cls.get_deprecated_arg_names()
blacklist = ['kwargs']
depr_arg_names = cls.get_deprecated_arg_names() + blacklist

allowed_types = (str, float, int, bool)
# TODO: get "help" from docstring :)
Expand All @@ -609,7 +609,13 @@ def add_argparse_args(cls, parent_parser: ArgumentParser) -> ArgumentParser:
for allowed_type in (at for at in allowed_types if at in arg_types):
if allowed_type is bool:
def allowed_type(x):
return bool(distutils.util.strtobool(x))
# distutils.util.strtobool() has issues
if x.lower() == 'true':
return True
elif x.lower() == 'false':
return False
else:
Borda marked this conversation as resolved.
Show resolved Hide resolved
raise Exception('bool not specified')

if arg == 'gpus':
def allowed_type(x):
Expand Down