Skip to content

Commit 5618647

Browse files
authored
[Docs] Reduce noise in docs and --help from the JSON tip (#22567)
Signed-off-by: Harry Mellor <[email protected]>
1 parent 1bf5e1f commit 5618647

File tree

4 files changed

+40
-24
lines changed

4 files changed

+40
-24
lines changed

docs/cli/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ Available Commands:
1616
vllm {chat,complete,serve,bench,collect-env,run-batch}
1717
```
1818

19+
When passing JSON CLI arguments, the following sets of arguments are equivalent:
20+
21+
- `--json-arg '{"key1": "value1", "key2": {"key3": "value2"}}'`
22+
- `--json-arg.key1 value1 --json-arg.key2.key3 value2`
23+
24+
Additionally, list elements can be passed individually using `+`:
25+
26+
- `--json-arg '{"key4": ["value3", "value4", "value5"]}'`
27+
- `--json-arg.key4+ value3 --json-arg.key4+='value4,value5'`
28+
1929
## serve
2030

2131
Start the vLLM OpenAI Compatible API server.

docs/configuration/engine_args.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ Engine arguments control the behavior of the vLLM engine.
1111

1212
The engine argument classes, [EngineArgs][vllm.engine.arg_utils.EngineArgs] and [AsyncEngineArgs][vllm.engine.arg_utils.AsyncEngineArgs], are a combination of the configuration classes defined in [vllm.config][]. Therefore, if you are interested in developer documentation, we recommend looking at these configuration classes as they are the source of truth for types, defaults and docstrings.
1313

14+
When passing JSON CLI arguments, the following sets of arguments are equivalent:
15+
16+
- `--json-arg '{"key1": "value1", "key2": {"key3": "value2"}}'`
17+
- `--json-arg.key1 value1 --json-arg.key2.key3 value2`
18+
19+
Additionally, list elements can be passed individually using `+`:
20+
21+
- `--json-arg '{"key4": ["value3", "value4", "value5"]}'`
22+
- `--json-arg.key4+ value3 --json-arg.key4+='value4,value5'`
23+
1424
## `EngineArgs`
1525

1626
--8<-- "docs/argparse/engine_args.md"

vllm/engine/arg_utils.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,8 @@ def _compute_kwargs(cls: ConfigType) -> dict[str, Any]:
178178
kwargs[name] = {"default": default, "help": help}
179179

180180
# Set other kwargs based on the type hints
181-
json_tip = """Should either be a valid JSON string or JSON keys
182-
passed individually. For example, the following sets of arguments are
183-
equivalent:
184-
185-
- `--json-arg '{"key1": "value1", "key2": {"key3": "value2"}}'`\n
186-
- `--json-arg.key1 value1 --json-arg.key2.key3 value2`
187-
188-
Additionally, list elements can be passed individually using `+`:
189-
190-
- `--json-arg '{"key4": ["value3", "value4", "value5"]}'`\n
191-
- `--json-arg.key4+ value3 --json-arg.key4+='value4,value5'`"""
181+
json_tip = ("Should either be a valid JSON string or JSON keys passed "
182+
"individually.")
192183
if dataclass_cls is not None:
193184

194185
def parse_dataclass(val: str, cls=dataclass_cls) -> Any:
@@ -1831,13 +1822,3 @@ def human_readable_int(value):
18311822

18321823
# Regular plain number.
18331824
return int(value)
1834-
1835-
1836-
# These functions are used by sphinx to build the documentation
1837-
def _engine_args_parser():
1838-
return EngineArgs.add_cli_args(FlexibleArgumentParser())
1839-
1840-
1841-
def _async_engine_args_parser():
1842-
return AsyncEngineArgs.add_cli_args(FlexibleArgumentParser(),
1843-
async_args_only=True)

vllm/utils/__init__.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,11 +1669,19 @@ class FlexibleArgumentParser(ArgumentParser):
16691669
"""ArgumentParser that allows both underscore and dash in names."""
16701670

16711671
_deprecated: set[Action] = set()
1672+
_json_tip: str = (
1673+
"When passing JSON CLI arguments, the following sets of arguments "
1674+
"are equivalent:\n"
1675+
' --json-arg \'{"key1": "value1", "key2": {"key3": "value2"}}\'\n'
1676+
" --json-arg.key1 value1 --json-arg.key2.key3 value2\n\n"
1677+
"Additionally, list elements can be passed individually using +:\n"
1678+
' --json-arg \'{"key4": ["value3", "value4", "value5"]}\'\n'
1679+
" --json-arg.key4+ value3 --json-arg.key4+=\'value4,value5\'\n\n")
16721680

16731681
def __init__(self, *args, **kwargs):
1674-
# Set the default 'formatter_class' to SortedHelpFormatter
1675-
if 'formatter_class' not in kwargs:
1676-
kwargs['formatter_class'] = SortedHelpFormatter
1682+
# Set the default "formatter_class" to SortedHelpFormatter
1683+
if "formatter_class" not in kwargs:
1684+
kwargs["formatter_class"] = SortedHelpFormatter
16771685
super().__init__(*args, **kwargs)
16781686

16791687
if sys.version_info < (3, 13):
@@ -1715,6 +1723,13 @@ def add_argument_group(self, *args, **kwargs):
17151723
self._action_groups.append(group)
17161724
return group
17171725

1726+
def format_help(self) -> str:
1727+
# Add tip about JSON arguments to the epilog
1728+
epilog = self.epilog or ""
1729+
if not epilog.startswith(FlexibleArgumentParser._json_tip):
1730+
self.epilog = FlexibleArgumentParser._json_tip + epilog
1731+
return super().format_help()
1732+
17181733
def parse_args( # type: ignore[override]
17191734
self,
17201735
args: list[str] | None = None,

0 commit comments

Comments
 (0)