Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions capabilities/comfyui/app.py
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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:
Expand All @@ -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.")
16 changes: 12 additions & 4 deletions capabilities/comfyui/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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"
Loading