Browse Source

fix: component loading

pull/340/head
dr.lt.data 10 months ago
parent
commit
ae743efd0c
  1. 2
      __init__.py
  2. 11
      js/comfyui-manager.js
  3. 54
      js/components-manager.js

2
__init__.py

@ -28,7 +28,7 @@ except:
print(f"[WARN] ComfyUI-Manager: Your ComfyUI version is outdated. Please update to the latest version.")
version = [2, 2, 1]
version = [2, 2, 2]
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
print(f"### Loading: ComfyUI-Manager ({version_str})")

11
js/comfyui-manager.js vendored

@ -16,7 +16,7 @@ import { AlternativesInstaller } from "./a1111-alter-downloader.js";
import { SnapshotManager } from "./snapshot.js";
import { ModelInstaller } from "./model-downloader.js";
import { manager_instance, setManagerInstance, install_via_git_url, install_pip, rebootAPI, free_models } from "./common.js";
import { ComponentBuilderDialog, load_components, set_component_policy } from "./components-manager.js";
import { ComponentBuilderDialog, load_components, set_component_policy, getPureName } from "./components-manager.js";
var docStyle = document.createElement('style');
docStyle.innerHTML = `
@ -407,6 +407,15 @@ function getNickname(node, nodename) {
if (nicknames[nodename]) {
node.nickname = nicknames[nodename];
}
else if(node.getInnerNodes) {
let pure_name = getPureName(node);
let groupNode = app.graph.extra?.groupNodes?.[pure_name];
if(groupNode) {
let packname = groupNode.packname;
node.nickname = packname;
}
return node.nickname;
}
else {
for(let i in nickname_patterns) {
let item = nickname_patterns[i];

54
js/components-manager.js

@ -7,12 +7,26 @@ import { ComfyDialog, $el } from "../../scripts/ui.js";
let pack_map = {};
let rpack_map = {};
function getPureName(node) {
export function getPureName(node) {
// group nodes/
let category = node.category.substring(12);
let category = null;
if(node.category) {
category = node.category.substring(12);
}
else {
category = node.constructor.category?.substring(12);
}
if(category) {
let purename = node.comfyClass.substring(category.length+1);
return purename;
}
else if(node.comfyClass.startsWith('workflow/')) {
return node.comfyClass.substring(9);
}
else {
return node.comfyClass;
}
}
function isValidVersionString(version) {
const versionPattern = /^(\d+)\.(\d+)(\.(\d+))?$/;
@ -72,6 +86,7 @@ export async function load_components() {
await config.registerType(category);
register_pack_map(name, data);
break;
}
continue;
}
@ -81,8 +96,8 @@ export async function load_components() {
storeGroupNode(name, nodeData);
const config = new GroupNodeConfig(name, nodeData);
while(!success) {
var success = false;
while(true) {
try {
let category = nodeData.packname;
if(nodeData.category) {
@ -94,12 +109,13 @@ export async function load_components() {
await config.registerType(category);
register_pack_map(name, nodeData);
break;
}
catch {
let elapsed_time = Date.now() - start_time;
if (elapsed_time > 5000) {
failed.push(name);
success = true;
break;
} else {
await sleep(100);
}
@ -120,8 +136,7 @@ export async function load_components() {
storeGroupNode(name, nodeData);
const config = new GroupNodeConfig(name, nodeData);
while(!success) {
var success = false;
while(true) {
try {
let category = nodeData.packname;
if(nodeData.workflow.category) {
@ -133,12 +148,13 @@ export async function load_components() {
await config.registerType(category);
register_pack_map(name, nodeData);
break;
}
catch {
let elapsed_time = Date.now() - start_time;
if (elapsed_time > 10000) {
failed2.push(name);
success = true;
break;
} else {
await sleep(100);
}
@ -155,9 +171,7 @@ export async function load_components() {
storeGroupNode(name, nodeData);
const config = new GroupNodeConfig(name, nodeData);
while(!success) {
var success = false;
while(true) {
try {
let category = nodeData.workflow.packname;
if(nodeData.workflow.category) {
@ -169,12 +183,13 @@ export async function load_components() {
await config.registerType(category);
register_pack_map(name, nodeData);
break;
}
catch {
let elapsed_time = Date.now() - start_time;
if (elapsed_time > 30000) {
failed.push(name);
success = true;
break;
} else {
await sleep(100);
}
@ -708,12 +723,11 @@ function getChangedVersion(groupNodes) {
const loadGraphData = app.loadGraphData;
app.loadGraphData = async function () {
const v = await loadGraphData.apply(this, arguments);
if(arguments.length == 0)
return v;
return await loadGraphData.apply(this, arguments);
let groupNodes = arguments[0].extra?.groupNodes;
let graphData = arguments[0];
let groupNodes = graphData.extra?.groupNodes;
let res = getChangedVersion(groupNodes);
if(res) {
@ -734,7 +748,10 @@ app.loadGraphData = async function () {
if(target_components) {
for(let i in target_components) {
let component_name = target_components[i];
restore_to_loaded_component(component_name);
let component = rpack_map[component_name];
if(component && graphData.extra?.groupNodes) {
graphData.extra.groupNodes[component_name] = component;
}
}
}
}
@ -742,7 +759,8 @@ app.loadGraphData = async function () {
console.log('Empty components: policy ignored');
}
return v;
arguments[0] = graphData;
return await loadGraphData.apply(this, arguments);
};
export function set_component_policy(v) {

Loading…
Cancel
Save