[Misc] vllm CLI flags should be ordered for better user readability (#10017)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
This commit is contained in:
Chauncey 2024-11-05 18:59:56 +08:00 committed by GitHub
parent 7a83b1aec0
commit 93dee88f6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1148,9 +1148,23 @@ class StoreBoolean(argparse.Action):
"Expected 'true' or 'false'.")
class SortedHelpFormatter(argparse.HelpFormatter):
"""SortedHelpFormatter that sorts arguments by their option strings."""
def add_arguments(self, actions):
actions = sorted(actions, key=lambda x: x.option_strings)
super(SortedHelpFormatter, self).add_arguments(actions)
class FlexibleArgumentParser(argparse.ArgumentParser):
"""ArgumentParser that allows both underscore and dash in names."""
def __init__(self, *args, **kwargs):
# Set the default 'formatter_class' to SortedHelpFormatter
if 'formatter_class' not in kwargs:
kwargs['formatter_class'] = SortedHelpFormatter
super().__init__(*args, **kwargs)
def parse_args(self, args=None, namespace=None):
if args is None:
args = sys.argv[1:]