diff --git a/tests/engine/test_arg_utils.py b/tests/engine/test_arg_utils.py index 86e28c687847..5a91758414a5 100644 --- a/tests/engine/test_arg_utils.py +++ b/tests/engine/test_arg_utils.py @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import json -from argparse import ArgumentError, ArgumentTypeError +from argparse import ArgumentError from contextlib import nullcontext from dataclasses import dataclass, field from typing import Annotated, Literal, Optional @@ -12,8 +12,8 @@ import pytest from vllm.config import CompilationConfig, config from vllm.engine.arg_utils import (EngineArgs, contains_type, get_kwargs, get_type, get_type_hints, is_not_builtin, - is_type, literal_to_kwargs, nullable_kvs, - optional_type, parse_type) + is_type, literal_to_kwargs, optional_type, + parse_type) from vllm.utils import FlexibleArgumentParser @@ -25,18 +25,10 @@ from vllm.utils import FlexibleArgumentParser "foo": 1, "bar": 2 }), - (json.loads, "foo=1,bar=2", { - "foo": 1, - "bar": 2 - }), ]) def test_parse_type(type, value, expected): parse_type_func = parse_type(type) - context = nullcontext() - if value == "foo=1,bar=2": - context = pytest.warns(DeprecationWarning) - with context: - assert parse_type_func(value) == expected + assert parse_type_func(value) == expected def test_optional_type(): @@ -203,34 +195,6 @@ def test_get_kwargs(): assert kwargs["from_cli_config2"]["type"]('{"field": 2}').field == 4 -@pytest.mark.parametrize(("arg", "expected"), [ - (None, dict()), - ("image=16", { - "image": 16 - }), - ("image=16,video=2", { - "image": 16, - "video": 2 - }), - ("Image=16, Video=2", { - "image": 16, - "video": 2 - }), -]) -def test_limit_mm_per_prompt_parser(arg, expected): - """This functionality is deprecated and will be removed in the future. - This argument should be passed as JSON string instead. - - TODO: Remove with nullable_kvs.""" - parser = EngineArgs.add_cli_args(FlexibleArgumentParser()) - if arg is None: - args = parser.parse_args([]) - else: - args = parser.parse_args(["--limit-mm-per-prompt", arg]) - - assert args.limit_mm_per_prompt == expected - - @pytest.mark.parametrize( ("arg", "expected"), [ @@ -326,18 +290,6 @@ def test_prefix_cache_default(): assert not engine_args.enable_prefix_caching -@pytest.mark.parametrize( - ("arg"), - [ - "image", # Missing = - "image=4,image=5", # Conflicting values - "image=video=4" # Too many = in tokenized arg - ]) -def test_bad_nullable_kvs(arg): - with pytest.raises(ArgumentTypeError): - nullable_kvs(arg) - - # yapf: disable @pytest.mark.parametrize(("arg", "expected", "option"), [ (None, None, "mm-processor-kwargs"), diff --git a/tests/entrypoints/openai/test_openai_schema.py b/tests/entrypoints/openai/test_openai_schema.py index aa87cd22fe44..580bf34f20c4 100644 --- a/tests/entrypoints/openai/test_openai_schema.py +++ b/tests/entrypoints/openai/test_openai_schema.py @@ -1,5 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project +import json from typing import Final import pytest @@ -29,7 +30,7 @@ def server(): "--enforce-eager", "--trust-remote-code", "--limit-mm-per-prompt", - f"image={MAXIMUM_IMAGES}", + json.dumps({"image": MAXIMUM_IMAGES}), ] with RemoteOpenAIServer(MODEL_NAME, args) as remote_server: diff --git a/vllm/engine/arg_utils.py b/vllm/engine/arg_utils.py index 500b333926c8..7b73060e3495 100644 --- a/vllm/engine/arg_utils.py +++ b/vllm/engine/arg_utils.py @@ -18,7 +18,7 @@ from typing import (TYPE_CHECKING, Annotated, Any, Callable, Dict, List, import regex as re import torch from pydantic import TypeAdapter, ValidationError -from typing_extensions import TypeIs, deprecated +from typing_extensions import TypeIs import vllm.envs as envs from vllm.config import (BlockSize, CacheConfig, CacheDType, CompilationConfig, @@ -65,9 +65,6 @@ def parse_type(return_type: Callable[[str], T]) -> Callable[[str], T]: def _parse_type(val: str) -> T: try: - if return_type is json.loads and not re.match( - r"(?s)^\s*{.*}\s*$", val): - return cast(T, nullable_kvs(val)) return return_type(val) except ValueError as e: raise argparse.ArgumentTypeError( @@ -93,42 +90,6 @@ def union_dict_and_str(val: str) -> Optional[Union[str, dict[str, str]]]: return optional_type(json.loads)(val) -@deprecated( - "Passing a JSON argument as a string containing comma separated key=value " - "pairs is deprecated. This will be removed in v0.10.0. Please use a JSON " - "string instead.") -def nullable_kvs(val: str) -> dict[str, int]: - """Parses a string containing comma separate key [str] to value [int] - pairs into a dictionary. - - Args: - val: String value to be parsed. - - Returns: - Dictionary with parsed values. - """ - out_dict: dict[str, int] = {} - for item in val.split(","): - kv_parts = [part.lower().strip() for part in item.split("=")] - if len(kv_parts) != 2: - raise argparse.ArgumentTypeError( - "Each item should be in the form KEY=VALUE") - key, value = kv_parts - - try: - parsed_value = int(value) - except ValueError as exc: - msg = f"Failed to parse value of item {key}={value}" - raise argparse.ArgumentTypeError(msg) from exc - - if key in out_dict and out_dict[key] != parsed_value: - raise argparse.ArgumentTypeError( - f"Conflicting values specified for key: {key}") - out_dict[key] = parsed_value - - return out_dict - - def is_type(type_hint: TypeHint, type: TypeHintT) -> TypeIs[TypeHintT]: """Check if the type hint is a specific type.""" return type_hint is type or get_origin(type_hint) is type