Skip to content

Commit

Permalink
Merge ad699b4 into 05133f5
Browse files Browse the repository at this point in the history
  • Loading branch information
shabazpatel committed Jul 20, 2018
2 parents 05133f5 + ad699b4 commit e0b0fe4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
38 changes: 23 additions & 15 deletions datmo/cli/driver/helper.py
Expand Up @@ -168,28 +168,36 @@ def prompt_available_options(self, available_options, option_type):
self.echo("(%s) %s" % (idx + 1, option))
input_environment_option = self.prompt(
__("prompt", "cli.environment.setup.%s" % option_type))
try:
if input_environment_option:
option_environment_index = int(input_environment_option)
else:
raise ValueError
except ValueError:
option_environment_index = None
valid_option = False
while input_environment_option is not None and not valid_option:
try:
option_environment_index = available_options.index(
input_environment_option) + 1
option_environment_index = int(input_environment_option)
if 0 < option_environment_index <= len(available_options):
valid_option = True
else:
raise ValueError
except ValueError:
self.echo(
__("warn",
"cli.environment.setup.argument.%s" % option_type,
input_environment_option))
option_environment_index, input_environment_option = None, None
if option_environment_index is not None and \
0 < option_environment_index <= len(available_options):
try:
option_environment_index = available_options.index(
input_environment_option) + 1
valid_option = True
except ValueError:
self.echo(
__("warn",
"cli.environment.setup.argument.unavailable.%s" % option_type,
input_environment_option))
input_environment_option = self.prompt(
__("prompt", "cli.environment.setup.%s" % option_type))
if option_environment_index is not None:
input_environment_option = available_options[
option_environment_index - 1]

if input_environment_option is None or option_environment_index <= 0 or\
option_environment_index > len(available_options):
self.echo(
__("warn",
"cli.environment.setup.argument.%s" % option_type))
if option_type == "type":
input_environment_option = "cpu"
elif option_type == "framework":
Expand Down
3 changes: 2 additions & 1 deletion datmo/cli/parser.py
Expand Up @@ -417,7 +417,8 @@ def get_datmo_parser():

snapshot_create = snapshot_subcommand_parsers.add_parser(
"create",
description=__("argparser", "cli.snapshot.create.description"))
description=__("argparser", "cli.snapshot.create.description"),
help="create a snapshot")
snapshot_create.add_argument(
"--message",
"-m",
Expand Down
12 changes: 9 additions & 3 deletions datmo/core/util/lang/en.py
Expand Up @@ -116,12 +116,18 @@
"Error cleaning up project code",
"controller.project.cleanup.files":
"Error cleaning up project files",
"cli.environment.setup.argument.unavailable.type":
"This name or index does not match any supported environment types: %s, please re-enter the type",
"cli.environment.setup.argument.unavailable.framework":
"This name or index does not match any supported environment frameworks: %s, please re-enter the framework",
"cli.environment.setup.argument.unavailable.language":
"This name or index does not match any supported environment language: %s, please re-enter the option",
"cli.environment.setup.argument.type":
"This name or index does not match any supported environment types: %s, using default: cpu ",
"No user input detected for environment type, defaulting to option: cpu",
"cli.environment.setup.argument.framework":
"This name or index does not match any supported environments: %s, using default: python-base",
"No user input detected for environment framework, defaulting to option: python-base",
"cli.environment.setup.argument.language":
"This name or index does not match any supported environment language: %s, using default: py27",
"No user input detected for environment language, defaulting to option: py27",
},
"error": {
"exception.validationfailed":
Expand Down

0 comments on commit e0b0fe4

Please sign in to comment.