Revert "[Feature] specify model in config.yaml (#14855)" (#15293)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
Cyrus Leung
2025-03-21 23:30:23 +08:00
committed by GitHub
parent c21b99b912
commit baec0d4de9
7 changed files with 30 additions and 102 deletions

View File

@@ -1265,29 +1265,19 @@ class FlexibleArgumentParser(argparse.ArgumentParser):
config_args = self._load_config_file(file_path)
# 0th index is for {serve,chat,complete}
# optionally followed by model_tag (only for serve)
# followed by model_tag (only for serve)
# followed by config args
# followed by rest of cli args.
# maintaining this order will enforce the precedence
# of cli > config > defaults
if args[0] == "serve":
model_in_cli = len(args) > 1 and not args[1].startswith('-')
model_in_config = any(arg == '--model' for arg in config_args)
if not model_in_cli and not model_in_config:
if index == 1:
raise ValueError(
"No model specified! Please specify model either in "
"command-line arguments or in config file.")
if model_in_cli:
# Model specified as positional arg, keep CLI version
args = [args[0]] + [
args[1]
] + config_args + args[2:index] + args[index + 2:]
else:
# No model in CLI, use config if available
args = [args[0]
] + config_args + args[1:index] + args[index + 2:]
"No model_tag specified! Please check your command-line"
" arguments.")
args = [args[0]] + [
args[1]
] + config_args + args[2:index] + args[index + 2:]
else:
args = [args[0]] + config_args + args[1:index] + args[index + 2:]
@@ -1305,7 +1295,9 @@ class FlexibleArgumentParser(argparse.ArgumentParser):
'--port': '12323',
'--tensor-parallel-size': '4'
]
"""
extension: str = file_path.split('.')[-1]
if extension not in ('yaml', 'yml'):
raise ValueError(
@@ -1330,15 +1322,7 @@ class FlexibleArgumentParser(argparse.ArgumentParser):
if isinstance(action, StoreBoolean)
]
# Skip model from config if it's provided as positional argument
skip_model = (hasattr(self, '_parsed_args') and self._parsed_args
and len(self._parsed_args) > 1
and self._parsed_args[0] == 'serve'
and not self._parsed_args[1].startswith('-'))
for key, value in config.items():
if skip_model and key == 'model':
continue
if isinstance(value, bool) and key not in store_boolean_arguments:
if value:
processed_args.append('--' + key)