From a0465f30f5446cdb8636dd702bf94da34116f22c Mon Sep 17 00:00:00 2001 From: dillonroach Date: Thu, 7 May 2026 13:47:21 -0700 Subject: [PATCH] pipe fixes for windows and throttling the download print spam --- capabilities/comfyui/app.py | 31 +++++++++++++++++++++++++------ capabilities/comfyui/pixi.toml | 16 ++++++++++++---- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/capabilities/comfyui/app.py b/capabilities/comfyui/app.py index f1330cd..a7d05e2 100644 --- a/capabilities/comfyui/app.py +++ b/capabilities/comfyui/app.py @@ -1,6 +1,13 @@ import os +import sys import urllib.request +if sys.platform == 'win32': + for stream in (sys.stdout, sys.stderr): + reconfigure = getattr(stream, 'reconfigure', None) + if reconfigure is not None: + reconfigure(encoding='utf-8', errors='replace') + DOWNLOADS = [ ( "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/diffusion_models/z_image_turbo_bf16.safetensors", @@ -17,11 +24,23 @@ ] -def hook(count, block_size, total_size): - got = count * block_size - if total_size > 0: - pct = min(100.0, got * 100 / total_size) - print(f" {pct:5.1f}% {got/(1024**3):.2f} / {total_size/(1024**3):.2f} GB", flush=True) +PROGRESS_INTERVAL_MB = 100 + + +def make_hook(): + last_mb = [0.0] + + def hook(count, block_size, total_size): + if total_size <= 0: + return + got = count * block_size + mb = got / (1024 ** 2) + if mb - last_mb[0] >= PROGRESS_INTERVAL_MB or got >= total_size: + pct = min(100.0, got * 100 / total_size) + print(f" {pct:5.1f}% {got/(1024**3):.2f} / {total_size/(1024**3):.2f} GB", flush=True) + last_mb[0] = mb + + return hook for url, dest in DOWNLOADS: @@ -30,7 +49,7 @@ def hook(count, block_size, total_size): continue os.makedirs(os.path.dirname(dest), exist_ok=True) print(f"Downloading -> {dest}") - urllib.request.urlretrieve(url, dest, reporthook=hook) + urllib.request.urlretrieve(url, dest, reporthook=make_hook()) print() print("All default model downloads complete.") diff --git a/capabilities/comfyui/pixi.toml b/capabilities/comfyui/pixi.toml index 3c30712..680584e 100755 --- a/capabilities/comfyui/pixi.toml +++ b/capabilities/comfyui/pixi.toml @@ -70,7 +70,7 @@ initialize = { cmd = "echo 'Initialization complete. Run: pixi run serve'", depe # the launch to ./ComfyUI/ rather than trying to pick up a recent install # elsewhere. Extra arguments for main.py (e.g. `-- --listen 0.0.0.0`) # can be appended on the pixi command line. -serve = { cmd = "comfy tracking disable && comfy --here launch", depends-on = ["install-comfyui", "download-models"] } +serve = { cmd = "comfy --skip-prompt --here launch", depends-on = ["install-comfyui", "download-models"] } # --------------------------------------------------------------------------- # Platform-specific `install-comfyui` @@ -94,10 +94,18 @@ serve = { cmd = "comfy tracking disable && comfy --here launch", depends-on = [" # from the nightly PyPI index) # --------------------------------------------------------------------------- [target.linux-64.tasks] -install-comfyui = "comfy tracking disable && (test -d ComfyUI || comfy --skip-prompt --here install --nvidia)" +install-comfyui = "test -d ComfyUI || comfy --skip-prompt --here install --nvidia" [target.win-64.tasks] -install-comfyui = "comfy tracking disable && (if not exist ComfyUI\\ (comfy --skip-prompt --here install --nvidia))" +install-comfyui = "test -d ComfyUI || comfy --skip-prompt --here install --nvidia" + +# Force UTF-8 for all child Python processes (comfy-cli, ComfyUI, pip). +# When the parent (.go) app captures stdout/stderr as pipes, Python on +# Windows defaults to the system codepage (cp1252) and crashes on the +# emoji/box-drawing chars that comfy-cli and ComfyUI emit. +[target.win-64.activation.env] +PYTHONIOENCODING = "utf-8" +PYTHONUTF8 = "1" [target.osx-arm64.tasks] -install-comfyui = "comfy tracking disable && (test -d ComfyUI || comfy --skip-prompt --here install --m-series)" +install-comfyui = "test -d ComfyUI || comfy --skip-prompt --here install --m-series"