Skip to content

Commit aa64cd9

Browse files
committed
Add workaround for pydantic/pydantic#9541
1 parent 652c6d1 commit aa64cd9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/guidellm/benchmark/scenario.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import yaml
1111
from datasets import Dataset, DatasetDict, IterableDataset, IterableDatasetDict
1212
from loguru import logger
13-
from pydantic import BeforeValidator, Field, PositiveFloat, PositiveInt
13+
from pydantic import BeforeValidator, Field, PositiveFloat, PositiveInt, SkipValidation
1414
from transformers.tokenization_utils_base import ( # type: ignore[import]
1515
PreTrainedTokenizerBase,
1616
)
@@ -115,16 +115,18 @@ class Config:
115115
# types like PreTrainedTokenizerBase
116116
arbitrary_types_allowed = True
117117

118-
data: (
118+
data: Annotated[
119119
Iterable[str]
120120
| Iterable[dict[str, Any]]
121121
| Dataset
122122
| DatasetDict
123123
| IterableDataset
124124
| IterableDatasetDict
125125
| str
126-
| Path
127-
)
126+
| Path,
127+
# BUG: See https://github.com/pydantic/pydantic/issues/9541
128+
SkipValidation,
129+
]
128130
profile: StrategyType | ProfileType | Profile
129131
rate: Annotated[list[PositiveFloat] | None, BeforeValidator(parse_float_list)] = (
130132
None
@@ -159,7 +161,7 @@ def enable_scenarios(func: Callable) -> Any:
159161
@wraps(func)
160162
async def decorator(*args, scenario: Scenario | None = None, **kwargs) -> Any:
161163
if scenario is not None:
162-
kwargs.update(**vars(scenario))
164+
kwargs.update(**scenario.model_dump())
163165
return await func(*args, **kwargs)
164166

165167
# Modify the signature of the decorator to include the `scenario` argument

0 commit comments

Comments
 (0)