Enforce that model is the first positional arg when --served-model-name is used (#34973)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -184,13 +184,11 @@ class FlexibleArgumentParser(ArgumentParser):
|
||||
if args is None:
|
||||
args = sys.argv[1:]
|
||||
|
||||
# Check for --model in command line arguments first
|
||||
if args and args[0] == "serve":
|
||||
# Check for --model in command line arguments first
|
||||
try:
|
||||
model_idx = next(
|
||||
i
|
||||
for i, arg in enumerate(args)
|
||||
if arg == "--model" or arg.startswith("--model=")
|
||||
i for i, arg in enumerate(args) if re.match(r"^--model(=.+|$)", arg)
|
||||
)
|
||||
logger.warning(
|
||||
"With `vllm serve`, you should provide the model as a "
|
||||
@@ -219,6 +217,19 @@ class FlexibleArgumentParser(ArgumentParser):
|
||||
]
|
||||
except StopIteration:
|
||||
pass
|
||||
# Check for --served-model-name without a positional model argument
|
||||
if (
|
||||
len(args) > 1
|
||||
and args[1].startswith("-")
|
||||
and not any(re.match(r"^--config(=.+|$)", arg) for arg in args)
|
||||
and any(
|
||||
re.match(r"^--served[-_]model[-_]name(=.+|$)", arg) for arg in args
|
||||
)
|
||||
):
|
||||
raise ValueError(
|
||||
"`model` should be provided as the first positional argument when "
|
||||
"using `vllm serve`. i.e. `vllm serve <model> --<arg> <value>`."
|
||||
)
|
||||
|
||||
if "--config" in args:
|
||||
args = self._pull_args_from_config(args)
|
||||
|
||||
Reference in New Issue
Block a user