mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 23:45:39 +08:00
- **Add SPDX license headers to python source files**
- **Check for SPDX headers using pre-commit**
commit 9d7ef44c3cfb72ca4c32e1c677d99259d10d4745
Author: Russell Bryant <rbryant@redhat.com>
Date: Fri Jan 31 14:18:24 2025 -0500
Add SPDX license headers to python source files
This commit adds SPDX license headers to python source files as
recommended to
the project by the Linux Foundation. These headers provide a concise way
that is
both human and machine readable for communicating license information
for each
source file. It helps avoid any ambiguity about the license of the code
and can
also be easily used by tools to help manage license compliance.
The Linux Foundation runs license scans against the codebase to help
ensure
we are in compliance with the licenses of the code we use, including
dependencies. Having these headers in place helps that tool do its job.
More information can be found on the SPDX site:
- https://spdx.dev/learn/handling-license-info/
Signed-off-by: Russell Bryant <rbryant@redhat.com>
commit 5a1cf1cb3b80759131c73f6a9dddebccac039dea
Author: Russell Bryant <rbryant@redhat.com>
Date: Fri Jan 31 14:36:32 2025 -0500
Check for SPDX headers using pre-commit
Signed-off-by: Russell Bryant <rbryant@redhat.com>
---------
Signed-off-by: Russell Bryant <rbryant@redhat.com>
69 lines
2.0 KiB
Python
69 lines
2.0 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
"""Test that aborting is handled properly."""
|
|
|
|
import asyncio
|
|
import tempfile
|
|
import uuid
|
|
|
|
import pytest
|
|
|
|
from tests.mq_llm_engine.utils import RemoteMQLLMEngine, generate
|
|
from vllm.engine.arg_utils import AsyncEngineArgs
|
|
|
|
MODEL = "google/gemma-1.1-2b-it"
|
|
ENGINE_ARGS = AsyncEngineArgs(model=MODEL)
|
|
RAISED_ERROR = KeyError
|
|
RAISED_VALUE = "foo"
|
|
EXPECTED_TOKENS = 250
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def tmp_socket():
|
|
with tempfile.TemporaryDirectory() as td:
|
|
yield f"ipc://{td}/{uuid.uuid4()}"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_abort(tmp_socket):
|
|
with RemoteMQLLMEngine(engine_args=ENGINE_ARGS,
|
|
ipc_path=tmp_socket) as engine:
|
|
|
|
client = await engine.make_client()
|
|
|
|
request_id_to_be_aborted = "request-aborted"
|
|
request_ids_a = [f"request-a-{idx}" for idx in range(10)]
|
|
request_ids_b = [f"request-b-{idx}" for idx in range(10)]
|
|
|
|
# Requests started before one to be aborted.
|
|
tasks = []
|
|
for request_id in request_ids_a:
|
|
tasks.append(
|
|
asyncio.create_task(
|
|
generate(client, request_id, EXPECTED_TOKENS)))
|
|
|
|
# Aborted.
|
|
task_aborted = asyncio.create_task(
|
|
generate(client, request_id_to_be_aborted, EXPECTED_TOKENS))
|
|
|
|
# Requests started after one to be aborted.
|
|
for request_id in request_ids_b:
|
|
tasks.append(
|
|
asyncio.create_task(
|
|
generate(client, request_id, EXPECTED_TOKENS)))
|
|
|
|
# Actually abort.
|
|
await asyncio.sleep(0.5)
|
|
await client.abort(request_id_to_be_aborted)
|
|
|
|
# Confirm that we got all the EXPECTED tokens from the requests.
|
|
for task in tasks:
|
|
count, request_id = await task
|
|
assert count == EXPECTED_TOKENS, (
|
|
f"{request_id} generated only {count} tokens")
|
|
|
|
# Cancel task (this will hang indefinitely if not).
|
|
task_aborted.cancel()
|
|
|
|
# Shutdown.
|
|
client.close()
|