Migrate linter from pylint to ruff (#1665)

This commit is contained in:
Simon Mo
2023-11-20 11:58:01 -08:00
committed by GitHub
parent 112627e8b2
commit 5ffc0d13a2
45 changed files with 122 additions and 607 deletions

View File

@@ -14,7 +14,6 @@ app = vllm.entrypoints.api_server.app
class AsyncLLMEngineWithStats(AsyncLLMEngine):
# pylint: disable=redefined-outer-name
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._num_aborts = 0

View File

@@ -24,7 +24,6 @@ def _query_server(prompt: str) -> dict:
def api_server():
script_path = Path(__file__).parent.joinpath(
"api_server_async_engine.py").absolute()
# pylint: disable=consider-using-with
uvicorn_process = subprocess.Popen([
sys.executable, "-u",
str(script_path), "--model", "facebook/opt-125m"
@@ -33,7 +32,6 @@ def api_server():
uvicorn_process.terminate()
# pylint: disable=redefined-outer-name, unused-argument
def test_api_server(api_server):
"""
Run the API server and test it.
@@ -49,11 +47,10 @@ def test_api_server(api_server):
prompts = ["Hello world"] * 1
result = None
while not result:
# pylint: disable=bare-except
try:
for result in pool.map(_query_server, prompts):
for _ in pool.map(_query_server, prompts):
break
except:
except Exception:
time.sleep(1)
# Actual tests start here

View File

@@ -8,7 +8,6 @@ from vllm import LLM, SamplingParams
from vllm.transformers_utils.tokenizer import get_tokenizer
_TEST_PROMPTS = [
# pylint: disable=line-too-long
"vLLM is a high-throughput and memory-efficient inference and serving engine for LLMs.",
"Briefly describe the major milestones in the development of artificial intelligence from 1950 to 2020.",
"Compare and contrast artificial intelligence with human intelligence in terms of processing information.",

View File

@@ -5,10 +5,9 @@ from transformers import AutoTokenizer
from vllm.transformers_utils.tokenizer import detokenize_incrementally
TRUTH = [
# pylint: disable=line-too-long
"Hello here, this is a simple test",
"vLLM is a high-throughput and memory-efficient inference and serving engine for LLMs. It is designed to be used in production environments, where inference and serving",
"我很感谢你的热情"
"Hello here, this is a simple test", # noqa: E501
"vLLM is a high-throughput and memory-efficient inference and serving engine for LLMs. It is designed to be used in production environments, where inference and serving", # noqa: E501
"我很感谢你的热情" # noqa: E501
]
TOKENIZERS = [
"facebook/opt-125m",

View File

@@ -211,7 +211,7 @@ def test_paged_attention(
alibi_slopes,
)
else:
assert False, f"Unknown version: {version}"
raise AssertionError(f"Unknown version: {version}")
# Run the reference implementation.
ref_output = torch.empty_like(query)

View File

@@ -1,4 +1,3 @@
# pylint: disable=protected-access
import random
from typing import Tuple
from unittest.mock import patch
@@ -20,10 +19,10 @@ class MockLogitsSampler(Sampler):
def forward(self, *args, **kwargs):
with patch("vllm.model_executor.layers.sampler._prune_hidden_states",
lambda x, y: x):
with patch("vllm.model_executor.layers.sampler._get_logits",
lambda x, y: x), patch(
"vllm.model_executor.layers.sampler._get_logits",
lambda *args, **kwargs: self.fake_logits):
return super().forward(*args, **kwargs)
return super().forward(*args, **kwargs)
def _prepare_test(
@@ -214,6 +213,6 @@ def test_sampler_logits_processors(seed: int):
sampler_output = sampler(embedding=None,
hidden_states=input_tensor,
input_metadata=input_metadata)
for i, sequence_output in enumerate(sampler_output):
for _, sequence_output in enumerate(sampler_output):
for idx, nth_output in enumerate(sequence_output.samples):
assert nth_output.output_token == idx

View File

@@ -1,4 +1,3 @@
# pylint: disable=protected-access
import random
import torch