implement: invalid installation handling

- print invalid installation nodes on terminal
(installed by `comfy registryinstall`)

- show only 'reinstall' menu if invalid installation node in gui
(and show INVALID marker)
This commit is contained in:
Dr.Lt.Data
2024-07-31 02:08:30 +09:00
parent 8e1f792cd1
commit cdb400d32b
4 changed files with 104 additions and 6 deletions

View File

@@ -56,6 +56,55 @@ def download_url(url, dest_folder, filename):
custom_nodes_path = os.path.abspath(os.path.join(comfyui_manager_path, '..'))
invalid_nodes = {}
def check_invalid_nodes():
global invalid_nodes
try:
import folder_paths
node_paths = folder_paths.get_folder_paths("custom_nodes")
except:
try:
sys.path.append(comfy_path)
import folder_paths
except:
raise Exception(f"Invalid COMFYUI_PATH: {comfy_path}")
def check(root):
global invalid_nodes
subdirs = [d for d in os.listdir(root) if os.path.isdir(os.path.join(root, d))]
for subdir in subdirs:
if subdir in ['.disabled', '__pycache__']:
continue
if '@' in subdir:
spec = subdir.split('@')
if spec[1] in ['unknown', 'nightly']:
continue
if not os.path.exists(os.path.join(root, subdir, '.tracking')):
invalid_nodes[spec[0]] = os.path.join(root, subdir)
node_paths = folder_paths.get_folder_paths("custom_nodes")
for x in node_paths:
check(x)
disabled_dir = os.path.join(x, '.disabled')
if os.path.exists(disabled_dir):
check(disabled_dir)
if len(invalid_nodes):
print(f"\n-------------------- ComfyUI-Manager invalid nodes notice ----------------")
print(f"\nNodes requiring reinstallation have been detected:\n(Directly delete the corresponding path and reinstall.)\n")
for x in invalid_nodes.values():
print(x)
print("\n---------------------------------------------------------------------------\n")
comfy_path = os.environ.get('COMFYUI_PATH')
if comfy_path is None:
@@ -2368,6 +2417,9 @@ async def get_unified_total_nodes(channel, mode):
updatable = False
cnr = unified_manager.cnr_map[cnr_id]
if cnr_id in invalid_nodes:
v['invalid-installation'] = True
if cnr_id in unified_manager.active_nodes:
# installed
v['state'] = 'enabled'
@@ -2608,4 +2660,3 @@ async def check_need_to_migrate():
print("The following custom nodes were installed using the old management method and require migration:")
print(", ".join(legacy_custom_nodes))
print("---------------------------------------------------------------------------\n")

View File

@@ -202,8 +202,7 @@ def print_comfyui_version():
print_comfyui_version()
core.check_invalid_nodes()
def setup_environment():
@@ -787,6 +786,12 @@ async def get_disabled_versions(request):
return web.Response(status=400)
@routes.post("/customnode/reinstall")
async def reinstall_custom_node(request):
await uninstall_custom_node(request)
await install_custom_node(request)
@routes.post("/customnode/install")
async def install_custom_node(request):
if not is_allowed_security_level('middle'):