mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2026-02-11 05:32:30 +08:00
revise /customnode/installed
improved: don't fetch data from cnr for the api
improved: change format {<cnr id>: <version>} -> {<module>: [<version>, <cnr id>]}
This commit is contained in:
parent
29ab428979
commit
784d32c8ec
@ -129,3 +129,26 @@ def read_cnr_info(fullpath):
|
||||
return None
|
||||
except Exception:
|
||||
return None # not valid CNR node pack
|
||||
|
||||
|
||||
def generate_cnr_id(fullpath, cnr_id):
|
||||
cnr_id_path = os.path.join(fullpath, '.git', '.cnr-id')
|
||||
try:
|
||||
if not os.path.exists(cnr_id_path):
|
||||
with open(cnr_id_path, "w") as f:
|
||||
return f.write(cnr_id)
|
||||
except:
|
||||
print(f"[ComfyUI Manager] unable to create file: {cnr_id_path}")
|
||||
|
||||
|
||||
def read_cnr_id(fullpath):
|
||||
cnr_id_path = os.path.join(fullpath, '.git', '.cnr-id')
|
||||
try:
|
||||
if not os.path.exists(cnr_id_path):
|
||||
with open(cnr_id_path) as f:
|
||||
return f.read().strip()
|
||||
except:
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ import manager_downloader
|
||||
from node_package import InstalledNodePackage
|
||||
|
||||
|
||||
version_code = [3, 3, 10]
|
||||
version_code = [3, 4]
|
||||
version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
|
||||
|
||||
|
||||
@ -457,6 +457,7 @@ class UnifiedManager:
|
||||
cnr = self.get_cnr_by_repo(url)
|
||||
commit_hash = git_utils.get_commit_hash(fullpath)
|
||||
if cnr:
|
||||
cnr_utils.generate_cnr_id(fullpath, cnr['id'])
|
||||
return {'id': cnr['id'], 'cnr': cnr, 'ver': 'nightly', 'hash': commit_hash}
|
||||
else:
|
||||
url = os.path.basename(url)
|
||||
@ -1318,6 +1319,7 @@ class UnifiedManager:
|
||||
if version_spec == 'unknown':
|
||||
self.unknown_active_nodes[node_id] = to_path
|
||||
elif version_spec == 'nightly':
|
||||
cnr_utils.generate_cnr_id(to_path, node_id)
|
||||
self.active_nodes[node_id] = 'nightly', to_path
|
||||
|
||||
return res.with_target(version_spec)
|
||||
@ -1370,6 +1372,30 @@ class UnifiedManager:
|
||||
unified_manager = UnifiedManager()
|
||||
|
||||
|
||||
def identify_node_pack_from_path(fullpath):
|
||||
module_name = os.path.basename(fullpath)
|
||||
if module_name.endswith('.git'):
|
||||
module_name = module_name[:-4]
|
||||
|
||||
repo_url = git_utils.git_url(fullpath)
|
||||
if repo_url is None:
|
||||
# cnr
|
||||
cnr = cnr_utils.read_cnr_info(fullpath)
|
||||
if cnr is not None:
|
||||
return module_name, cnr['version'], cnr['id']
|
||||
|
||||
return None
|
||||
else:
|
||||
# nightly or unknown
|
||||
cnr_id = cnr_utils.read_cnr_id(fullpath)
|
||||
commit_hash = git_utils.get_commit_hash(fullpath)
|
||||
|
||||
if cnr_id is not None:
|
||||
return module_name, commit_hash, cnr_id
|
||||
else:
|
||||
return module_name, commit_hash, ''
|
||||
|
||||
|
||||
def get_channel_dict():
|
||||
global channel_dict
|
||||
|
||||
|
||||
@ -539,15 +539,21 @@ def populate_markdown(x):
|
||||
|
||||
@routes.get("/customnode/installed")
|
||||
async def installed_list(request):
|
||||
unified_manager = core.unified_manager
|
||||
res = {}
|
||||
|
||||
await unified_manager.reload('cache')
|
||||
await unified_manager.get_custom_nodes('default', 'cache')
|
||||
for x in core.get_custom_nodes_paths():
|
||||
for y in os.listdir(x):
|
||||
if y == '__pycache__' or y.endswith('.disabled'):
|
||||
continue
|
||||
|
||||
return web.json_response({
|
||||
node_id: package.version if package.is_from_cnr else package.get_commit_hash()
|
||||
for node_id, package in unified_manager.installed_node_packages.items() if not package.disabled
|
||||
}, content_type='application/json')
|
||||
fullpath = os.path.join(x, y)
|
||||
info = core.identify_node_pack_from_path(fullpath)
|
||||
if info is None:
|
||||
continue
|
||||
|
||||
res[info[0]] = [info[1], info[2]]
|
||||
|
||||
return web.json_response(res, content_type='application/json')
|
||||
|
||||
|
||||
@routes.get("/customnode/getlist")
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-manager"
|
||||
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
|
||||
version = "3.3.10"
|
||||
version = "3.4"
|
||||
license = { file = "LICENSE.txt" }
|
||||
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user