[Bugfix] Stop reading the removed OmniRequestOutput.request_output accessor (#6172)
Signed-off-by: MrlixiangWE <mrdanaer@gmail.com>
This commit is contained in:
1 parent
fe54ecc388
commit
b95c73742d
12 files changed
+74
-32
No files matched your search
@@ -53,14 +53,10 @@ def _diff_metrics(a: Image.Image, b: Image.Image) -> tuple[float, float]:
|
||||
def _extract_single_image(outputs) -> Image.Image:
|
||||
first_output = outputs[0]
|
||||
assert first_output.final_output_type == "image"
|
||||
if not hasattr(first_output, "request_output") or not first_output.request_output:
|
||||
raise ValueError("No request_output found in OmniRequestOutput")
|
||||
if not isinstance(first_output, OmniRequestOutput):
|
||||
raise ValueError(f"Expected an OmniRequestOutput, got {type(first_output).__name__}")
|
||||
|
||||
req_out = first_output.request_output
|
||||
if not isinstance(req_out, OmniRequestOutput) or not hasattr(req_out, "images"):
|
||||
raise ValueError("Invalid request_output structure or missing 'images' key")
|
||||
|
||||
images = req_out.images
|
||||
images = first_output.images
|
||||
if images is None or len(images) != 1:
|
||||
raise ValueError(f"Expected 1 image, got {0 if images is None else len(images)}")
|
||||
return images[0]
|
||||
|
||||
@@ -72,8 +72,7 @@ def _to_float_array(data: Any) -> np.ndarray:
|
||||
|
||||
|
||||
def _extract_output_array(output: Any) -> np.ndarray:
|
||||
req_out = output.request_output
|
||||
payload = req_out.images[0]
|
||||
payload = output.images[0]
|
||||
return _to_float_array(payload)
|
||||
|
||||
|
||||
|
||||
@@ -142,12 +142,6 @@ def _generate_joint_output(omni, config: QualityTestConfig):
|
||||
|
||||
first = outputs[0]
|
||||
worker_peak_memory_mb = float(getattr(first, "peak_memory_mb", 0.0) or 0.0)
|
||||
if hasattr(first, "request_output") and isinstance(first.request_output, list):
|
||||
first = first.request_output[0]
|
||||
worker_peak_memory_mb = max(
|
||||
worker_peak_memory_mb,
|
||||
float(getattr(first, "peak_memory_mb", 0.0) or 0.0),
|
||||
)
|
||||
if not hasattr(first, "images") or not first.images:
|
||||
raise ValueError("Could not extract video frames from H3 output")
|
||||
frames = first.images[0]
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Guard the public accessor that examples and docs use to read omni outputs.
|
||||
|
||||
``OmniRequestOutput`` used to hold a nested ``RequestOutput`` in a
|
||||
``request_output`` field. Since #5146 it *inherits* ``RequestOutput``, so the
|
||||
generation content lives on the object itself and the nested field is gone.
|
||||
|
||||
Call sites that kept the old accessor only fail once a real model runs, which
|
||||
means a GPU nightly job is the first thing to notice. These checks pin both
|
||||
halves of the contract on CPU instead: the field is really gone, and no doc,
|
||||
example, test or tool still reaches for it.
|
||||
"""
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm_omni.outputs import OmniRequestOutput
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
|
||||
ROOT_DIR = Path(__file__).parents[2]
|
||||
SCANNED_DIRS = ("docs", "examples", "tests", "tools")
|
||||
SCANNED_SUFFIXES = (".py", ".md")
|
||||
|
||||
# ``.request_outputs`` (plural, an OutputProcessor batch) is a different and
|
||||
# still-valid attribute, so require a non-identifier character after the name.
|
||||
NESTED_ACCESSOR = re.compile(r"\.request_output(?![\w])")
|
||||
|
||||
|
||||
def _iter_scanned_files():
|
||||
for directory in SCANNED_DIRS:
|
||||
for path in sorted((ROOT_DIR / directory).rglob("*")):
|
||||
if path.suffix in SCANNED_SUFFIXES and path.resolve() != Path(__file__).resolve():
|
||||
yield path
|
||||
|
||||
|
||||
def test_omni_request_output_has_no_nested_request_output():
|
||||
assert not hasattr(OmniRequestOutput(request_id="req-accessor"), "request_output")
|
||||
|
||||
|
||||
def test_no_source_reads_the_nested_request_output():
|
||||
offenders = []
|
||||
for path in _iter_scanned_files():
|
||||
for lineno, line in enumerate(path.read_text(encoding="utf-8").splitlines(), start=1):
|
||||
if NESTED_ACCESSOR.search(line):
|
||||
offenders.append(f"{path.relative_to(ROOT_DIR)}:{lineno}: {line.strip()}")
|
||||
|
||||
assert not offenders, (
|
||||
"OmniRequestOutput no longer nests a RequestOutput; read the content off the "
|
||||
"output itself (e.g. `outputs[0].images`) instead of `.request_output`:\n" + "\n".join(offenders)
|
||||
)
|
||||
Reference in new issue
Block a user