[Partner Nodes] feat: add Runway Aleph2 node#14306
Conversation
Signed-off-by: bigcat88 <bigcat88@icloud.com>
📝 WalkthroughWalkthroughThis PR adds Aleph2 video-to-video editing support to the Runway node collection. It introduces three new node classes—Keyframe, Prompt Image, and Video-to-Video—that enable timeline-aware guidance images for video generation. The implementation validates constraints (prompt length, video duration, fps caps), uploads videos and guidance images, constructs Aleph2 request payloads, polls for task completion, and downloads results. Simultaneously, the PR refactors progress extraction into get_response and migrates exception handling from the removed RunwayApiError to ValueError across existing nodes. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@comfy_api_nodes/nodes_runway.py`:
- Around line 789-815: Validate all Aleph2 inputs (keyframes and prompt_images)
before calling upload_video_to_comfyapi or upload_image_to_comfyapi: first check
keyframes is not None and enforce len(keyframes.items) <= 5 and call
_check_seconds for each KEYFRAME_MODE_SECONDS item, and similarly validate
prompt_images length and timestamps/percentages for PROMPT_IMAGE_MODE_TIMESTAMP
before any uploads; only after these validations pass, call
upload_video_to_comfyapi and then upload_image_to_comfyapi for each item to
build keyframe_models and prompt_image_models so failed/invalid requests never
trigger uploads. Ensure references to upload_video_to_comfyapi,
upload_image_to_comfyapi, keyframes, prompt_images, and _check_seconds are used
to locate and reorder the logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4b13f73b-2385-4493-a9e4-735d92a0265d
⛔ Files ignored due to path filters (1)
comfy_api_nodes/apis/runway.pyis excluded by!comfy_api_nodes/apis/**
📒 Files selected for processing (1)
comfy_api_nodes/nodes_runway.py
| video_url = await upload_video_to_comfyapi(cls, video) | ||
|
|
||
| keyframe_models: list[RunwayAleph2KeyframeSeconds | RunwayAleph2KeyframeAt] = [] | ||
| if keyframes is not None: | ||
| if len(keyframes.items) > 5: | ||
| raise ValueError("Aleph2 supports at most 5 keyframes.") | ||
| for item in keyframes.items: | ||
| image_url = await upload_image_to_comfyapi(cls, item.image, mime_type="image/png") | ||
| if item.mode == KEYFRAME_MODE_SECONDS: | ||
| _check_seconds(item.value, "Keyframe timestamp") | ||
| keyframe_models.append(RunwayAleph2KeyframeSeconds(seconds=item.value, uri=image_url)) | ||
| else: | ||
| keyframe_models.append(RunwayAleph2KeyframeAt(at=item.value, uri=image_url)) | ||
|
|
||
| prompt_image_models: list[RunwayAleph2PromptImage] = [] | ||
| if prompt_images is not None: | ||
| if len(prompt_images.items) > 5: | ||
| raise ValueError("Aleph2 supports at most 5 prompt images.") | ||
| for item in prompt_images.items: | ||
| image_url = await upload_image_to_comfyapi(cls, item.image, mime_type="image/png") | ||
| position: RunwayAleph2TimestampPosition | RunwayAleph2RelativePosition | ||
| if item.mode == PROMPT_IMAGE_MODE_TIMESTAMP: | ||
| _check_seconds(item.value, "Prompt image timestamp") | ||
| position = RunwayAleph2TimestampPosition(timestampSeconds=item.value) | ||
| else: | ||
| position = RunwayAleph2RelativePosition(positionPercentage=item.value) | ||
| prompt_image_models.append(RunwayAleph2PromptImage(position=position, uri=image_url)) |
There was a problem hiding this comment.
Finish validating Aleph2 inputs before the first upload.
Line 789 uploads the source video, and Lines 796/808 upload guidance images, before this method rejects too many items or out-of-range timestamps. Invalid requests currently pay the full upload cost for assets that will never be used.
♻️ Suggested flow
- video_url = await upload_video_to_comfyapi(cls, video)
-
- keyframe_models: list[RunwayAleph2KeyframeSeconds | RunwayAleph2KeyframeAt] = []
- if keyframes is not None:
- if len(keyframes.items) > 5:
- raise ValueError("Aleph2 supports at most 5 keyframes.")
+ if keyframes is not None and len(keyframes.items) > 5:
+ raise ValueError("Aleph2 supports at most 5 keyframes.")
+ if prompt_images is not None and len(prompt_images.items) > 5:
+ raise ValueError("Aleph2 supports at most 5 prompt images.")
+
+ for item in keyframes.items if keyframes is not None else []:
+ if item.mode == KEYFRAME_MODE_SECONDS:
+ _check_seconds(item.value, "Keyframe timestamp")
+ for item in prompt_images.items if prompt_images is not None else []:
+ if item.mode == PROMPT_IMAGE_MODE_TIMESTAMP:
+ _check_seconds(item.value, "Prompt image timestamp")
+
+ video_url = await upload_video_to_comfyapi(cls, video)
+
+ keyframe_models: list[RunwayAleph2KeyframeSeconds | RunwayAleph2KeyframeAt] = []
+ if keyframes is not None:
for item in keyframes.items:
image_url = await upload_image_to_comfyapi(cls, item.image, mime_type="image/png")
- if item.mode == KEYFRAME_MODE_SECONDS:
- _check_seconds(item.value, "Keyframe timestamp")
+ if item.mode == KEYFRAME_MODE_SECONDS:
keyframe_models.append(RunwayAleph2KeyframeSeconds(seconds=item.value, uri=image_url))As per coding guidelines, comfy_api_nodes/** reviews should focus on proper error handling for API failures.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@comfy_api_nodes/nodes_runway.py` around lines 789 - 815, Validate all Aleph2
inputs (keyframes and prompt_images) before calling upload_video_to_comfyapi or
upload_image_to_comfyapi: first check keyframes is not None and enforce
len(keyframes.items) <= 5 and call _check_seconds for each KEYFRAME_MODE_SECONDS
item, and similarly validate prompt_images length and timestamps/percentages for
PROMPT_IMAGE_MODE_TIMESTAMP before any uploads; only after these validations
pass, call upload_video_to_comfyapi and then upload_image_to_comfyapi for each
item to build keyframe_models and prompt_image_models so failed/invalid requests
never trigger uploads. Ensure references to upload_video_to_comfyapi,
upload_image_to_comfyapi, keyframes, prompt_images, and _check_seconds are used
to locate and reorder the logic.
Source: Coding guidelines
Nodes for this endpoint: https://docs.dev.runwayml.com/api/#tag/Start-generating/paths/~1v1~1video_to_video/post
API Node PR Checklist
Scope
Pricing & Billing
If Need pricing update:
QA
Comms