Skip to content

Commit 1e36c86

Browse files
authored
[Deprecation] Remove nullable_kvs (#20969)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
1 parent 5bac613 commit 1e36c86

File tree

3 files changed

+7
-93
lines changed

3 files changed

+7
-93
lines changed

tests/engine/test_arg_utils.py

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
33

44
import json
5-
from argparse import ArgumentError, ArgumentTypeError
5+
from argparse import ArgumentError
66
from contextlib import nullcontext
77
from dataclasses import dataclass, field
88
from typing import Annotated, Literal, Optional
@@ -12,8 +12,8 @@
1212
from vllm.config import CompilationConfig, config
1313
from vllm.engine.arg_utils import (EngineArgs, contains_type, get_kwargs,
1414
get_type, get_type_hints, is_not_builtin,
15-
is_type, literal_to_kwargs, nullable_kvs,
16-
optional_type, parse_type)
15+
is_type, literal_to_kwargs, optional_type,
16+
parse_type)
1717
from vllm.utils import FlexibleArgumentParser
1818

1919

@@ -25,18 +25,10 @@
2525
"foo": 1,
2626
"bar": 2
2727
}),
28-
(json.loads, "foo=1,bar=2", {
29-
"foo": 1,
30-
"bar": 2
31-
}),
3228
])
3329
def test_parse_type(type, value, expected):
3430
parse_type_func = parse_type(type)
35-
context = nullcontext()
36-
if value == "foo=1,bar=2":
37-
context = pytest.warns(DeprecationWarning)
38-
with context:
39-
assert parse_type_func(value) == expected
31+
assert parse_type_func(value) == expected
4032

4133

4234
def test_optional_type():
@@ -203,34 +195,6 @@ def test_get_kwargs():
203195
assert kwargs["from_cli_config2"]["type"]('{"field": 2}').field == 4
204196

205197

206-
@pytest.mark.parametrize(("arg", "expected"), [
207-
(None, dict()),
208-
("image=16", {
209-
"image": 16
210-
}),
211-
("image=16,video=2", {
212-
"image": 16,
213-
"video": 2
214-
}),
215-
("Image=16, Video=2", {
216-
"image": 16,
217-
"video": 2
218-
}),
219-
])
220-
def test_limit_mm_per_prompt_parser(arg, expected):
221-
"""This functionality is deprecated and will be removed in the future.
222-
This argument should be passed as JSON string instead.
223-
224-
TODO: Remove with nullable_kvs."""
225-
parser = EngineArgs.add_cli_args(FlexibleArgumentParser())
226-
if arg is None:
227-
args = parser.parse_args([])
228-
else:
229-
args = parser.parse_args(["--limit-mm-per-prompt", arg])
230-
231-
assert args.limit_mm_per_prompt == expected
232-
233-
234198
@pytest.mark.parametrize(
235199
("arg", "expected"),
236200
[
@@ -326,18 +290,6 @@ def test_prefix_cache_default():
326290
assert not engine_args.enable_prefix_caching
327291

328292

329-
@pytest.mark.parametrize(
330-
("arg"),
331-
[
332-
"image", # Missing =
333-
"image=4,image=5", # Conflicting values
334-
"image=video=4" # Too many = in tokenized arg
335-
])
336-
def test_bad_nullable_kvs(arg):
337-
with pytest.raises(ArgumentTypeError):
338-
nullable_kvs(arg)
339-
340-
341293
# yapf: disable
342294
@pytest.mark.parametrize(("arg", "expected", "option"), [
343295
(None, None, "mm-processor-kwargs"),

tests/entrypoints/openai/test_openai_schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3+
import json
34
from typing import Final
45

56
import pytest
@@ -29,7 +30,7 @@ def server():
2930
"--enforce-eager",
3031
"--trust-remote-code",
3132
"--limit-mm-per-prompt",
32-
f"image={MAXIMUM_IMAGES}",
33+
json.dumps({"image": MAXIMUM_IMAGES}),
3334
]
3435

3536
with RemoteOpenAIServer(MODEL_NAME, args) as remote_server:

vllm/engine/arg_utils.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import regex as re
1919
import torch
2020
from pydantic import TypeAdapter, ValidationError
21-
from typing_extensions import TypeIs, deprecated
21+
from typing_extensions import TypeIs
2222

2323
import vllm.envs as envs
2424
from vllm.config import (BlockSize, CacheConfig, CacheDType, CompilationConfig,
@@ -65,9 +65,6 @@ def parse_type(return_type: Callable[[str], T]) -> Callable[[str], T]:
6565

6666
def _parse_type(val: str) -> T:
6767
try:
68-
if return_type is json.loads and not re.match(
69-
r"(?s)^\s*{.*}\s*$", val):
70-
return cast(T, nullable_kvs(val))
7168
return return_type(val)
7269
except ValueError as e:
7370
raise argparse.ArgumentTypeError(
@@ -93,42 +90,6 @@ def union_dict_and_str(val: str) -> Optional[Union[str, dict[str, str]]]:
9390
return optional_type(json.loads)(val)
9491

9592

96-
@deprecated(
97-
"Passing a JSON argument as a string containing comma separated key=value "
98-
"pairs is deprecated. This will be removed in v0.10.0. Please use a JSON "
99-
"string instead.")
100-
def nullable_kvs(val: str) -> dict[str, int]:
101-
"""Parses a string containing comma separate key [str] to value [int]
102-
pairs into a dictionary.
103-
104-
Args:
105-
val: String value to be parsed.
106-
107-
Returns:
108-
Dictionary with parsed values.
109-
"""
110-
out_dict: dict[str, int] = {}
111-
for item in val.split(","):
112-
kv_parts = [part.lower().strip() for part in item.split("=")]
113-
if len(kv_parts) != 2:
114-
raise argparse.ArgumentTypeError(
115-
"Each item should be in the form KEY=VALUE")
116-
key, value = kv_parts
117-
118-
try:
119-
parsed_value = int(value)
120-
except ValueError as exc:
121-
msg = f"Failed to parse value of item {key}={value}"
122-
raise argparse.ArgumentTypeError(msg) from exc
123-
124-
if key in out_dict and out_dict[key] != parsed_value:
125-
raise argparse.ArgumentTypeError(
126-
f"Conflicting values specified for key: {key}")
127-
out_dict[key] = parsed_value
128-
129-
return out_dict
130-
131-
13293
def is_type(type_hint: TypeHint, type: TypeHintT) -> TypeIs[TypeHintT]:
13394
"""Check if the type hint is a specific type."""
13495
return type_hint is type or get_origin(type_hint) is type

0 commit comments

Comments
 (0)