Skip to content

Commit 852704c

Browse files
authored
fix(seedream4): add flag to ignore error on partial success (Comfy-Org#9952)
1 parent 9fdf8c2 commit 852704c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

comfy_api_nodes/nodes_bytedance.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,12 @@ def define_schema(cls):
567567
tooltip="Whether to add an \"AI generated\" watermark to the image.",
568568
optional=True,
569569
),
570+
comfy_io.Boolean.Input(
571+
"fail_on_partial",
572+
default=True,
573+
tooltip="If enabled, abort execution if any requested images are missing or return an error.",
574+
optional=True,
575+
),
570576
],
571577
outputs=[
572578
comfy_io.Image.Output(),
@@ -592,6 +598,7 @@ async def execute(
592598
max_images: int = 1,
593599
seed: int = 0,
594600
watermark: bool = True,
601+
fail_on_partial: bool = True,
595602
) -> comfy_io.NodeOutput:
596603
validate_string(prompt, strip_whitespace=True, min_length=1)
597604
w = h = None
@@ -651,9 +658,10 @@ async def execute(
651658

652659
if len(response.data) == 1:
653660
return comfy_io.NodeOutput(await download_url_to_image_tensor(get_image_url_from_response(response)))
654-
return comfy_io.NodeOutput(
655-
torch.cat([await download_url_to_image_tensor(str(i["url"])) for i in response.data])
656-
)
661+
urls = [str(d["url"]) for d in response.data if isinstance(d, dict) and "url" in d]
662+
if fail_on_partial and len(urls) < len(response.data):
663+
raise RuntimeError(f"Only {len(urls)} of {len(response.data)} images were generated before error.")
664+
return comfy_io.NodeOutput(torch.cat([await download_url_to_image_tensor(i) for i in urls]))
657665

658666

659667
class ByteDanceTextToVideoNode(comfy_io.ComfyNode):
@@ -1171,7 +1179,7 @@ async def process_video_task(
11711179
payload: Union[Text2VideoTaskCreationRequest, Image2VideoTaskCreationRequest],
11721180
auth_kwargs: dict,
11731181
node_id: str,
1174-
estimated_duration: int | None,
1182+
estimated_duration: Optional[int],
11751183
) -> comfy_io.NodeOutput:
11761184
initial_response = await SynchronousOperation(
11771185
endpoint=ApiEndpoint(

0 commit comments

Comments
 (0)