2424from guidellm .benchmark .progress import BenchmarkerProgressGroup
2525from guidellm .benchmark .scenario import enable_scenarios
2626from guidellm .benchmark .types import (
27- OutputFormatType ,
28- DataInputType ,
29- ProcessorInputType ,
30- ProgressInputType ,
31- AggregatorInputType
27+ AggregatorInputT ,
28+ DataInputT ,
29+ OutputFormatT ,
30+ ProcessorInputT ,
31+ ProgressInputT ,
3232)
3333from guidellm .request import GenerativeRequestLoader
3434from guidellm .scheduler import (
4949
5050# Helper functions
5151
52+
5253async def initialize_backend (
5354 backend : BackendType | Backend ,
5455 target : str ,
5556 model : str | None ,
5657 backend_kwargs : dict [str , Any ] | None ,
5758) -> Backend :
5859 backend = (
59- Backend .create (
60- backend , target = target , model = model , ** (backend_kwargs or {})
61- )
60+ Backend .create (backend , target = target , model = model , ** (backend_kwargs or {}))
6261 if not isinstance (backend , Backend )
6362 else backend
6463 )
@@ -95,18 +94,19 @@ async def resolve_profile(
9594 )
9695 return profile
9796
97+
9898async def resolve_output_formats (
99- output_formats : OutputFormatType ,
99+ output_formats : OutputFormatT ,
100100 output_path : str | Path | None ,
101101) -> dict [str , GenerativeBenchmarkerOutput ]:
102- output_formats = GenerativeBenchmarkerOutput .resolve (
102+ return GenerativeBenchmarkerOutput .resolve (
103103 output_formats = (output_formats or {}), output_path = output_path
104104 )
105- return output_formats
105+
106106
107107async def finalize_outputs (
108108 report : GenerativeBenchmarksReport ,
109- resolved_output_formats : dict [str , GenerativeBenchmarkerOutput ]
109+ resolved_output_formats : dict [str , GenerativeBenchmarkerOutput ],
110110):
111111 output_format_results = {}
112112 for key , output in resolved_output_formats .items ():
@@ -122,7 +122,7 @@ async def finalize_outputs(
122122@enable_scenarios
123123async def benchmark_generative_text ( # noqa: C901
124124 target : str ,
125- data : DataInputType ,
125+ data : DataInputT ,
126126 profile : StrategyType | ProfileType | Profile ,
127127 rate : list [float ] | None = None ,
128128 random_seed : int = 42 ,
@@ -131,18 +131,18 @@ async def benchmark_generative_text( # noqa: C901
131131 backend_kwargs : dict [str , Any ] | None = None ,
132132 model : str | None = None ,
133133 # Data configuration
134- processor : ProcessorInputType | None = None ,
134+ processor : ProcessorInputT | None = None ,
135135 processor_args : dict [str , Any ] | None = None ,
136136 data_args : dict [str , Any ] | None = None ,
137137 data_sampler : Literal ["random" ] | None = None ,
138138 # Output configuration
139139 output_path : str | Path | None = _CURRENT_WORKING_DIR ,
140- output_formats : OutputFormatType = ("console" , "json" , "html" , "csv" ),
140+ output_formats : OutputFormatT = ("console" , "json" , "html" , "csv" ),
141141 # Updates configuration
142- progress : ProgressInputType | None = None ,
142+ progress : ProgressInputT | None = None ,
143143 print_updates : bool = False ,
144144 # Aggregators configuration
145- add_aggregators : AggregatorInputType | None = None ,
145+ add_aggregators : AggregatorInputT | None = None ,
146146 warmup : float | None = None ,
147147 cooldown : float | None = None ,
148148 request_samples : int | None = 20 ,
@@ -259,7 +259,9 @@ async def benchmark_generative_text( # noqa: C901
259259 )
260260
261261 with console .print_update_step (title = "Resolving output formats" ) as console_step :
262- resolved_output_formats = await resolve_output_formats (output_formats , output_path )
262+ resolved_output_formats = await resolve_output_formats (
263+ output_formats , output_path
264+ )
263265 console_step .finish (
264266 title = "Output formats resolved" ,
265267 details = {key : str (val ) for key , val in resolved_output_formats .items ()},
@@ -314,7 +316,7 @@ async def benchmark_generative_text( # noqa: C901
314316async def reimport_benchmarks_report (
315317 file : Path ,
316318 output_path : Path | None ,
317- output_formats : OutputFormatType = ("console" , "json" , "html" , "csv" ),
319+ output_formats : OutputFormatT = ("console" , "json" , "html" , "csv" ),
318320) -> tuple [GenerativeBenchmarksReport , dict [str , Any ]]:
319321 """
320322 The command-line entry point for re-importing and displaying an
@@ -326,10 +328,15 @@ async def reimport_benchmarks_report(
326328 title = f"Loading benchmarks from { file } "
327329 ) as console_step :
328330 report = GenerativeBenchmarksReport .load_file (file )
329- console_step .finish (f"Import of old benchmarks complete; loaded { len (report .benchmarks )} benchmark(s)" )
331+ console_step .finish (
332+ "Import of old benchmarks complete;"
333+ f" loaded { len (report .benchmarks )} benchmark(s)"
334+ )
330335
331336 with console .print_update_step (title = "Resolving output formats" ) as console_step :
332- resolved_output_formats = await resolve_output_formats (output_formats , output_path )
337+ resolved_output_formats = await resolve_output_formats (
338+ output_formats , output_path
339+ )
333340 console_step .finish (
334341 title = "Output formats resolved" ,
335342 details = {key : str (val ) for key , val in resolved_output_formats .items ()},
0 commit comments