Skip to content

Commit

Permalink
verdi setup: forward broker defaults to interactive mode (aiidateam…
Browse files Browse the repository at this point in the history
…#4405)

The options for the message broker configuration do define defaults,
however, the interactive clones for `verdi setup`, which are defined in
`aiida.cmdline.params.options.commands.setup` override the default with
the `contextual_default` which sets an empty default, unless it is taken
from an existing profile. The result is that for new profiles, the
broker options do not specify a default, even though for most usecases
the defaults will be required. After the changes of this commit, the
prompt of `verdi setup` will provide a default for all broker parameters
so most users will simply have to press enter each time.
  • Loading branch information
sphuber committed Sep 28, 2020
1 parent 1c85bc8 commit cc5af0e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions aiida/cmdline/params/options/commands/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from aiida.cmdline.params import options, types
from aiida.manage.configuration import get_config, get_config_option, Profile
from aiida.manage.external.postgres import DEFAULT_DBINFO
from aiida.manage.external.rmq import BROKER_DEFAULTS

PASSWORD_UNCHANGED = '***' # noqa

Expand Down Expand Up @@ -292,42 +293,44 @@ def get_quicksetup_password(ctx, param, value): # pylint: disable=unused-argume
SETUP_BROKER_PROTOCOL = QUICKSETUP_BROKER_PROTOCOL.clone(
prompt='Broker protocol',
required=True,
contextual_default=functools.partial(get_profile_attribute_default, ('broker_protocol', None)),
contextual_default=functools.partial(get_profile_attribute_default, ('broker_protocol', BROKER_DEFAULTS.protocol)),
cls=options.interactive.InteractiveOption
)

SETUP_BROKER_USERNAME = QUICKSETUP_BROKER_USERNAME.clone(
prompt='Broker username',
required=True,
contextual_default=functools.partial(get_profile_attribute_default, ('broker_username', None)),
contextual_default=functools.partial(get_profile_attribute_default, ('broker_username', BROKER_DEFAULTS.username)),
cls=options.interactive.InteractiveOption
)

SETUP_BROKER_PASSWORD = QUICKSETUP_BROKER_PASSWORD.clone(
prompt='Broker password',
required=True,
contextual_default=functools.partial(get_profile_attribute_default, ('broker_password', None)),
contextual_default=functools.partial(get_profile_attribute_default, ('broker_password', BROKER_DEFAULTS.password)),
cls=options.interactive.InteractiveOption
)

SETUP_BROKER_HOST = QUICKSETUP_BROKER_HOST.clone(
prompt='Broker host',
required=True,
contextual_default=functools.partial(get_profile_attribute_default, ('broker_host', None)),
contextual_default=functools.partial(get_profile_attribute_default, ('broker_host', BROKER_DEFAULTS.host)),
cls=options.interactive.InteractiveOption
)

SETUP_BROKER_PORT = QUICKSETUP_BROKER_PORT.clone(
prompt='Broker port',
required=True,
contextual_default=functools.partial(get_profile_attribute_default, ('broker_port', None)),
contextual_default=functools.partial(get_profile_attribute_default, ('broker_port', BROKER_DEFAULTS.port)),
cls=options.interactive.InteractiveOption
)

SETUP_BROKER_VIRTUAL_HOST = QUICKSETUP_BROKER_VIRTUAL_HOST.clone(
prompt='Broker virtual host name',
required=True,
contextual_default=functools.partial(get_profile_attribute_default, ('broker_virtual_host', None)),
contextual_default=functools.partial(
get_profile_attribute_default, ('broker_virtual_host', BROKER_DEFAULTS.virtual_host)
),
cls=options.interactive.InteractiveOption
)

Expand Down

0 comments on commit cc5af0e

Please sign in to comment.