"components/backends/vscode:/vscode.git/clone" did not exist on "f9be2e9eeab5862292429c70dfb2fae4c56334a1"
Unverified Commit f6b4da08 authored by jh-nv's avatar jh-nv Committed by GitHub
Browse files

chore: mypy typing for python bindings (#6857)

parent 49fa25e2
...@@ -13,8 +13,6 @@ from typing import ( ...@@ -13,8 +13,6 @@ from typing import (
Tuple, Tuple,
) )
from ._prometheus_names import prometheus_names
# Import from specialized modules # Import from specialized modules
from .prometheus_metrics import RuntimeMetrics as PyRuntimeMetrics from .prometheus_metrics import RuntimeMetrics as PyRuntimeMetrics
...@@ -1088,6 +1086,36 @@ def lora_name_to_id(lora_name: str) -> int: ...@@ -1088,6 +1086,36 @@ def lora_name_to_id(lora_name: str) -> int:
"""Generate a deterministic integer ID from a LoRA name using blake3 hash.""" """Generate a deterministic integer ID from a LoRA name using blake3 hash."""
... ...
class LoRADownloader:
"""Unified interface for LoRA downloading and caching (local file:// and S3 s3:// URIs)."""
def __init__(self, cache_path: Optional[str] = None) -> None: ...
def download_if_needed(self, lora_uri: str) -> Awaitable[str]: ...
def get_cache_path(self, cache_key: str) -> str: ...
def is_cached(self, cache_key: str) -> bool: ...
def validate_cached(self, cache_key: str) -> bool: ...
@staticmethod
def uri_to_cache_key(uri: str) -> str: ...
class MediaDecoder:
"""Media decoder for image and video preprocessing."""
def __init__(self) -> None: ...
def enable_image(self, decoder_options: Dict[str, Any]) -> None: ...
class MediaFetcher:
"""Media fetcher for loading remote image/video URLs."""
def __init__(self) -> None: ...
def user_agent(self, user_agent: str) -> None: ...
def allow_direct_ip(self, allow: bool) -> None: ...
def allow_direct_port(self, allow: bool) -> None: ...
def allowed_media_domains(self, domains: List[str]) -> None: ...
def timeout_ms(self, timeout_ms: int) -> None: ...
async def fetch_model(remote_name: str, ignore_weights: bool = False) -> str: async def fetch_model(remote_name: str, ignore_weights: bool = False) -> str:
""" """
Download a model from Hugging Face, returning its local path. Download a model from Hugging Face, returning its local path.
...@@ -1618,12 +1646,3 @@ class VirtualConnectorClient: ...@@ -1618,12 +1646,3 @@ class VirtualConnectorClient:
"""Blocks until there is a new decision to fetch using 'get'""" """Blocks until there is a new decision to fetch using 'get'"""
... ...
__all__ = [
"Client",
"Context",
"KserveGrpcService",
"ModelDeploymentCard",
"PythonAsyncEngine",
"prometheus_names",
"ModelCardInstanceId",
]
...@@ -28,7 +28,7 @@ class LogHandler(logging.Handler): ...@@ -28,7 +28,7 @@ class LogHandler(logging.Handler):
Custom logging handler that sends log messages to the Rust env_logger Custom logging handler that sends log messages to the Rust env_logger
""" """
def emit(self, record): def emit(self, record: logging.LogRecord) -> None:
""" """
Emit a log record Emit a log record
""" """
...@@ -78,7 +78,7 @@ class VllmColorFormatter(logging.Formatter): ...@@ -78,7 +78,7 @@ class VllmColorFormatter(logging.Formatter):
_DIM = "\033[2m" _DIM = "\033[2m"
_RESET = "\033[0m" _RESET = "\033[0m"
def format(self, record): def format(self, record: logging.LogRecord) -> str:
ts = datetime.fromtimestamp(record.created, tz=timezone.utc).strftime( ts = datetime.fromtimestamp(record.created, tz=timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%S.%fZ" "%Y-%m-%dT%H:%M:%S.%fZ"
) )
...@@ -98,7 +98,7 @@ class VllmColorFormatter(logging.Formatter): ...@@ -98,7 +98,7 @@ class VllmColorFormatter(logging.Formatter):
# Configure the Python logger to use the NimLogHandler # Configure the Python logger to use the NimLogHandler
def configure_logger(service_name: str | None, worker_id: int | None): def configure_logger(service_name: str | None, worker_id: int | None) -> None:
""" """
Called once to configure the Python logger to use the LogHandler Called once to configure the Python logger to use the LogHandler
""" """
...@@ -129,7 +129,7 @@ def construct_formatter_prefix(service_name: str | None, worker_id: int | None) ...@@ -129,7 +129,7 @@ def construct_formatter_prefix(service_name: str | None, worker_id: int | None)
def configure_dynamo_logging( def configure_dynamo_logging(
service_name: str | None = None, worker_id: int | None = None service_name: str | None = None, worker_id: int | None = None
): ) -> None:
""" """
A single place to configure logging for Dynamo. A single place to configure logging for Dynamo.
""" """
...@@ -181,7 +181,7 @@ def log_level_mapping(level: str) -> int: ...@@ -181,7 +181,7 @@ def log_level_mapping(level: str) -> int:
return logging.INFO return logging.INFO
def configure_sglang_logging(dyn_level: int): def configure_sglang_logging(dyn_level: int) -> None:
""" """
SGLang allows us to create a custom logging config file SGLang allows us to create a custom logging config file
""" """
...@@ -213,7 +213,7 @@ def configure_sglang_logging(dyn_level: int): ...@@ -213,7 +213,7 @@ def configure_sglang_logging(dyn_level: int):
os.environ["SGLANG_LOGGING_CONFIG_PATH"] = f.name os.environ["SGLANG_LOGGING_CONFIG_PATH"] = f.name
def configure_vllm_logging(dyn_level: int): def configure_vllm_logging(dyn_level: int) -> None:
""" """
Configure vLLM logging for the main process and subprocesses. Configure vLLM logging for the main process and subprocesses.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment