fixed: crash related to deleted CNR node after installed

modified: convert cm-cli.sh to cm-cli command
This commit is contained in:
Dr.Lt.Data 2025-04-28 00:13:31 +09:00 committed by bymyself
parent 6233fabe02
commit 9d2034bd4f
6 changed files with 43 additions and 24 deletions

View File

@ -1,2 +0,0 @@
#!/bin/bash
python ./comfyui_manager/cm-cli.py $*

View File

@ -1,6 +1,5 @@
import os
import logging
from comfy.cli_args import args
def prestartup():
from . import prestartup_script # noqa: F401
@ -8,6 +7,8 @@ def prestartup():
def start():
from comfy.cli_args import args
logging.info('[START] ComfyUI-Manager')
from .common import cm_global # noqa: F401
@ -32,6 +33,7 @@ def should_be_disabled(fullpath:str) -> bool:
1. Disables the legacy ComfyUI-Manager.
2. The blocklist can be expanded later based on policies.
"""
from comfy.cli_args import args
if not args.disable_manager:
# In cases where installation is done via a zip archive, the directory name may not be comfyui-manager, and it may not contain a git repository.

View File

View File

@ -15,7 +15,7 @@ import git
import importlib
from .common import manager_util
from ..common import manager_util
# read env vars
# COMFYUI_FOLDERS_BASE_PATH is not required in cm-cli.py
@ -35,11 +35,11 @@ if not os.path.exists(os.path.join(comfy_path, 'folder_paths.py')):
import utils.extra_config
from .common import cm_global
from .glob import manager_core as core
from .common import context
from .glob.manager_core import unified_manager
from .common import cnr_utils
from ..common import cm_global
from ..legacy import manager_core as core
from ..common import context
from ..legacy.manager_core import unified_manager
from ..common import cnr_utils
comfyui_manager_path = os.path.abspath(os.path.dirname(__file__))
@ -108,7 +108,7 @@ class Ctx:
self.no_deps = False
self.mode = 'cache'
self.user_directory = None
self.custom_nodes_paths = [os.path.join(core.comfy_base_path, 'custom_nodes')]
self.custom_nodes_paths = [os.path.join(context.comfy_base_path, 'custom_nodes')]
self.manager_files_directory = os.path.dirname(__file__)
if Ctx.folder_paths is None:
@ -444,10 +444,13 @@ def show_list(kind, simple=False):
flag = kind in ['all', 'cnr', 'installed', 'enabled']
for k, v in unified_manager.active_nodes.items():
if flag:
cnr = unified_manager.cnr_map[k]
cnr = unified_manager.cnr_map.get(k)
if cnr:
processed[k] = "[ ENABLED ] ", cnr['name'], k, cnr['publisher']['name'], v[0]
else:
processed[k] = None
else:
processed[k] = None
if flag and kind != 'cnr':
for k, v in unified_manager.unknown_active_nodes.items():
@ -465,20 +468,26 @@ def show_list(kind, simple=False):
continue
if flag:
cnr = unified_manager.cnr_map[k]
cnr = unified_manager.cnr_map.get(k) # NOTE: can this be None if removed from CNR after installed
if cnr:
processed[k] = "[ DISABLED ] ", cnr['name'], k, cnr['publisher']['name'], ", ".join(list(v.keys()))
else:
processed[k] = None
else:
processed[k] = None
for k, v in unified_manager.nightly_inactive_nodes.items():
if k in processed:
continue
if flag:
cnr = unified_manager.cnr_map[k]
cnr = unified_manager.cnr_map.get(k)
if cnr:
processed[k] = "[ DISABLED ] ", cnr['name'], k, cnr['publisher']['name'], 'nightly'
else:
processed[k] = None
else:
processed[k] = None
if flag and kind != 'cnr':
for k, v in unified_manager.unknown_inactive_nodes.items():
@ -496,11 +505,14 @@ def show_list(kind, simple=False):
continue
if flag:
cnr = unified_manager.cnr_map[k]
cnr = unified_manager.cnr_map.get(k)
if cnr:
ver_spec = v['latest_version']['version'] if 'latest_version' in v else '0.0.0'
processed[k] = "[ NOT INSTALLED ] ", cnr['name'], k, cnr['publisher']['name'], ver_spec
else:
processed[k] = None
else:
processed[k] = None
if flag and kind != 'cnr':
for x in not_installed_unknown_nodes:
@ -1286,6 +1298,10 @@ def export_custom_node_ids(
print(f"{x['id']}@unknown", file=output_file)
def main():
app()
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(app())

View File

@ -87,9 +87,6 @@ manager_pip_blacklist_path = os.path.join(manager_files_path, "pip_blacklist.lis
restore_snapshot_path = os.path.join(manager_files_path, "startup-scripts", "restore-snapshot.json")
manager_config_path = os.path.join(manager_files_path, 'config.ini')
cm_cli_path = os.path.join(comfyui_manager_path, "cm-cli.py")
default_conf = {}
def read_config():
@ -563,7 +560,10 @@ if os.path.exists(restore_snapshot_path):
if 'COMFYUI_FOLDERS_BASE_PATH' not in new_env:
new_env["COMFYUI_FOLDERS_BASE_PATH"] = comfy_path
cmd_str = [sys.executable, cm_cli_path, 'restore-snapshot', restore_snapshot_path]
if 'COMFYUI_PATH' not in new_env:
new_env['COMFYUI_PATH'] = os.path.dirname(folder_paths.__file__)
cmd_str = [sys.executable, '-m', 'comfyui_manager.cm_cli', 'restore-snapshot', restore_snapshot_path]
exit_code = process_wrap(cmd_str, custom_nodes_base_path, handler=msg_capture, env=new_env)
if exit_code != 0:

View File

@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "comfyui-manager"
license = { text = "GPL-3.0-only" }
version = "4.0.0-beta.2"
version = "4.0.0-beta.3"
requires-python = ">= 3.9"
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
readme = "README.md"
@ -48,6 +48,9 @@ Repository = "https://github.com/ltdrdata/ComfyUI-Manager"
where = ["."]
include = ["comfyui_manager*"]
[project.scripts]
cm-cli = "comfyui_manager.cm_cli.__main__:main"
[tool.ruff]
line-length = 120
target-version = "py39"