Skip to content

Commit a55bc60

Browse files
committed
CLI: Remove the RabbitMQ options from verdi profile setup
For the vast majority of use cases, users will have a default setup for RabbitMQ and so the default configuration will be adequate and so they will not need the options in the command. On the flipside, showing the options by default can makes the command harder to use as users will take pause to think what value to pass. Since there is the `verdi profile configure-rabbitmq` command now that allows to configure or reconfigure the RabbitMQ connection parameters for an existing profile, it is fine to remove these options from the profile setup. Advanced users that need to customize the connection parameters can resort to that separate command.
1 parent c2ca642 commit a55bc60

File tree

1 file changed

+9
-33
lines changed

1 file changed

+9
-33
lines changed

src/aiida/cmdline/commands/cmd_profile.py

+9-33
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def command_create_profile(
3939
:param set_as_default: Whether to set the created profile as the new default.
4040
:param kwargs: Arguments to initialise instance of the selected storage implementation.
4141
"""
42+
from aiida.brokers.rabbitmq.defaults import detect_rabbitmq_config
4243
from aiida.plugins.entry_point import get_entry_point_from_class
4344

4445
if not storage_cls.read_only and kwargs.get('email', None) is None:
@@ -52,22 +53,15 @@ def command_create_profile(
5253
_, storage_entry_point = get_entry_point_from_class(storage_cls.__module__, storage_cls.__name__)
5354
assert storage_entry_point is not None
5455

55-
if kwargs.pop('use_rabbitmq'):
56-
broker_backend = 'core.rabbitmq'
57-
broker_config = {
58-
key: kwargs.get(key)
59-
for key in (
60-
'broker_protocol',
61-
'broker_username',
62-
'broker_password',
63-
'broker_host',
64-
'broker_port',
65-
'broker_virtual_host',
66-
)
67-
}
56+
broker_config = detect_rabbitmq_config()
57+
broker_backend = 'core.rabbitmq' if kwargs.get('use_rabbitmq', False) else None
58+
59+
if broker_config is None:
60+
echo.echo_warning('RabbitMQ server not found: configuring the profile without a broker.')
6861
else:
69-
broker_backend = None
70-
broker_config = None
62+
echo.echo_success('RabbitMQ server detected: configuring the profile with a broker.')
63+
64+
echo.echo_report('RabbitMQ connection parameters can be reconfigured with `verdi profile configure-rabbitmq`.')
7165

7266
try:
7367
profile = create_profile(
@@ -104,24 +98,6 @@ def command_create_profile(
10498
setup.SETUP_USER_LAST_NAME(),
10599
setup.SETUP_USER_INSTITUTION(),
106100
setup.SETUP_USE_RABBITMQ(),
107-
setup.SETUP_BROKER_PROTOCOL(
108-
prompt_fn=lambda ctx: ctx.params['use_rabbitmq'], required_fn=lambda ctx: ctx.params['use_rabbitmq']
109-
),
110-
setup.SETUP_BROKER_USERNAME(
111-
prompt_fn=lambda ctx: ctx.params['use_rabbitmq'], required_fn=lambda ctx: ctx.params['use_rabbitmq']
112-
),
113-
setup.SETUP_BROKER_PASSWORD(
114-
prompt_fn=lambda ctx: ctx.params['use_rabbitmq'], required_fn=lambda ctx: ctx.params['use_rabbitmq']
115-
),
116-
setup.SETUP_BROKER_HOST(
117-
prompt_fn=lambda ctx: ctx.params['use_rabbitmq'], required_fn=lambda ctx: ctx.params['use_rabbitmq']
118-
),
119-
setup.SETUP_BROKER_PORT(
120-
prompt_fn=lambda ctx: ctx.params['use_rabbitmq'], required_fn=lambda ctx: ctx.params['use_rabbitmq']
121-
),
122-
setup.SETUP_BROKER_VIRTUAL_HOST(
123-
prompt_fn=lambda ctx: ctx.params['use_rabbitmq'], required_fn=lambda ctx: ctx.params['use_rabbitmq']
124-
),
125101
],
126102
)
127103
def profile_setup():

0 commit comments

Comments
 (0)