Skip to content

Commit 039db66

Browse files
style + type fixes
1 parent 6c6c15a commit 039db66

File tree

6 files changed

+117
-251
lines changed

6 files changed

+117
-251
lines changed

src/guidellm/backend/openai.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def __init__(
9393
raise ValueError("Target URL must be provided for OpenAI HTTP backend.")
9494

9595
if self._target.endswith("/v1") or self._target.endswith("/v1/"):
96-
# backwards compatability, strip v1 off
96+
# backwards compatibility, strip v1 off
9797
self._target = self._target[:-3]
9898

9999
if self._target.endswith("/"):
@@ -572,12 +572,12 @@ async def _iterative_completions_request(
572572

573573
async for line in stream.aiter_lines():
574574
iter_time = time.time()
575-
# logger.debug(
576-
# "{} request: {} recieved iter response line: {}",
577-
# self.__class__.__name__,
578-
# request_id,
579-
# line,
580-
# )
575+
logger.debug(
576+
"{} request: {} recieved iter response line: {}",
577+
self.__class__.__name__,
578+
request_id,
579+
line,
580+
)
581581

582582
if not line or not line.strip().startswith("data:"):
583583
continue

src/guidellm/objects/pydantic.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from typing import Any, Generic, TypeVar
22

3-
from loguru import logger
43
from pydantic import BaseModel, ConfigDict, Field
54

65
__all__ = ["StandardBaseModel", "StatusBreakdown"]
76

7+
from guidellm import logger
8+
89

910
class StandardBaseModel(BaseModel):
1011
"""
@@ -21,11 +22,11 @@ class StandardBaseModel(BaseModel):
2122

2223
def __init__(self, /, **data: Any) -> None:
2324
super().__init__(**data)
24-
# logger.debug(
25-
# "Initialized new instance of {} with data: {}",
26-
# self.__class__.__name__,
27-
# data,
28-
# )
25+
logger.debug(
26+
"Initialized new instance of {} with data: {}",
27+
self.__class__.__name__,
28+
data,
29+
)
2930

3031

3132
SuccessfulT = TypeVar("SuccessfulT")

src/guidellm/scheduler/repro.py

Lines changed: 0 additions & 138 deletions
This file was deleted.

src/guidellm/scheduler/result.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class SchedulerRunInfo(StandardBaseModel):
5050
end_number: float
5151
processes: int
5252
strategy: SchedulingStrategy
53+
last_requests_statuses: deque[RequestStatus]
5354
max_error_rate: Optional[float] = None
5455

5556
created_requests: int = 0
@@ -59,8 +60,6 @@ class SchedulerRunInfo(StandardBaseModel):
5960
completed_requests: int = 0
6061
errored_requests: int = 0
6162

62-
last_requests_statuses: Optional[deque[RequestStatus]] = None
63-
6463

6564
class SchedulerRequestInfo(StandardBaseModel):
6665
"""

src/guidellm/scheduler/scheduler.py

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import collections
2-
from datetime import timedelta
31
import asyncio
2+
import collections
43
import math
54
import multiprocessing
65
import multiprocessing.queues
@@ -11,8 +10,10 @@
1110
from typing import (
1211
Any,
1312
Generic,
13+
Literal,
1414
Optional,
15-
Union, Literal, cast,
15+
Union,
16+
cast,
1617
)
1718

1819
from loguru import logger
@@ -128,9 +129,7 @@ async def run(
128129
requests_queue,
129130
responses_queue,
130131
shutdown_event,
131-
) = await self._start_processes(
132-
manager, executor, scheduling_strategy
133-
)
132+
) = await self._start_processes(manager, executor, scheduling_strategy)
134133
if shutdown_event.is_set():
135134
raise RuntimeError("shutdown_event is set before starting scheduling")
136135

@@ -156,7 +155,6 @@ async def run(
156155
):
157156
# we've exhausted all requests we've wanted to run
158157
# and yielded all responses
159-
logger.info("run_info.completed_requests >= run_info.created_requests")
160158
break
161159

162160
requests_iter = self._add_requests(
@@ -229,10 +227,7 @@ def _is_max_error_rate_reached(self, run_info: SchedulerRunInfo) -> bool:
229227
f"{max_error} (max error)"
230228
)
231229
return max_error < run_info.errored_requests
232-
elif(
233-
run_info.strategy.type_ == "constant"
234-
and run_info.end_number != math.inf
235-
):
230+
elif run_info.strategy.type_ == "constant" and run_info.end_number != math.inf:
236231
current_error_ratio = run_info.errored_requests / run_info.end_number
237232
logger.debug(
238233
f"Current error rate {current_error_ratio} "
@@ -241,13 +236,12 @@ def _is_max_error_rate_reached(self, run_info: SchedulerRunInfo) -> bool:
241236
return max_error < current_error_ratio
242237
elif settings.error_check_window_size <= run_info.completed_requests:
243238
last_requests_statuses = run_info.last_requests_statuses
244-
last_errored_requests_count = len([
245-
s
246-
for s
247-
in last_requests_statuses
248-
if s == "error"
249-
])
250-
current_error_ratio = last_errored_requests_count / len(last_requests_statuses)
239+
last_errored_requests_count = len(
240+
[s for s in last_requests_statuses if s == "error"]
241+
)
242+
current_error_ratio = last_errored_requests_count / len(
243+
last_requests_statuses
244+
)
251245
logger.debug(
252246
f"Current error rate in "
253247
f"last requests window is "
@@ -353,7 +347,7 @@ def _run_setup(
353347
max_error_rate=max_error_rate,
354348
last_requests_statuses=collections.deque(
355349
maxlen=settings.error_check_window_size
356-
)
350+
),
357351
)
358352

359353
return info, requests_iter, times_iter
@@ -471,8 +465,7 @@ def _check_result_ready(
471465
run_info.errored_requests += 1
472466

473467
request_status: Literal["error", "success"] = cast(
474-
Literal["error", "success"],
475-
"error" if is_errored else "success"
468+
"Literal['error', 'success']", "error" if is_errored else "success"
476469
)
477470
run_info.last_requests_statuses.append(request_status)
478471

0 commit comments

Comments
 (0)