[Feature] Change cache.py with pydantic validation (#26390)
Signed-off-by: Vinay Damodaran <vrdn@hey.com> Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
e09d1753ec
commit
b25d7b5657
@@ -27,6 +27,7 @@ import huggingface_hub
|
||||
import regex as re
|
||||
import torch
|
||||
from pydantic import TypeAdapter, ValidationError
|
||||
from pydantic.fields import FieldInfo
|
||||
from typing_extensions import TypeIs, deprecated
|
||||
|
||||
import vllm.envs as envs
|
||||
@@ -209,6 +210,13 @@ def _compute_kwargs(cls: ConfigType) -> dict[str, Any]:
|
||||
# Get the default value of the field
|
||||
if field.default is not MISSING:
|
||||
default = field.default
|
||||
# Handle pydantic.Field defaults
|
||||
if isinstance(default, FieldInfo):
|
||||
default = (
|
||||
default.default
|
||||
if default.default_factory is None
|
||||
else default.default_factory()
|
||||
)
|
||||
elif field.default_factory is not MISSING:
|
||||
default = field.default_factory()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user