Skip to content

Commit 85cf65e

Browse files
Merge branch 'main' into feat/over-saturation-stopping
2 parents 6e834fc + 38f1738 commit 85cf65e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/guidellm/benchmark/schemas.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,26 @@ def get_default(cls: type[BenchmarkGenerativeTextArgs], field: str) -> Any:
19571957
description="Whether to stop the benchmark if the model is over-saturated",
19581958
)
19591959

1960+
@field_validator("data", "data_args", "rate", mode="wrap")
1961+
@classmethod
1962+
def single_to_list(
1963+
cls, value: Any, handler: ValidatorFunctionWrapHandler
1964+
) -> list[Any]:
1965+
"""
1966+
Ensures field is always a list.
1967+
1968+
:param value: Input value for the 'data' field
1969+
:return: List of data sources
1970+
"""
1971+
try:
1972+
return handler(value)
1973+
except ValidationError as err:
1974+
# If validation fails, try wrapping the value in a list
1975+
if err.errors()[0]["type"] == "list_type":
1976+
return handler([value])
1977+
else:
1978+
raise
1979+
19601980
@field_validator("data", "data_args", "rate", mode="wrap")
19611981
@classmethod
19621982
def single_to_list(

0 commit comments

Comments
 (0)