-
Notifications
You must be signed in to change notification settings - Fork 192
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
π Improve usage of configure-rabbitmq
#6474
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6474 +/- ##
==========================================
+ Coverage 77.51% 77.76% +0.26%
==========================================
Files 560 561 +1
Lines 41444 41781 +337
==========================================
+ Hits 32120 32487 +367
+ Misses 9324 9294 -30 β View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mbercx . I'm onboard with the suggestion to change the default to being non-interactive behavior. Just some suggestions on the implementation
7577bc8
to
2540606
Compare
@sphuber I made the requested changes:
Here is the usage: β― verdi presto
Report: Option `--use-postgres` not enabled: configuring the profile to use SQLite.
Report: RabbitMQ server not found: configuring the profile without a broker.
Report: Initialising the storage backend.
Report: Storage initialisation completed.
Success: Created new profile `presto-9`.
Success: Configured the localhost as a computer.
β― verdi profile configure-rabbitmq
Warning: Unable to connect to RabbitMQ server with configuration: {'protocol': 'amqp', 'username': 'guest', 'password': 'guest', 'host': '127.0.0.1', 'port': 5672, 'virtual_host': ''}
Do you want to continue with the provided configuration? [y/N]: N
Aborted!
β― brew services start rabbitmq
==> Successfully started `rabbitmq` (label: homebrew.mxcl.rabbitmq)
β― verdi profile configure-rabbitmq
Success: Connected to RabbitMQ with the provided connection parameters
Success: RabbitMQ configuration for `presto-9` updated to: {'protocol': 'amqp', 'username': 'guest', 'password': 'guest', 'host': '127.0.0.1', 'port': 5672, 'virtual_host': ''}
β― brew services stop rabbitmq
Stopping `rabbitmq`... (might take a while)
==> Successfully stopped `rabbitmq` (label: homebrew.mxcl.rabbitmq)
β― verdi profile configure-rabbitmq
Warning: Unable to connect to RabbitMQ server with configuration: {'protocol': 'amqp', 'username': 'guest', 'password': 'guest', 'host': '127.0.0.1', 'port': 5672, 'virtual_host': ''}
Do you want to continue with the provided configuration? [y/N]: N
Aborted!
β― verdi profile configure-rabbitmq -f
Warning: Unable to connect to RabbitMQ server with configuration: {'protocol': 'amqp', 'username': 'guest', 'password': 'guest', 'host': '127.0.0.1', 'port': 5672, 'virtual_host': ''}
Success: RabbitMQ configuration for `presto-9` updated to: {'protocol': 'amqp', 'username': 'guest', 'password': 'guest', 'host': '127.0.0.1', 'port': 5672, 'virtual_host': ''} I was still considering making the final |
@sphuber will update the commits properly once we've agreed on the changes. |
NON_INTERACTIVE = OverridableOption( | ||
'-n', | ||
'--non-interactive', | ||
is_flag=True, | ||
is_eager=True, | ||
help='In non-interactive mode, the CLI never prompts but simply uses default values for options that define one.', | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that wasn't quite the change I was aiming for π
I see the point of wanting to avoid the double negative though. Ok, fine to keep the change, but I think we cannot just remove the NON_INTERACTIVE
option as it is probably used elsewhere. So please reinstate it and just define if as a INTERACTIVE.clone()
. Ideally we would deprecate it, but that will take some doing. We probably would have to add a deprecated
argument to OverridableOption
that is then checked upon option call, or the value parsing. We cannot just do it on import because then it will always show, even if the user is not actually using it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, it can also be used outside of aiida-core
. π€¦ I'll reinstate it for now, we can think of the deprecation path later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Van uitstel komt afstel.....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just redefine it using INTERACTIVE.clone()
though? As I understand it, we can't override the option name, and this would be used in the function definition of the click
command. So I think we need to fully preserve the NON_INTERACTIVE
option if we want to maintain backwards compatibility.
I've added the deprecation warning as requested to avoid afstel. ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So now we are exactly in the situation that I was trying to avoid. We now have two options to do the same thing that need to be maintained and the old one is deprecated. Is all of that faf really necessary just to avoid a double negative in one place? It was working fine before wasn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I hadn't considered that the options were part of the public API. I still think having an INTERACTIVE
switch option makes more sense, but it isn't worth the deprecation. I'll see about turning the NON_INTERACTIVE
option into a proper switch instead.
e87eb5c
to
da8db25
Compare
For many setup/configuration CLI commands, the `NON_INTERACTIVE` option is added to allow the user to run the command without being prompted for input and use the defaults instead. However, new users are often not aware of this option, and will not understand some options as they are prompted. Even when a sensible default is offered by the prompt, users will still want to understand the option and be unsure if the default works for them. Hence, it might be preferable to run it non-interactively by default for some commands. Here we adapt the `NON_INTERACTIVE` option into a switch (`-n/-I` or `--non-interactive`/`--interactive`) that is `--interactive` by default.
The `configure-rabbitmq` command was introduced mainly to allow new users that set up their profile with `verdi presto` before they set up RabbitMQ to upgrade their profile to use the message broker. However, since the command is interactive, they would be prompted for each of the options when running the command without `-n`/`--non-interactive`. Users that don't understand these inputs will typically want to set the defaults, so switching the modus operandi of the commmand to be non-interactive will make life easier for these users. Users that _do_ want to set different values than the defaults will understand the options of the command and should be able to be able to provide them directly or via the interactive mode.
Currently the `verdi profile configure-rabbitmq` command doesn't give any feedback to the user whether the provided options can successfully connect to the RabbitMQ server. Here we adapt the `detect_rabbitmq_config` function to accept the broker configuration as `**kwargs`, and use it to check if the provided options in the `configure-rabbitmq` can successfully connect to the RabbitMQ server. A "success" message is printed if we can connect to the server, else a warning is printed and the user is asked for confirmation before proceeding to configure the broker. A `--force` flag is also added to avoid asking for confirmation in case the command is unable to connect to the broker.
da8db25
to
a49e79a
Compare
@sphuber the |
Fantastic, thanks a lot for going through that effort, much appreciated |
Implements the suggestions in #6454 (comment).
Example UX: