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>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
7dcb4068a6
commit
d5fd56541b
@@ -548,7 +548,7 @@ def notify_workers_to_start(worker_urls, master_url, session_name, sync_models_t
|
||||
Notify remote worker ComfyUI instances to start processing.
|
||||
Sends POST /distribution/start_worker to each worker URL.
|
||||
|
||||
Uses urllib.request (no 'requests' library for ComfyUI Registry compliance).
|
||||
Uses network_utils.py gateway for all outbound requests.
|
||||
|
||||
Args:
|
||||
worker_urls: List of worker base URLs
|
||||
|
||||
@@ -656,7 +656,7 @@ class WorkerThread(threading.Thread):
|
||||
def _submit_result(self, job_id, image_bytes, meta, max_retries=3):
|
||||
"""
|
||||
Upload image + metadata to master via multipart POST.
|
||||
Uses urllib (no 'requests' library for ComfyUI Registry compliance).
|
||||
Uses network_utils.py gateway for all outbound requests.
|
||||
Retries on transient network errors (connection reset, timeout).
|
||||
"""
|
||||
# JSON-safe meta (ensure no non-serializable types from config round-trip)
|
||||
|
||||
+5
-3
@@ -16,9 +16,6 @@ import urllib.request
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
|
||||
import torch
|
||||
from safetensors.torch import _tobytes
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# 1. CIVITAI API — Model/LoRA metadata lookup
|
||||
@@ -91,6 +88,11 @@ def huggingface_vae_decode(endpoint_url, tensor, height, width):
|
||||
ValueError: If endpoint_url is not in the allowlist
|
||||
RuntimeError: If the remote endpoint returns non-200
|
||||
"""
|
||||
# Lazy imports — only needed for HF VAE, avoids breaking CivitAI/Distribution
|
||||
# if torch or safetensors are not installed
|
||||
import torch
|
||||
from safetensors.torch import _tobytes
|
||||
|
||||
# Validate endpoint against allowlist
|
||||
if endpoint_url not in HUGGINGFACE_VAE_ENDPOINTS.values():
|
||||
raise ValueError(
|
||||
|
||||
Reference in New Issue
Block a user