Skip to content
Closed
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
23 changes: 20 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ history.
`asset_upload_refused`; new codes `asset_upload_invalid`,
`asset_upload_failed` and `asset_upload_timeout` cover the other ways it
can end.

- `comfy knowledge resolve` suggests canonical model ids for an incomplete
family/version name such as `Qwen 2.1`. The command still fails with
`knowledge_unknown_model` and exit 1, but `error.details.candidate_ids` lists
Expand All @@ -60,9 +61,21 @@ history.

### Fixed

- `comfy assets library ls` reports a 401 or 403 as `cloud_unauthorized` even
when the server drops the connection partway through its error body, instead
of crashing with `IncompleteRead`.
- `comfy update` no longer dies with a `FileNotFoundError` traceback when the
configured workspace directory does not exist (never installed, or deleted).
It now fails with a `not_in_workspace` error that points at `comfy install`,
including when `--recent` cannot resolve a workspace, keeping the resolver's
exit status.

- `comfy update cli` works for a `uv tool install` of comfy-cli. Those envs ship
without pip, so the old `python -m pip install -U` always failed; it now runs
`uv tool upgrade comfy-cli`, and any installer failure is reported as an
`update_cli_failed` error rather than a traceback. The upgrade targets the
running installation's tool directory even when `UV_TOOL_DIR` is absent or
selects a different directory in the current shell. An exact uv version pin
is preserved and reported with manual reinstall guidance. Installer diagnostics
stay on stderr in JSON/NDJSON modes, which end with one success or error envelope.

- A typed `comfy model download` with no `--relative-path` now saves into the
folder the running local ComfyUI scans for that model type, and says where.
On Comfy Desktop that is the shared library, not the install's `models/`.
Expand Down Expand Up @@ -112,6 +125,10 @@ history.
value. Saves with a real marker have one more value than sockets and still go
through the filter.

- `comfy assets library ls` reports a 401 or 403 as `cloud_unauthorized` even
when the server drops the connection partway through its error body, instead
of crashing with `IncompleteRead`.

## [1.24.0] - 2026-10-29

[Full notes](https://github.com/Comfy-Org/comfy-cli/releases/tag/v1.24.0) · 25 commits since v1.23.0.
Expand Down
61 changes: 55 additions & 6 deletions comfy_cli/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1759,13 +1759,52 @@ def update(
raise typer.Exit(code=1)

if "cli" == target:
from comfy_cli.update import upgrade_cli
from comfy_cli.update import UpgradeUnavailable, upgrade_cli

rprint("Updating comfy-cli...")
upgrade_cli()
try:
upgrade_cli()
except UpgradeUnavailable as e:
get_renderer().error(code="update_cli_failed", message=str(e), hint=e.hint)
raise typer.Exit(code=1) from e
except subprocess.CalledProcessError as e:
get_renderer().error(
code="update_cli_failed",
message=f"`{' '.join(map(str, e.cmd))}` failed with exit code {e.returncode}.",
hint="see the installer output above; re-running `comfy update cli` is safe",
details={"returncode": e.returncode},
)
raise typer.Exit(code=1) from e
except subprocess.TimeoutExpired as e:
get_renderer().error(
code="update_cli_failed",
message=f"The comfy-cli installer timed out after {e.timeout} seconds.",
hint="check the installer output, then re-run `comfy update cli`",
details={"timeout": e.timeout},
)
raise typer.Exit(code=1) from e
except OSError as e:
get_renderer().error(
code="update_cli_failed",
message=f"Could not start the comfy-cli installer: {e}",
hint="check the installer executable and its permissions, then re-run `comfy update cli`",
)
raise typer.Exit(code=1) from e
get_renderer().emit({"target": "cli"}, command="update")
return

comfy_path = workspace_manager.workspace_path
try:
comfy_path = workspace_manager.workspace_path
except typer.Exit as error:
if target != "comfy":
raise
get_renderer().error(
code="not_in_workspace",
message="ComfyUI workspace could not be resolved.",
hint="run `comfy install`, or pass `--workspace` to point at an existing install",
exit_code=error.exit_code,
)
raise

if "all" == target:
# Without raise_on_error, execute_cm_cli swallows a cm-cli exit 1 and returns None,
Expand Down Expand Up @@ -1798,10 +1837,20 @@ def update(
)
raise typer.Exit(code=code) from e
else:
rprint(f"Updating ComfyUI in {comfy_path}...")
if comfy_path is None:
rprint("ComfyUI path is not found.")
# The default workspace path comes from config and can name a directory that
# was never installed (or was deleted), so check existence, not just None.
if comfy_path is None or not os.path.isdir(comfy_path):
get_renderer().error(
code="not_in_workspace",
message=(
"ComfyUI workspace not found."
if comfy_path is None
else f"ComfyUI workspace not found: {comfy_path}"
),
hint="run `comfy install`, or pass `--workspace` to point at an existing install",
)
raise typer.Exit(code=1)
rprint(f"Updating ComfyUI in {comfy_path}...")
if version is not None:
_switch_comfy_version(comfy_path, version, stash=not no_stash)
else:
Expand Down
9 changes: 9 additions & 0 deletions comfy_cli/error_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,15 @@ class ErrorCode:
"CLI usage error).",
"read the cm-cli output above for the failing pack, then re-run `comfy update all`",
),
ErrorCode(
"update_cli_failed",
"`comfy update cli` could not upgrade comfy-cli: either no usable installer was found "
"(a `uv tool` env without `uv` on PATH, or an env without pip), the uv receipt is unreadable "
"or pins the CLI to an exact version, or the installer could not start, timed out, or exited non-zero. "
"`details.timeout` carries the expired time budget; `details.returncode` carries a non-zero exit status.",
"follow the error's hint; for a `uv tool` install, ensure `uv` is on PATH and use the stated "
"UV_TOOL_DIR; change an exact version pin only through an explicit reinstall",
),
ErrorCode(
"version_switch_unknown_version",
"`comfy update comfy --version X` could not resolve X to a ComfyUI tag; the workspace was left untouched.",
Expand Down
113 changes: 110 additions & 3 deletions comfy_cli/update.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib.util
import json
import logging
import os
Expand All @@ -9,10 +10,13 @@
import requests
from packaging import version

from comfy_cli._safe_exec import resolve_binary

logger = logging.getLogger(__name__)

UPDATE_CHECK_TTL_SECONDS = 24 * 60 * 60
UPDATE_CHECK_DISABLE_ENV = "COMFY_NO_UPDATE_CHECK"
CLI_UPGRADE_TIMEOUT_SECONDS = 600


def check_for_newer_pypi_version(package_name, current_version):
Expand All @@ -39,10 +43,113 @@ def check_for_newer_pypi_version(package_name, current_version):
return False, current_version


class UpgradeUnavailable(RuntimeError):
"""The running installation cannot be upgraded automatically."""

def __init__(self, message: str, hint: str):
super().__init__(message)
self.hint = hint


def _check_uv_tool_pin(receipt: Path) -> None:
"""Preserve exact primary-tool constraints rather than reporting a no-op upgrade."""
from packaging.requirements import Requirement
from packaging.specifiers import SpecifierSet
from packaging.utils import canonicalize_name
from tomlkit import parse
from tomlkit.exceptions import ParseError

tool_root = receipt.parent.parent
hint = (
"Review the receipt. To change or remove a pin, explicitly reinstall using your chosen requirement "
"(for example `uv tool install --force comfy-cli` to remove it); "
f"first set UV_TOOL_DIR to {tool_root} to target this installation."
)
pinned = False
try:
tool = parse(receipt.read_text(encoding="utf-8")).unwrap().get("tool")
if not isinstance(tool, dict):
raise ValueError("missing tool table")
for field in ("requirements", "constraints"):
rows = tool.get(field, [])
if not isinstance(rows, list):
raise ValueError("invalid requirement list")
for row in rows:
if isinstance(row, str):
requirement = Requirement(row)
name, specifiers = requirement.name, requirement.specifier
elif isinstance(row, dict):
name = row.get("name")
if not isinstance(name, str):
raise ValueError("missing requirement name")
parsed_name = Requirement(name)
if parsed_name.extras or parsed_name.url or parsed_name.specifier or parsed_name.marker:
raise ValueError("invalid package name")
if canonicalize_name(name) != "comfy-cli":
continue
specifier = row.get("specifier", "")
if not isinstance(specifier, str):
raise ValueError("invalid primary specifier")
specifiers = SpecifierSet(specifier)
else:
raise ValueError("invalid requirement row")
if canonicalize_name(name) == "comfy-cli" and any(
spec.operator == "===" or (spec.operator == "==" and not spec.version.endswith(".*"))
for spec in specifiers
):
pinned = True
except (OSError, ValueError, ParseError) as error:
raise UpgradeUnavailable("The running uv tool receipt could not be read or understood.", hint=hint) from error
if pinned:
raise UpgradeUnavailable(
"The running comfy-cli installation has an exact uv version pin; this command will not remove it.",
hint=hint,
)


def upgrade_cli():
"""Upgrade the ``comfy-cli`` package itself via pip against the running
interpreter. Raises ``CalledProcessError`` if pip fails — fail fast."""
subprocess.run([sys.executable, "-m", "pip", "install", "-U", "comfy-cli"], check=True)
"""Upgrade the ``comfy-cli`` package itself in the environment it runs from.

A ``uv tool install`` env ships without pip, so it is upgraded through
``uv tool upgrade``; anything else goes through pip against the running
interpreter. Exact uv pins remain unchanged. Raises ``UpgradeUnavailable``
for unusable installers or receipts, and propagates installer exit, start,
or timeout failures to the command."""
from comfy_cli.output import get_renderer

installer_stdout = sys.stderr if get_renderer().is_json() else None
receipt = Path(sys.prefix) / "uv-receipt.toml"
if receipt.is_file():
uv = resolve_binary("uv")
if uv is None:
raise UpgradeUnavailable(
"comfy-cli was installed with `uv tool`, but `uv` is not on PATH.",
hint="run `uv tool upgrade comfy-cli` from a shell where uv is available",
)
_check_uv_tool_pin(receipt)
# Upgrade the running installation even if its original tool-dir override
# is absent now, or the current shell selects another tools directory.
installer_env = os.environ.copy()
installer_env["UV_TOOL_DIR"] = str(Path(sys.prefix).parent)
subprocess.run(
[uv, "tool", "upgrade", "comfy-cli"],
check=True,
timeout=CLI_UPGRADE_TIMEOUT_SECONDS,
env=installer_env,
stdout=installer_stdout,
)
return
if importlib.util.find_spec("pip") is None:
raise UpgradeUnavailable(
f"pip is not installed in the comfy-cli environment ({sys.prefix}).",
hint="upgrade comfy-cli with the tool that installed it (e.g. `pipx upgrade comfy-cli`)",
)
subprocess.run(
[sys.executable, "-m", "pip", "install", "-U", "comfy-cli"],
check=True,
timeout=CLI_UPGRADE_TIMEOUT_SECONDS,
stdout=installer_stdout,
)
Comment thread
wealthwiselabs marked this conversation as resolved.
Resolved


def _read_fresh_cache(cache_file, now):
Expand Down
16 changes: 15 additions & 1 deletion tests/comfy_cli/command/test_assets_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,22 @@ def reset_singleton():
reset_renderer_for_testing()


@pytest.fixture(scope="module")
def root_cli_ready():
"""Load the actual CLI before a test's target fake can bind into lazy modules."""
from click import Context
from typer.main import get_command

from comfy_cli.cmdline import app as root_app

root = get_command(root_app)
with Context(root) as context:
for name in root.list_commands(context):
root.get_command(context, name)


@pytest.fixture
def cloud_target(monkeypatch: pytest.MonkeyPatch):
def cloud_target(monkeypatch: pytest.MonkeyPatch, root_cli_ready):
from comfy_cli.target import Target

fake = Target(
Expand Down
9 changes: 8 additions & 1 deletion tests/comfy_cli/command/test_deploy_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,14 @@ class _TerminalRenderer:
def __init__(self, width: int) -> None:
from rich.console import Console

self._console = Console(file=io.StringIO(), width=width, force_terminal=True, color_system=None)
# Emulate the promised terminal even when the caller exports TERM=dumb.
self._console = Console(
file=io.StringIO(),
width=width,
force_terminal=True,
color_system=None,
_environ={"TERM": "xterm-256color"},
)

def is_pretty(self) -> bool:
return True
Expand Down
3 changes: 2 additions & 1 deletion tests/comfy_cli/command/test_pretty_print_sanitize.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ def test_status_glyph_keeps_its_own_tags_live(pretty):

from comfy_cli.output.glyphs import status_glyph

console = Console(file=pretty, force_terminal=True, width=80)
# This tests authored styling, independently of the caller's terminal type.
console = Console(file=pretty, force_terminal=True, width=80, _environ={"TERM": "xterm-256color"})
console.print(status_glyph("success"))
out = pretty.getvalue()

Expand Down
34 changes: 25 additions & 9 deletions tests/comfy_cli/command/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2363,14 +2363,29 @@ def test_markup_in_node_name_does_not_crash_confirm(self, monkeypatch):


class TestExecuteUiWorkflow:
@pytest.fixture(autouse=True)
def local_preflight_catalog(self, monkeypatch):
"""Validate against the complete conversion fixture without a live server."""
from copy import deepcopy

monkeypatch.setattr("comfy_cli.command.run._fetch_object_info", lambda *a, **k: deepcopy(self.OBJECT_INFO))

def unexpected_catalog_request(*args, **kwargs):
pytest.fail("unexpected real catalog request; mock the specific object_info transport")

monkeypatch.setattr("comfy_cli.http._PLAIN_OPENER.open", unexpected_catalog_request)
monkeypatch.setattr("comfy_cli.cql.engine._load_from_target", unexpected_catalog_request)

# The conversion success fixture must also be an executable graph:
# PreviewImage consumes IMAGE, not an EmptyLatentImage's LATENT output.
UI = {
"nodes": [
{
"id": 1,
"type": "EmptyLatentImage",
"type": "EmptyImage",
"inputs": [],
"outputs": [{"name": "LATENT", "type": "LATENT", "links": [10]}],
"widgets_values": [512, 512, 1],
"outputs": [{"name": "IMAGE", "type": "IMAGE", "links": [10]}],
"widgets_values": [512, 512, 1, 0],
"mode": 0,
},
{
Expand All @@ -2384,19 +2399,20 @@ class TestExecuteUiWorkflow:
"links": [[10, 1, 0, 2, 0, "IMAGE"]],
}
OBJECT_INFO = {
"EmptyLatentImage": {
"EmptyImage": {
"input": {
"required": {
"width": ["INT", {"default": 512}],
"height": ["INT", {"default": 512}],
"batch_size": ["INT", {"default": 1}],
"color": ["INT", {"default": 0}],
}
},
"input_order": {"required": ["width", "height", "batch_size"]},
"output": ["LATENT"],
"output_name": ["LATENT"],
"input_order": {"required": ["width", "height", "batch_size", "color"]},
"output": ["IMAGE"],
"output_name": ["IMAGE"],
"output_node": False,
"display_name": "Empty Latent Image",
"display_name": "Empty Image",
},
"PreviewImage": {
"input": {"required": {"images": ["IMAGE"]}},
Expand Down Expand Up @@ -2435,7 +2451,7 @@ def test_ui_workflow_is_converted_then_executed(self, ui_workflow_file):
assert mock_fetch.call_args.args == ("127.0.0.1", 8188, 30)
api_workflow = MockExec.call_args.args[0]
assert set(api_workflow) == {"1", "2"}
assert api_workflow["1"]["class_type"] == "EmptyLatentImage"
assert api_workflow["1"]["class_type"] == "EmptyImage"
assert api_workflow["2"]["inputs"]["images"] == ["1", 0]
mock_exec.queue.assert_called_once()

Expand Down
Loading
Loading