-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Implement 2-phase parser with greedy subparsers #12910
Conversation
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.
Just some naming issues, interesting approach, I like it!
Co-authored-by: Jannis Leidel <jannis@leidel.info>
|
@kenodegard, those performance statistics don't look too good 😦... If I'm reading it correctly, we're seeing a 32% slow down for the mean run times of |
Also, another concern I have with the output of
Which isn't the case. I don't think the underlying implementation mechanism for how the subcommands are discovered really matters at all to our end users. Does it make sense to simply remove the Furthermore, those descriptions don't really make sense. Do we really want users to invoke |
Some more benchmarks: Data
using
I interpret this as meaning the slowdown was introduced in some other change since |
Description
Splits CLI parser into a 2-phase parser. Phase 1 only parses
conda
's options (e.g.,conda --json
,conda --no-plugins
, etc.) allowing us to disable plugins before generating the complete parser for phase 2. A benefit of the 2-phase parser is any option parsed in phase 1 can appear anywhere on the CLI, so the following are identical:Note that
conda doctor
has not explicitly defined--json
as one of its arguments:conda/conda/plugins/subcommands/doctor/cli.py
Lines 22 to 30 in b89a147
In addition to the 2-phase parser we also implement a custom
argparse._SubParserAction
that will greedily consume all unmatched arguments, this is the change that resolves theargparse.REMAINDER
issue.Resolves #12906
Checklist - did you ...
news
directory (using the template) for the next release's release notes?Add / update outdated documentation?