Skip to content

Commit 5b31cb1

Browse files
dubejfJean-Francois DubeDarkLight1337
authored
[Bugfix] Fix --config arg expansion called from api_server.py (#23944)
Signed-off-by: Jean-Francois Dube <dubejf+gh@gmail.com> Co-authored-by: Jean-Francois Dube <dubejf+gh@gmail.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
1 parent d660c98 commit 5b31cb1

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

tests/entrypoints/openai/test_cli_args.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@ def serve_parser():
2727
return make_arg_parser(parser)
2828

2929

30+
### Test config parsing
31+
def test_config_arg_parsing(serve_parser, cli_config_file):
32+
args = serve_parser.parse_args([])
33+
assert args.port == 8000
34+
args = serve_parser.parse_args(['--config', cli_config_file])
35+
assert args.port == 12312
36+
args = serve_parser.parse_args([
37+
'--config',
38+
cli_config_file,
39+
'--port',
40+
'9000',
41+
])
42+
assert args.port == 9000
43+
args = serve_parser.parse_args([
44+
'--port',
45+
'9000',
46+
'--config',
47+
cli_config_file,
48+
])
49+
assert args.port == 9000
50+
51+
3052
### Tests for LoRA module parsing
3153
def test_valid_key_value_format(serve_parser):
3254
# Test old format: name=path

vllm/utils/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,13 +1976,16 @@ def _pull_args_from_config(self, args: list[str]) -> list[str]:
19761976

19771977
config_args = self.load_config_file(file_path)
19781978

1979-
# 0th index is for {serve,chat,complete}
1979+
# 0th index might be the sub command {serve,chat,complete,...}
19801980
# optionally followed by model_tag (only for serve)
19811981
# followed by config args
19821982
# followed by rest of cli args.
19831983
# maintaining this order will enforce the precedence
19841984
# of cli > config > defaults
1985-
if args[0] == "serve":
1985+
if args[0].startswith('-'):
1986+
# No sub command (e.g., api_server entry point)
1987+
args = config_args + args[0:index] + args[index + 2:]
1988+
elif args[0] == "serve":
19861989
model_in_cli = len(args) > 1 and not args[1].startswith('-')
19871990
model_in_config = any(arg == '--model' for arg in config_args)
19881991

0 commit comments

Comments
 (0)