-
Notifications
You must be signed in to change notification settings - Fork 191
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
Swapped pyinquirer with questionary #799
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #799 +/- ##
==========================================
- Coverage 82.97% 82.88% -0.10%
==========================================
Files 13 13
Lines 2726 2717 -9
==========================================
- Hits 2262 2252 -10
- Misses 464 465 +1
Continue to review full report at Codecov.
|
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.
Wow, this really was an easy switch! Hardly any code at all. Kudos @KevinMenden for actually sitting down and doing this - great work!
- Love that the currently selected option in a Select list has a highlighted background!
I notice that we're still shuffling the default option to the top of the list. Does Questionary support creating a list with the pointer at a given default instead of always being on the first option?(Sounds like no?)- Similar: we're still using the
if answer == {}: raise KeyboardInterrupt
hack to capturectrl-c
events. Can Questionary allowKeyboardInterrupt
events to bubbled to our code without capturing them first? If so could remove this hack. (Sounds like yes?) - Something I could never do with PyInquirer: Is it possible to show one thing in a Select list but return a different value?
- What I originally wanted to do was to show the default / filled in value for each option in a group. For example:
--my_param [foo]
. But this broke PyInquirer, as the select list would only take value so had to have just--my_param
to work. - Would be awesome if we could show the given values for each option in the group list view, bonus points by colouring if different to the schema default.
- What I originally wanted to do was to show the default / filled in value for each option in a group. For example:
- Select dropdown prompt - can we customise this to get the nice orange arrow back? 🤓 (not a dealbreaker)
Phew, finally managed to break it.. I was starting to get worried. Running nf-core launch atacseq --show-hidden
and navigate through to --publish_dir_mode
. This option uses enum
to limit the allowed return values. Typing in random jibberish gave the following traceback:
│ /opt/miniconda3/envs/py3.8/lib/python3.8/site-packages/questionary/prompts/common.py:448 in create_inquirer_layout │
│ │
│ 445 ) -> Layout: │
│ 446 │ """Create a layout combining question and inquirer selection.""" │
│ 447 │ │
│ ❱ 448 │ ps = PromptSession(get_prompt_tokens, reserve_space_for_menu=0, **kwargs) │
│ 449 │ _fix_unecessary_blank_lines(ps) │
│ 450 │ │
│ 451 │ validation_prompt = PromptSession(bottom_toolbar=lambda: ic.error_message, **kwargs)
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: __init__() got an unexpected keyword argument 'validate'
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.
Couple of super minor things
Co-authored-by: Phil Ewels <[email protected]>
Thanks for the review Phil and sorry for the typos! And especially thanks for breaking it :D I'll have a look into that :) Yes it was hardly any brainwork - really simply swapping the two. Probably possible because the questionary code was based on PyInyquirer to some extent, that's why they are so similar.
|
Good news, there was a PR 2 months back that introduced the default option in questionary. So we can just comment-out the workaround code and default options are automatically selected. Questionary also 'catches' keyboard interrupts, but instead of exiting it just returns Bad news is, the error you encountered is caused because in questionary, |
|
Okay so for now I have commented all things related to the validator for 'enum' objects --> I was wondering whether we actually need validation of the input there? Because it is a selection from a list, the user shouldn't have the option to pass wrong inputs - or am I missing something? Tried to monkey-patch your arrow back in, but it didn't work somehow :/ but at least now it's orange again! Didn't find any specific feature that would allow to do what you suggest in point 4. So we'd have to code it ourselves I guess, if that's even possible. |
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.
Quick code review on my phone, will try to test again when I get a chance.
This is looking brilliant - it makes me very happy to see my hacks and workarounds being removed! 😄
Co-authored-by: Phil Ewels <[email protected]>
Co-authored-by: Phil Ewels <[email protected]>
Co-authored-by: Phil Ewels <[email protected]>
Co-authored-by: Phil Ewels <[email protected]>
* Use ANSI colours instead of hex values, so that colours honour the terminal settings (and match the nf-core logo) * Show the value for each parameter in the select list - either the default from the schema or the entered value
Turns out that you can do this with Questionary! It accepts both I pushed a change to add this above, so now we get either the entered value, or the schema default in square brackets in the list view:
This is super cool! Makes the interface a lot more usable as you can see at a glance that I'd love to have the default values printed in a different colour, but I couldn't figure out how to do that and have run out of time. |
Also, I changed the colours - I hope that's ok! Instead of absolute hex codes, I switched to ANSI colour codes. This means that the colours (a) should exactly match the nf-core ANSI logo, which also uses the same codes, and (b) will change according to the colour scheme that people have set on their terminal. |
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.
Looks great now! If you're happy with my changes then please merge 🚀
Awesome, I completely oversaw that. That's indeed pretty neat :-) |
I'm not sure that it was actually documented it anywhere? I only found it when digging around in the questionary code base.. |
Yes same for the other things - they could certainly use a better documentation ... but I understand that it's not what developers like to do :) |
PR checklist
CHANGELOG.md
is updateddocs
is updatedTo resolve #726 , swapped PyInquirer with questionary in
launch.py
andsetup.py
Installed locally and
nf-core launch
seemed to behave as expected.