Skip to content

Commit d5fd565

Browse files
JasonHokuclaude
andcommitted
fix: lazy-import torch/safetensors in network gateway, update stale comments
Move torch and safetensors imports inside huggingface_vae_decode() so CivitAI and Distribution functions still work if those packages are missing. Update stale "Uses urllib" comments to reference the gateway. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7dcb406 commit d5fd565

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

distribution_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ def notify_workers_to_start(worker_urls, master_url, session_name, sync_models_t
548548
Notify remote worker ComfyUI instances to start processing.
549549
Sends POST /distribution/start_worker to each worker URL.
550550
551-
Uses urllib.request (no 'requests' library for ComfyUI Registry compliance).
551+
Uses network_utils.py gateway for all outbound requests.
552552
553553
Args:
554554
worker_urls: List of worker base URLs

distribution_worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ def _process_job(self, job):
656656
def _submit_result(self, job_id, image_bytes, meta, max_retries=3):
657657
"""
658658
Upload image + metadata to master via multipart POST.
659-
Uses urllib (no 'requests' library for ComfyUI Registry compliance).
659+
Uses network_utils.py gateway for all outbound requests.
660660
Retries on transient network errors (connection reset, timeout).
661661
"""
662662
# JSON-safe meta (ensure no non-serializable types from config round-trip)

network_utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
import urllib.error
1717
import urllib.parse
1818

19-
import torch
20-
from safetensors.torch import _tobytes
21-
2219

2320
# =============================================================================
2421
# 1. CIVITAI API — Model/LoRA metadata lookup
@@ -91,6 +88,11 @@ def huggingface_vae_decode(endpoint_url, tensor, height, width):
9188
ValueError: If endpoint_url is not in the allowlist
9289
RuntimeError: If the remote endpoint returns non-200
9390
"""
91+
# Lazy imports — only needed for HF VAE, avoids breaking CivitAI/Distribution
92+
# if torch or safetensors are not installed
93+
import torch
94+
from safetensors.torch import _tobytes
95+
9496
# Validate endpoint against allowlist
9597
if endpoint_url not in HUGGINGFACE_VAE_ENDPOINTS.values():
9698
raise ValueError(

0 commit comments

Comments
 (0)