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

Allow Spaces in `--channel-order` Argument #731

Merged
merged 3 commits into from Mar 27, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -211,6 +211,37 @@ def ls(experiment_module, arg):
click.echo('{}'.format(e.id))


# https://stackoverflow.com/questions/48391777/nargs-equivalent-for-options-in-click
class OptionEatAll(click.Option):
def __init__(self, *args, **kwargs):
self.save_other_options = kwargs.pop('save_other_options', True)
nargs = kwargs.pop('nargs', -1)
assert nargs == -1, 'nargs, if set, must be -1 not {}'.format(nargs)
super(OptionEatAll, self).__init__(*args, **kwargs)
self._previous_parser_process = None
self._eat_all_parser = None

def add_to_parser(self, parser, ctx):
def parser_process(value, state):
value = str(value)
while state.rargs:
value = '{} {}'.format(value, state.rargs.pop(0))
self._previous_parser_process(value, state)

retval = super(OptionEatAll, self).add_to_parser(parser, ctx)

for name in self.opts:
our_parser = parser._long_opt.get(name) or parser._short_opt.get(
name)
if our_parser:
self._eat_all_parser = our_parser
self._previous_parser_process = our_parser.process
our_parser.process = parser_process
break

return retval


@main.command(
'predict', short_help='Make predictions using a predict package.')
@click.argument('predict_package')
@@ -225,6 +256,7 @@ def ls(experiment_module, arg):
'that exist in the prediction package'))
@click.option(
'--channel-order',
cls=OptionEatAll,
help='String containing channel_order. Example: \"2 1 0\"')
This conversation was marked as resolved by lewfish

This comment has been minimized.

Copy link
@lewfish

lewfish Mar 27, 2019

Contributor

Docs need to be updated since the syntax is now --channel-order 2 1 0

@click.option(
'--export-config',
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.