mirror of
https://git.datalinker.icu/ltdrdata/ComfyUI-Manager
synced 2025-12-10 06:34:24 +08:00
modified: node-in-workflow -> deps-in-workflow
add install/disable/not-install state to result .json file.
This commit is contained in:
parent
d44b11c280
commit
b1ce6c800d
40
cm-cli.py
40
cm-cli.py
@ -27,7 +27,7 @@ if not (len(sys.argv) == 2 and sys.argv[1] in ['save-snapshot', 'restore-depende
|
||||
f" restore-snapshot <snapshot .json/.yaml>\n"
|
||||
f" cli-only-mode [enable|disable]\n"
|
||||
f" restore-dependencies\n"
|
||||
f" node-in-workflow <workflow .json/.png> <output name>\n"
|
||||
f" deps-in-workflow --workflow <workflow .json/.png> --output <output name>\n"
|
||||
f" clear\n")
|
||||
exit(-1)
|
||||
|
||||
@ -499,11 +499,39 @@ def save_snapshot():
|
||||
return core.save_snapshot_with_postfix('snapshot', output_path)
|
||||
|
||||
|
||||
def node_in_workflow(input_path, output_path):
|
||||
def deps_in_workflow():
|
||||
input_path = None
|
||||
output_path = None
|
||||
|
||||
for i in range(len(sys.argv)):
|
||||
if sys.argv[i] == '--workflow' and len(sys.argv) > i and not sys.argv[i+1].startswith('-'):
|
||||
input_path = sys.argv[i+1]
|
||||
|
||||
elif sys.argv[i] == '--output' and len(sys.argv) > i and not sys.argv[i+1].startswith('-'):
|
||||
output_path = sys.argv[i+1]
|
||||
|
||||
if input_path is None:
|
||||
print(f"missing arguments: --workflow <path>")
|
||||
exit(-1)
|
||||
elif not os.path.exists(input_path):
|
||||
print(f"File not founed: {input_path}")
|
||||
exit(-1)
|
||||
|
||||
|
||||
if output_path is None:
|
||||
print(f"missing arguments: --output <path>")
|
||||
exit(-1)
|
||||
|
||||
print(f"{input_path}, {output_path}")
|
||||
|
||||
used_exts, unknown_nodes = asyncio.run(core.extract_nodes_from_workflow(input_path))
|
||||
|
||||
custom_nodes = {}
|
||||
for x in used_exts:
|
||||
custom_nodes[x] = core.simple_check_custom_node(x)
|
||||
|
||||
res = {
|
||||
'custom_nodes': list(used_exts),
|
||||
'custom_nodes': custom_nodes,
|
||||
'unknown_nodes': list(unknown_nodes)
|
||||
}
|
||||
|
||||
@ -592,12 +620,12 @@ elif op == 'cli-only-mode':
|
||||
else:
|
||||
print(f"\ninvalid value for cli-only-mode: {sys.argv[2]}\n")
|
||||
|
||||
elif op == "nodes-in-workflow":
|
||||
elif op == "deps-in-workflow":
|
||||
if len(sys.argv) < 4:
|
||||
print(f"missing arguments: python cm-cli.py <workflow file> <output path>")
|
||||
print(f"missing arguments: python cm-cli.py --workflow <workflow file> --output <output path>")
|
||||
exit(-1)
|
||||
|
||||
node_in_workflow(sys.argv[2], sys.argv[3])
|
||||
deps_in_workflow()
|
||||
|
||||
elif op == 'save-snapshot':
|
||||
path = save_snapshot()
|
||||
|
||||
@ -854,6 +854,7 @@ def update_path(repo_path, instant_execution=False):
|
||||
else:
|
||||
return "skipped"
|
||||
|
||||
|
||||
def lookup_customnode_by_url(data, target):
|
||||
for x in data['custom_nodes']:
|
||||
if target in x['files']:
|
||||
@ -868,6 +869,17 @@ def lookup_customnode_by_url(data, target):
|
||||
return None
|
||||
|
||||
|
||||
def simple_check_custom_node(url):
|
||||
dir_name = os.path.splitext(os.path.basename(url))[0].replace(".git", "")
|
||||
dir_path = os.path.join(custom_nodes_path, dir_name)
|
||||
if os.path.exists(dir_path):
|
||||
return 'installed'
|
||||
elif os.path.exists(dir_path+'.disabled'):
|
||||
return 'disabled'
|
||||
|
||||
return 'not-installed'
|
||||
|
||||
|
||||
def check_a_custom_node_installed(item, do_fetch=False, do_update_check=True, do_update=False):
|
||||
item['installed'] = 'None'
|
||||
|
||||
@ -1009,7 +1021,7 @@ def save_snapshot_with_postfix(postfix, path=None):
|
||||
return path
|
||||
|
||||
|
||||
async def extract_nodes_from_workflow(filepath):
|
||||
async def extract_nodes_from_workflow(filepath, mode='local', channel_url='default'):
|
||||
# prepare json data
|
||||
workflow = None
|
||||
if filepath.endswith('.json'):
|
||||
@ -1060,7 +1072,7 @@ async def extract_nodes_from_workflow(filepath):
|
||||
extract_nodes(x)
|
||||
|
||||
# lookup dependent custom nodes
|
||||
ext_map = await get_data_by_mode('local', 'extension-node-map.json')
|
||||
ext_map = await get_data_by_mode(mode, 'extension-node-map.json', channel_url)
|
||||
|
||||
rext_map = {}
|
||||
preemption_map = {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user