[Misc] Upgrade to Python 3.9 typing for additional directories (#14492)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
@@ -9,7 +9,7 @@ import time
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from threading import Thread
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from typing import Any, Optional, Union
|
||||
from uuid import uuid4
|
||||
|
||||
import cpuinfo
|
||||
@@ -27,7 +27,7 @@ _USAGE_STATS_DO_NOT_TRACK_PATH = os.path.join(_config_home, "do_not_track")
|
||||
_USAGE_STATS_ENABLED = None
|
||||
_USAGE_STATS_SERVER = envs.VLLM_USAGE_STATS_SERVER
|
||||
|
||||
_GLOBAL_RUNTIME_DATA: Dict[str, Union[str, int, bool]] = {}
|
||||
_GLOBAL_RUNTIME_DATA = dict[str, Union[str, int, bool]]()
|
||||
|
||||
_USAGE_ENV_VARS_TO_COLLECT = [
|
||||
"VLLM_USE_MODELSCOPE",
|
||||
@@ -150,7 +150,7 @@ class UsageMessage:
|
||||
def report_usage(self,
|
||||
model_architecture: str,
|
||||
usage_context: UsageContext,
|
||||
extra_kvs: Optional[Dict[str, Any]] = None) -> None:
|
||||
extra_kvs: Optional[dict[str, Any]] = None) -> None:
|
||||
t = Thread(target=self._report_usage_worker,
|
||||
args=(model_architecture, usage_context, extra_kvs or {}),
|
||||
daemon=True)
|
||||
@@ -158,13 +158,13 @@ class UsageMessage:
|
||||
|
||||
def _report_usage_worker(self, model_architecture: str,
|
||||
usage_context: UsageContext,
|
||||
extra_kvs: Dict[str, Any]) -> None:
|
||||
extra_kvs: dict[str, Any]) -> None:
|
||||
self._report_usage_once(model_architecture, usage_context, extra_kvs)
|
||||
self._report_continous_usage()
|
||||
|
||||
def _report_usage_once(self, model_architecture: str,
|
||||
usage_context: UsageContext,
|
||||
extra_kvs: Dict[str, Any]) -> None:
|
||||
extra_kvs: dict[str, Any]) -> None:
|
||||
# Platform information
|
||||
from vllm.platforms import current_platform
|
||||
if current_platform.is_cuda_alike():
|
||||
@@ -227,7 +227,7 @@ class UsageMessage:
|
||||
self._write_to_file(data)
|
||||
self._send_to_server(data)
|
||||
|
||||
def _send_to_server(self, data: Dict[str, Any]) -> None:
|
||||
def _send_to_server(self, data: dict[str, Any]) -> None:
|
||||
try:
|
||||
global_http_client = global_http_connection.get_sync_client()
|
||||
global_http_client.post(_USAGE_STATS_SERVER, json=data)
|
||||
@@ -235,7 +235,7 @@ class UsageMessage:
|
||||
# silently ignore unless we are using debug log
|
||||
logging.debug("Failed to send usage data to server")
|
||||
|
||||
def _write_to_file(self, data: Dict[str, Any]) -> None:
|
||||
def _write_to_file(self, data: dict[str, Any]) -> None:
|
||||
os.makedirs(os.path.dirname(_USAGE_STATS_JSON_PATH), exist_ok=True)
|
||||
Path(_USAGE_STATS_JSON_PATH).touch(exist_ok=True)
|
||||
with open(_USAGE_STATS_JSON_PATH, "a") as f:
|
||||
|
||||
Reference in New Issue
Block a user