Skip to content

[Partner Nodes] ByteDance: virtual portrait library for regular images#13638

Merged
Kosinkadink merged 3 commits intomasterfrom
feat/api-nodes/bytedance-virtual-port-lib
Apr 30, 2026
Merged

[Partner Nodes] ByteDance: virtual portrait library for regular images#13638
Kosinkadink merged 3 commits intomasterfrom
feat/api-nodes/bytedance-virtual-port-lib

Conversation

@bigcat88
Copy link
Copy Markdown
Contributor

@bigcat88 bigcat88 commented Apr 30, 2026

API Node PR Checklist

Scope

  • Is API Node Change

Pricing & Billing

  • Need pricing update
  • No pricing update

If Need pricing update:

  • Metronome rate cards updated
  • Auto‑billing tests updated and passing

QA

  • QA done
  • QA not required

Comms

  • Informed Kosinkadink

…ar images

Signed-off-by: bigcat88 <bigcat88@icloud.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

📝 Walkthrough

Walkthrough

Adds SHA-256 hashing for image tensors and a helper that uploads images to ComfyAPI, registers them via SeedanceVirtualLibraryCreateAssetRequest, polls until the asset reaches Active, and returns asset://<asset_id>. Updates ByteDance2FirstLastFrameNode and ByteDance2ReferenceNode to route inline images through this virtual-library asset registration flow instead of the previous direct upload URL path. No public API signatures changed.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: implementing a virtual portrait library feature for ByteDance nodes that handles regular images.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description directly relates to the changeset, describing an API node change for ByteDance virtual portrait library using inline images.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@comfy_api_nodes/nodes_bytedance.py`:
- Around line 284-289: The current image dedup hash computed in the image_hash
line (using hashlib.sha256 on
image.detach().cpu().contiguous().to(torch.float32).numpy().tobytes()) omits the
image shape and can cause collisions for different-shaped arrays with identical
flattened bytes; update the hash computation in the same block (where image_hash
is created, referenced by the variable image and the use of hashlib.sha256) to
also incorporate the image shape (for example by feeding the shape tuple or its
bytes into the hasher before/after the raw bytes) so the resulting hash used in
SeedanceVirtualLibraryCreateAssetRequest is unique to both content and
dimensions.
- Around line 283-289: The synchronous SHA-256 tensor hashing (the image_hash
computation) blocks the event loop; modify ByteDance2ReferenceNode.execute to
offload that work by running the hashing expression inside asyncio.to_thread and
awaiting it before calling sync_op/create request. Specifically, replace the
direct image.detach().cpu().contiguous().to(torch.float32).numpy().tobytes() +
hashlib.sha256(...).hexdigest() computation with an awaited asyncio.to_thread
wrapper that returns the hex digest and assign it to image_hash (keep
upload_image_to_comfyapi call and subsequent
sync_op/SeedanceVirtualLibraryCreateAssetRequest usage unchanged).
🪄 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: f05c165c-9863-44a8-b081-ca12b796b3f8

📥 Commits

Reviewing files that changed from the base of the PR and between 38ecad8 and b318f10.

⛔ Files ignored due to path filters (1)
  • comfy_api_nodes/apis/bytedance.py is excluded by !comfy_api_nodes/apis/**
📒 Files selected for processing (1)
  • comfy_api_nodes/nodes_bytedance.py

Comment thread comfy_api_nodes/nodes_bytedance.py
Comment thread comfy_api_nodes/nodes_bytedance.py Outdated
Signed-off-by: bigcat88 <bigcat88@icloud.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
comfy_api_nodes/nodes_bytedance.py (1)

284-289: ⚠️ Potential issue | 🟠 Major

Offload hash computation from the async path.

This new code performs CPU-heavy tensor normalization + NumPy conversion + SHA-256 directly on the event loop. With multiple reference images, it can block concurrent async work. Please move hashing into asyncio.to_thread(...).

Suggested fix
+import asyncio
 import hashlib
-    normalized = image.detach().cpu().contiguous().to(torch.float32)
-    digest = hashlib.sha256()
-    digest.update(str(tuple(normalized.shape)).encode("utf-8"))
-    digest.update(b"\0")
-    digest.update(normalized.numpy().tobytes())
-    image_hash = digest.hexdigest()
+    def _compute_image_hash() -> str:
+        normalized = image.detach().cpu().contiguous().to(torch.float32)
+        digest = hashlib.sha256()
+        digest.update(str(tuple(normalized.shape)).encode("utf-8"))
+        digest.update(b"\0")
+        digest.update(normalized.numpy().tobytes())
+        return digest.hexdigest()
+
+    image_hash = await asyncio.to_thread(_compute_image_hash)

Based on learnings: "if the PR adds new synchronous CPU/IO work inside async def execute, prefer offloading with asyncio.to_thread (or an equivalent background executor) to avoid blocking the event loop."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@comfy_api_nodes/nodes_bytedance.py` around lines 284 - 289, The CPU-heavy
tensor normalization, NumPy conversion and SHA-256 hash must be offloaded from
the async path: create a synchronous helper (e.g., compute_image_hash(image))
that performs normalized = image.detach().cpu().contiguous().to(torch.float32),
builds the hashlib digest from normalized.numpy().tobytes() and returns the hex
digest, then inside async def execute replace the inline hashing code with:
image_hash = await asyncio.to_thread(compute_image_hash, image). Ensure the
helper name (compute_image_hash), the image_hash variable and the call site in
async def execute are updated accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@comfy_api_nodes/nodes_bytedance.py`:
- Around line 284-289: The CPU-heavy tensor normalization, NumPy conversion and
SHA-256 hash must be offloaded from the async path: create a synchronous helper
(e.g., compute_image_hash(image)) that performs normalized =
image.detach().cpu().contiguous().to(torch.float32), builds the hashlib digest
from normalized.numpy().tobytes() and returns the hex digest, then inside async
def execute replace the inline hashing code with: image_hash = await
asyncio.to_thread(compute_image_hash, image). Ensure the helper name
(compute_image_hash), the image_hash variable and the call site in async def
execute are updated accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fecd10b8-e2bf-440f-9684-e01a64524149

📥 Commits

Reviewing files that changed from the base of the PR and between b318f10 and cde8a63.

📒 Files selected for processing (1)
  • comfy_api_nodes/nodes_bytedance.py

@Kosinkadink Kosinkadink merged commit b633244 into master Apr 30, 2026
17 checks passed
@bigcat88 bigcat88 deleted the feat/api-nodes/bytedance-virtual-port-lib branch April 30, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants