[Refactor][OutputProcessor 2/8]: OmniRequestOutput should inherit RequestOutput and no nested wrap-up (#5146)
Signed-off-by: Boao Shi <aoibosh@connect.hku.hk> Signed-off-by: bowieshi <aoibosh@connect.hku.hk> Signed-off-by: princepride <wangzhipeng628@gmail.com> Signed-off-by: R2-Y <ruiruyang2@gmail.com> Signed-off-by: amy-why-3459 <wuhaiyan17@huawei.com> Signed-off-by: Shi Boao Bowie <aoibosh@connect.hku.hk> Co-authored-by: 汪志鹏 <wangzhipeng628@gmail.com> Co-authored-by: ruirui(rein) yang <73573651+R2-Y@users.noreply.github.com> Co-authored-by: amy-why-3459 <wuhaiyan17@huawei.com> Co-authored-by: Gao Han <hgaoaf@connect.ust.hk> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
89 files changed
+944
-639
No files matched your search
@@ -119,7 +119,6 @@ class MockGenerationResult:
|
||||
|
||||
def __init__(self, images):
|
||||
self.images = images
|
||||
self.request_output = SimpleNamespace(images=images)
|
||||
self.stage_durations = {}
|
||||
self.peak_memory_mb = 0.0
|
||||
|
||||
@@ -137,10 +136,7 @@ class MockStageResult:
|
||||
outputs = [SimpleNamespace(text=text, index=0)]
|
||||
else:
|
||||
outputs = []
|
||||
self.request_output = SimpleNamespace(
|
||||
outputs=outputs,
|
||||
images=self.images,
|
||||
)
|
||||
self.outputs = outputs
|
||||
self.stage_durations = {}
|
||||
self.peak_memory_mb = 0.0
|
||||
|
||||
@@ -2080,22 +2076,20 @@ def test_extract_images_from_result():
|
||||
assert all(isinstance(img, Image.Image) for img in images)
|
||||
assert all(img.size == (64, 64) for img in images)
|
||||
|
||||
# Test dict path: result.request_output["images"]
|
||||
# Test result with "images" attribute set in __init__
|
||||
class DictRequestOutput:
|
||||
def __init__(self):
|
||||
self.request_output = {"images": [np.random.randint(0, 255, (64, 64, 3), dtype=np.uint8)]}
|
||||
self.images = [np.random.randint(0, 255, (64, 64, 3), dtype=np.uint8)]
|
||||
|
||||
result = DictRequestOutput()
|
||||
images = _extract_images_from_result(result)
|
||||
assert len(images) == 1
|
||||
assert isinstance(images[0], Image.Image)
|
||||
|
||||
# Test attribute path: result.request_output.images
|
||||
# Test result with "images" attribute from an inner object
|
||||
class AttrRequestOutput:
|
||||
def __init__(self):
|
||||
self.request_output = type(
|
||||
"obj", (), {"images": [np.random.randint(0, 255, (32, 32, 3), dtype=np.uint8)]}
|
||||
)()
|
||||
self.images = [np.random.randint(0, 255, (32, 32, 3), dtype=np.uint8)]
|
||||
|
||||
result = AttrRequestOutput()
|
||||
images = _extract_images_from_result(result)
|
||||
|
||||
Reference in new issue
Block a user