[Bugfix][Frontend] Accept successful 2xx responses for batch output uploads (#60507)
Signed-off-by: bnkaiteam <bnkaiteam@gmail.com> Co-authored-by: Flora Feng <4florafeng@gmail.com>
This commit is contained in:
@@ -1071,17 +1071,32 @@ def _make_aiohttp_put_session(status: int = 200, body_text: str = ""):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_upload_data_uploads_once_on_success():
|
@pytest.mark.parametrize("status", [200, 201, 204])
|
||||||
"""A successful upload must not be retried (regression guard)."""
|
@pytest.mark.parametrize("from_file", [False, True])
|
||||||
session = _make_aiohttp_put_session(status=200)
|
async def test_upload_data_uploads_once_on_success(status, from_file, tmp_path):
|
||||||
with patch(
|
"""Successful PUT responses must not retry either upload path."""
|
||||||
"vllm.entrypoints.launchers.run_batch.aiohttp.ClientSession",
|
session = _make_aiohttp_put_session(status=status)
|
||||||
return_value=session,
|
data_or_file = "payload"
|
||||||
|
if from_file:
|
||||||
|
path = tmp_path / "output.jsonl"
|
||||||
|
path.write_text(data_or_file, encoding="utf-8")
|
||||||
|
data_or_file = str(path)
|
||||||
|
|
||||||
|
with (
|
||||||
|
patch(
|
||||||
|
"vllm.entrypoints.launchers.run_batch.aiohttp.ClientSession",
|
||||||
|
return_value=session,
|
||||||
|
),
|
||||||
|
patch(
|
||||||
|
"vllm.entrypoints.launchers.run_batch.asyncio.sleep",
|
||||||
|
new_callable=AsyncMock,
|
||||||
|
) as sleep,
|
||||||
):
|
):
|
||||||
await upload_data(
|
await upload_data(
|
||||||
"https://example.com/output.jsonl", "payload", from_file=False
|
"https://example.com/output.jsonl", data_or_file, from_file=from_file
|
||||||
)
|
)
|
||||||
assert session.put.call_count == 1
|
assert session.put.call_count == 1
|
||||||
|
sleep.assert_not_awaited()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ async def upload_data(output_url: str, data_or_file: str, from_file: bool) -> No
|
|||||||
if from_file:
|
if from_file:
|
||||||
with open(data_or_file, "rb") as file:
|
with open(data_or_file, "rb") as file:
|
||||||
async with session.put(output_url, data=file) as response:
|
async with session.put(output_url, data=file) as response:
|
||||||
if response.status != 200:
|
if not 200 <= response.status < 300:
|
||||||
error_text = await response.text()
|
error_text = await response.text()
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f"Failed to upload file.\n"
|
f"Failed to upload file.\n"
|
||||||
@@ -394,7 +394,7 @@ async def upload_data(output_url: str, data_or_file: str, from_file: bool) -> No
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
async with session.put(output_url, data=data_or_file) as response:
|
async with session.put(output_url, data=data_or_file) as response:
|
||||||
if response.status != 200:
|
if not 200 <= response.status < 300:
|
||||||
error_text = await response.text()
|
error_text = await response.text()
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f"Failed to upload data.\n"
|
f"Failed to upload data.\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user