Skip to content

Commit

Permalink
[Misc] vllm CLI flags should be ordered for better user readability (v…
Browse files Browse the repository at this point in the history
…llm-project#10017)

Signed-off-by: chaunceyjiang <[email protected]>
Signed-off-by: Tyler Michael Smith <[email protected]>
  • Loading branch information
chaunceyjiang authored and tlrmchlsmth committed Nov 23, 2024
1 parent 4d335ab commit 640b7f1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions vllm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,9 +1148,23 @@ def __call__(self, parser, namespace, values, option_string=None):
"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:]
Expand Down

0 comments on commit 640b7f1

Please sign in to comment.