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

CLI: fix choices of InteractiveOption not being displayed #5432

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Mar 12, 2022

Fixes #5406

The choices of interactive options were not being displayed in
interactive mode when the special character ? was passed. This bug was
introduced when click_completion was dropped for the tab-completion
feature that ships with click itself as of v8.0. The complete method
changed from complete to shell_complete and the get_help_message
of the InteractiveOption was not properly updated.

@mbercx
Copy link
Member

mbercx commented Mar 14, 2022

Doing a bit of field testing... Seems that the help message doesn't show properly for ON_COMPUTER option:

Installed on target computer? [Y/n]: ?
Error: invalid input

And some options show None next to the choices:

Computer: ?     
Name of the computer, on which the code is installed.
Select one of:
localhost    None
Default calculation input plugin: ?
Entry point name of the default calculation plugin (as listed in 'verdi plugin list aiida.calculations').
Select one of:
aiida.calculations:arithmetic.add None
aiida.calculations:core.arithmetic.add None
[...]

I'm assuming because choice.help is None, but not sure when this is not the case?

The choices of interactive options were not being displayed in
interactive mode when the special character `?` was passed. This bug was
introduced when `click_completion` was dropped for the tab-completion
feature that ships with `click` itself as of `v8.0`. The complete method
changed from `complete` to `shell_complete` and the `get_help_message`
of the `InteractiveOption` was not properly updated.
@sphuber sphuber force-pushed the fix/5406/cli-interactive-option-help-message branch from 6e2740e to 9c5835c Compare March 14, 2022 09:23
@sphuber
Copy link
Contributor Author

sphuber commented Mar 14, 2022

yeah the help always being shown is my bad, pushed a fix. The first problem you highlight is due to something else and not related to this fix. I suspect that the validation of type (which is a boolean) is called before it hits our override. Will look into fixing it

@sphuber
Copy link
Contributor Author

sphuber commented Mar 14, 2022

The problem with the help not being displayed for --on-computer is because it is a boolean flag, and click.Option.prompt_for_value makes an exception in the handling for these types. It doesn't call the prompt of our InteractiveOption (which handles the ? characters) but it goes straight to click.confirm which only allows y and n or otherwise prints invalid input. Don't see an easy way to make this behave nicely without entirely replacing part of their implementation which would be sensitive to breaking in the future.

Copy link
Member

@mbercx mbercx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I won't push the scope creep since we want this in the release, but maybe we should open an issue for the boolean option prompts?

@sphuber
Copy link
Contributor Author

sphuber commented Mar 14, 2022

Alright, I won't push the scope creep since we want this in the release, but maybe we should open an issue for the boolean option prompts?

Yeah I am working on it now and if I cannot fix it soon, will open an issue and describe what I found so far.

@sphuber sphuber merged commit ecec211 into aiidateam:develop Mar 14, 2022
@sphuber sphuber deleted the fix/5406/cli-interactive-option-help-message branch March 14, 2022 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

verdi code setup input plugin prompt does not show the list of calculations for choosing
2 participants