-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
[CI] Fix mypy for vllm/v1/core and vllm/v1/engine
#27108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
8244ff7
60ae003
3565e69
8bae154
463e3d3
e90cb02
4f4f6e7
2105a7e
a6ec06a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| import time | ||
| from collections.abc import AsyncGenerator, Iterable, Mapping | ||
| from copy import copy | ||
| from typing import Any | ||
| from typing import Any, cast | ||
|
|
||
| import numpy as np | ||
| import torch | ||
|
|
@@ -131,10 +131,9 @@ def __init__( | |
| self.output_processor = OutputProcessor( | ||
| self.tokenizer, log_stats=self.log_stats | ||
| ) | ||
| if self.observability_config.otlp_traces_endpoint is not None: | ||
| tracer = init_tracer( | ||
| "vllm.llm_engine", self.observability_config.otlp_traces_endpoint | ||
| ) | ||
| endpoint = self.observability_config.otlp_traces_endpoint | ||
| if endpoint is not None: | ||
| tracer = init_tracer("vllm.llm_engine", endpoint) | ||
| self.output_processor.tracer = tracer | ||
|
|
||
| # EngineCore (starts the engine in background process). | ||
|
|
@@ -266,7 +265,9 @@ def shutdown(self): | |
| if engine_core := getattr(self, "engine_core", None): | ||
| engine_core.shutdown() | ||
|
|
||
| cancel_task_threadsafe(getattr(self, "output_handler", None)) | ||
| handler = getattr(self, "output_handler", None) | ||
| if handler is not None: | ||
| cancel_task_threadsafe(handler) | ||
|
|
||
| async def get_supported_tasks(self) -> tuple[SupportedTask, ...]: | ||
| return await self.engine_core.get_supported_tasks_async() | ||
|
|
@@ -314,7 +315,10 @@ async def add_request( | |
| priority, | ||
| data_parallel_rank, | ||
| ) | ||
| prompt_text = prompt if isinstance(prompt, str) else prompt.get("prompt") | ||
| if isinstance(prompt, str): | ||
| prompt_text = prompt | ||
| elif isinstance(prompt, Mapping): | ||
| prompt_text = cast(str | None, prompt.get("prompt")) | ||
|
|
||
| if is_pooling or params.n == 1: | ||
| await self._add_request(request, prompt_text, None, 0, queue) | ||
|
|
@@ -436,6 +440,7 @@ async def generate( | |
| # Note: both OutputProcessor and EngineCore handle their | ||
| # own request cleanup based on finished. | ||
| finished = out.finished | ||
| assert isinstance(out, RequestOutput) | ||
| yield out | ||
|
|
||
| # If the request is disconnected by the client, generate() | ||
|
|
@@ -653,7 +658,7 @@ async def get_tokenizer(self) -> AnyTokenizer: | |
| return self.tokenizer | ||
|
|
||
| async def is_tracing_enabled(self) -> bool: | ||
| return self.observability_config.otlp_traces_endpoint is not None | ||
| return self.observability_config.otlp_traces_endpoint is not None # type: ignore | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does the type need to be ignored here? Should this not always return a bool?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue is async def is_tracing_enabled(self) -> bool:
assert self.observability_config is not None
return self.observability_config.otlp_traces_endpoint is not NoneI think this is not very elegant so just #type ignore |
||
|
|
||
| async def do_log_stats(self) -> None: | ||
| if self.logger_manager: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.