mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-16 08:22:36 +08:00
Handle missing internal nodes
This commit is contained in:
parent
b3f759d979
commit
f9ff5d9105
@ -541,4 +541,43 @@ describe("group node", () => {
|
||||
})
|
||||
);
|
||||
});
|
||||
test("shows missing node error on missing internal node when loading graph data", async () => {
|
||||
const { graph } = await start();
|
||||
|
||||
const dialogShow = jest.spyOn(graph.app.ui.dialog, "show");
|
||||
await graph.app.loadGraphData({
|
||||
last_node_id: 3,
|
||||
last_link_id: 1,
|
||||
nodes: [
|
||||
{
|
||||
id: 3,
|
||||
type: "workflow/testerror",
|
||||
},
|
||||
],
|
||||
links: [],
|
||||
groups: [],
|
||||
config: {},
|
||||
extra: {
|
||||
groupNodes: {
|
||||
testerror: {
|
||||
nodes: [
|
||||
{
|
||||
type: "NotKSampler",
|
||||
},
|
||||
{
|
||||
type: "NotVAEDecode",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(dialogShow).toBeCalledTimes(1);
|
||||
const call = dialogShow.mock.calls[0][0];
|
||||
expect(call).toContain("the following node types were not found");
|
||||
expect(call).toContain("NotKSampler");
|
||||
expect(call).toContain("NotVAEDecode");
|
||||
expect(call).toContain("workflow/testerror");
|
||||
});
|
||||
});
|
||||
|
||||
@ -6,7 +6,7 @@ export const IS_GROUP_NODE = Symbol();
|
||||
export const GROUP_DATA = Symbol();
|
||||
const GROUP_SLOTS = Symbol();
|
||||
|
||||
export async function registerGroupNodes(groupNodes, source, prefix) {
|
||||
export async function registerGroupNodes(groupNodes, source, prefix, missingNodeTypes) {
|
||||
if (!groupNodes) return;
|
||||
|
||||
let extra = app.graph.extra;
|
||||
@ -15,7 +15,20 @@ export async function registerGroupNodes(groupNodes, source, prefix) {
|
||||
if (!nodes) extra.groupNodes = nodes = {};
|
||||
|
||||
for (const g in groupNodes) {
|
||||
const def = buildNodeDef(groupNodes[g], g, globalDefs, source);
|
||||
const groupData = groupNodes[g];
|
||||
|
||||
let hasMissing = false;
|
||||
for (const n of groupData.nodes) {
|
||||
// Find missing node types
|
||||
if (!(n.type in LiteGraph.registered_node_types)) {
|
||||
missingNodeTypes.push(n.type);
|
||||
hasMissing = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasMissing) continue;
|
||||
|
||||
const def = buildNodeDef(groupData, g, globalDefs, source);
|
||||
if (prefix) {
|
||||
def.display_name = prefix + "/" + def.display_name;
|
||||
}
|
||||
@ -319,8 +332,8 @@ class ConvertToGroupAction {
|
||||
Object.values(app.canvas.selected_nodes).find((n) => n.constructor.nodeData?.[IS_GROUP_NODE]),
|
||||
callback: async () => {
|
||||
const name = this.getName();
|
||||
if(!name) return;
|
||||
|
||||
if (!name) return;
|
||||
|
||||
let extra = app.graph.extra;
|
||||
if (!extra) app.graph.extra = extra = {};
|
||||
let groupNodes = extra.groupNodes;
|
||||
@ -402,8 +415,8 @@ const ext = {
|
||||
};
|
||||
}
|
||||
},
|
||||
async beforeConfigureGraph(graphData) {
|
||||
registerGroupNodes(graphData?.extra?.groupNodes, "workflow");
|
||||
async beforeConfigureGraph(graphData, missingNodeTypes) {
|
||||
registerGroupNodes(graphData?.extra?.groupNodes, "workflow", undefined, missingNodeTypes);
|
||||
},
|
||||
addCustomNodeDefs(defs) {
|
||||
globalDefs = defs;
|
||||
|
||||
@ -1486,8 +1486,8 @@ export class ComfyApp {
|
||||
reset_invalid_values = true;
|
||||
}
|
||||
|
||||
await this.#invokeExtensionsAsync("beforeConfigureGraph", graphData);
|
||||
const missingNodeTypes = [];
|
||||
await this.#invokeExtensionsAsync("beforeConfigureGraph", graphData, missingNodeTypes);
|
||||
for (let n of graphData.nodes) {
|
||||
// Patch T2IAdapterLoader to ControlNetLoader since they are the same node now
|
||||
if (n.type == "T2IAdapterLoader") n.type = "ControlNetLoader";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user