Unverified Commit 5b31cb17 authored by dubejf's avatar dubejf Committed by GitHub
Browse files

[Bugfix] Fix --config arg expansion called from api_server.py (#23944)


Signed-off-by: default avatarJean-Francois Dube <dubejf+gh@gmail.com>
Co-authored-by: default avatarJean-Francois Dube <dubejf+gh@gmail.com>
Co-authored-by: default avatarCyrus Leung <tlleungac@connect.ust.hk>
parent d660c98c
...@@ -27,6 +27,28 @@ def serve_parser(): ...@@ -27,6 +27,28 @@ def serve_parser():
return make_arg_parser(parser) return make_arg_parser(parser)
### Test config parsing
def test_config_arg_parsing(serve_parser, cli_config_file):
args = serve_parser.parse_args([])
assert args.port == 8000
args = serve_parser.parse_args(['--config', cli_config_file])
assert args.port == 12312
args = serve_parser.parse_args([
'--config',
cli_config_file,
'--port',
'9000',
])
assert args.port == 9000
args = serve_parser.parse_args([
'--port',
'9000',
'--config',
cli_config_file,
])
assert args.port == 9000
### Tests for LoRA module parsing ### Tests for LoRA module parsing
def test_valid_key_value_format(serve_parser): def test_valid_key_value_format(serve_parser):
# Test old format: name=path # Test old format: name=path
......
...@@ -1976,13 +1976,16 @@ class FlexibleArgumentParser(ArgumentParser): ...@@ -1976,13 +1976,16 @@ class FlexibleArgumentParser(ArgumentParser):
config_args = self.load_config_file(file_path) config_args = self.load_config_file(file_path)
# 0th index is for {serve,chat,complete} # 0th index might be the sub command {serve,chat,complete,...}
# optionally followed by model_tag (only for serve) # optionally followed by model_tag (only for serve)
# followed by config args # followed by config args
# followed by rest of cli args. # followed by rest of cli args.
# maintaining this order will enforce the precedence # maintaining this order will enforce the precedence
# of cli > config > defaults # of cli > config > defaults
if args[0] == "serve": if args[0].startswith('-'):
# No sub command (e.g., api_server entry point)
args = config_args + args[0:index] + args[index + 2:]
elif args[0] == "serve":
model_in_cli = len(args) > 1 and not args[1].startswith('-') model_in_cli = len(args) > 1 and not args[1].startswith('-')
model_in_config = any(arg == '--model' for arg in config_args) model_in_config = any(arg == '--model' for arg in config_args)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment