Update deprecated Python 3.8 typing (#13971)
This commit is contained in:
@@ -10,7 +10,7 @@ from abc import ABC, abstractmethod
|
||||
from concurrent.futures import Future
|
||||
from dataclasses import dataclass
|
||||
from threading import Thread
|
||||
from typing import Any, Dict, List, Optional, Set, Type, Union
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import zmq
|
||||
import zmq.asyncio
|
||||
@@ -48,7 +48,7 @@ class EngineCoreClient(ABC):
|
||||
multiprocess_mode: bool,
|
||||
asyncio_mode: bool,
|
||||
vllm_config: VllmConfig,
|
||||
executor_class: Type[Executor],
|
||||
executor_class: type[Executor],
|
||||
log_stats: bool,
|
||||
) -> "EngineCoreClient":
|
||||
|
||||
@@ -94,7 +94,7 @@ class EngineCoreClient(ABC):
|
||||
async def execute_dummy_batch_async(self) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
def abort_requests(self, request_ids: List[str]) -> None:
|
||||
def abort_requests(self, request_ids: list[str]) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
def add_lora(self, lora_request: LoRARequest) -> bool:
|
||||
@@ -103,7 +103,7 @@ class EngineCoreClient(ABC):
|
||||
def remove_lora(self, lora_id: int) -> bool:
|
||||
raise NotImplementedError
|
||||
|
||||
def list_loras(self) -> Set[int]:
|
||||
def list_loras(self) -> set[int]:
|
||||
raise NotImplementedError
|
||||
|
||||
def pin_lora(self, lora_id: int) -> bool:
|
||||
@@ -127,7 +127,7 @@ class EngineCoreClient(ABC):
|
||||
async def wake_up_async(self) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
async def abort_requests_async(self, request_ids: List[str]) -> None:
|
||||
async def abort_requests_async(self, request_ids: list[str]) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
async def add_lora_async(self, lora_request: LoRARequest) -> bool:
|
||||
@@ -136,7 +136,7 @@ class EngineCoreClient(ABC):
|
||||
async def remove_lora_async(self, lora_id: int) -> bool:
|
||||
raise NotImplementedError
|
||||
|
||||
async def list_loras_async(self) -> Set[int]:
|
||||
async def list_loras_async(self) -> set[int]:
|
||||
raise NotImplementedError
|
||||
|
||||
async def pin_lora_async(self, lora_id: int) -> bool:
|
||||
@@ -162,7 +162,7 @@ class InprocClient(EngineCoreClient):
|
||||
def add_request(self, request: EngineCoreRequest) -> None:
|
||||
self.engine_core.add_request(request)
|
||||
|
||||
def abort_requests(self, request_ids: List[str]) -> None:
|
||||
def abort_requests(self, request_ids: list[str]) -> None:
|
||||
if len(request_ids) > 0:
|
||||
self.engine_core.abort_requests(request_ids)
|
||||
|
||||
@@ -190,7 +190,7 @@ class InprocClient(EngineCoreClient):
|
||||
def remove_lora(self, lora_id: int) -> bool:
|
||||
return self.engine_core.remove_lora(lora_id)
|
||||
|
||||
def list_loras(self) -> Set[int]:
|
||||
def list_loras(self) -> set[int]:
|
||||
return self.engine_core.list_loras()
|
||||
|
||||
def pin_lora(self, lora_id: int) -> bool:
|
||||
@@ -239,7 +239,7 @@ class MPClient(EngineCoreClient):
|
||||
self,
|
||||
asyncio_mode: bool,
|
||||
vllm_config: VllmConfig,
|
||||
executor_class: Type[Executor],
|
||||
executor_class: type[Executor],
|
||||
log_stats: bool,
|
||||
):
|
||||
# The child processes will send SIGUSR1 when unrecoverable
|
||||
@@ -293,14 +293,14 @@ class MPClient(EngineCoreClient):
|
||||
|
||||
self.output_socket = resources.output_socket
|
||||
self.input_socket = resources.input_socket
|
||||
self.utility_results: Dict[int, AnyFuture] = {}
|
||||
self.utility_results: dict[int, AnyFuture] = {}
|
||||
|
||||
def shutdown(self):
|
||||
self._finalizer()
|
||||
|
||||
|
||||
def _process_utility_output(output: UtilityOutput,
|
||||
utility_results: Dict[int, AnyFuture]):
|
||||
utility_results: dict[int, AnyFuture]):
|
||||
"""Set the result from a utility method in the waiting future"""
|
||||
future = utility_results.pop(output.call_id)
|
||||
if output.failure_message is not None:
|
||||
@@ -312,7 +312,7 @@ def _process_utility_output(output: UtilityOutput,
|
||||
class SyncMPClient(MPClient):
|
||||
"""Synchronous client for multi-proc EngineCore."""
|
||||
|
||||
def __init__(self, vllm_config: VllmConfig, executor_class: Type[Executor],
|
||||
def __init__(self, vllm_config: VllmConfig, executor_class: type[Executor],
|
||||
log_stats: bool):
|
||||
super().__init__(
|
||||
asyncio_mode=False,
|
||||
@@ -373,7 +373,7 @@ class SyncMPClient(MPClient):
|
||||
request.prompt = None
|
||||
self._send_input(EngineCoreRequestType.ADD, request)
|
||||
|
||||
def abort_requests(self, request_ids: List[str]) -> None:
|
||||
def abort_requests(self, request_ids: list[str]) -> None:
|
||||
if len(request_ids) > 0:
|
||||
self._send_input(EngineCoreRequestType.ABORT, request_ids)
|
||||
|
||||
@@ -389,7 +389,7 @@ class SyncMPClient(MPClient):
|
||||
def remove_lora(self, lora_id: int) -> bool:
|
||||
return self._call_utility("remove_lora", lora_id)
|
||||
|
||||
def list_loras(self) -> Set[int]:
|
||||
def list_loras(self) -> set[int]:
|
||||
return self._call_utility("list_loras")
|
||||
|
||||
def pin_lora(self, lora_id: int) -> bool:
|
||||
@@ -408,7 +408,7 @@ class SyncMPClient(MPClient):
|
||||
class AsyncMPClient(MPClient):
|
||||
"""Asyncio-compatible client for multi-proc EngineCore."""
|
||||
|
||||
def __init__(self, vllm_config: VllmConfig, executor_class: Type[Executor],
|
||||
def __init__(self, vllm_config: VllmConfig, executor_class: type[Executor],
|
||||
log_stats: bool):
|
||||
super().__init__(
|
||||
asyncio_mode=True,
|
||||
@@ -471,7 +471,7 @@ class AsyncMPClient(MPClient):
|
||||
request.prompt = None
|
||||
await self._send_input(EngineCoreRequestType.ADD, request)
|
||||
|
||||
async def abort_requests_async(self, request_ids: List[str]) -> None:
|
||||
async def abort_requests_async(self, request_ids: list[str]) -> None:
|
||||
if len(request_ids) > 0:
|
||||
await self._send_input(EngineCoreRequestType.ABORT, request_ids)
|
||||
|
||||
@@ -496,7 +496,7 @@ class AsyncMPClient(MPClient):
|
||||
async def remove_lora_async(self, lora_id: int) -> bool:
|
||||
return await self._call_utility_async("remove_lora", lora_id)
|
||||
|
||||
async def list_loras_async(self) -> Set[int]:
|
||||
async def list_loras_async(self) -> set[int]:
|
||||
return await self._call_utility_async("list_loras")
|
||||
|
||||
async def pin_lora_async(self, lora_id: int) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user