From 2528135dbeebc62ba34eefab1d19a55fdf57f571 Mon Sep 17 00:00:00 2001 From: Sammy Franklin Date: Fri, 27 Oct 2023 16:51:24 -0700 Subject: [PATCH] janitorial things --- comfy_extras/nodes_subflow.py | 30 ++------------- folder_paths.py | 15 -------- web/extensions/core/subflow.js | 2 - web/lib/litegraph.core.js | 69 ---------------------------------- web/scripts/widgets.js | 2 - 5 files changed, 3 insertions(+), 115 deletions(-) diff --git a/comfy_extras/nodes_subflow.py b/comfy_extras/nodes_subflow.py index 37787f309..194738cc6 100644 --- a/comfy_extras/nodes_subflow.py +++ b/comfy_extras/nodes_subflow.py @@ -1,40 +1,16 @@ -import folder_paths - -class LoadSubflow: +class FileSubflow: @classmethod def INPUT_TYPES(s): - return {"required": { "subflow_name": (folder_paths.get_filename_list("subflows"), ), }} + return {} RETURN_TYPES = () FUNCTION = "" CATEGORY = "loaders" - -class FileSubflow: - @classmethod - def INPUT_TYPES(s): - return {"required": { "subflow_name": (folder_paths.get_filename_list("subflows"), )} } - RETURN_TYPES = () - FUNCTION = "" - - CATEGORY = "utils" - -class InMemorySubflow: - @classmethod - def INPUT_TYPES(s): - return {"required": {} } - RETURN_TYPES = () - FUNCTION = "" - - CATEGORY = "" NODE_CLASS_MAPPINGS = { - "LoadSubflow": LoadSubflow, "FileSubflow": FileSubflow, - "InMemorySubflow": InMemorySubflow } NODE_DISPLAY_NAME_MAPPINGS = { - "Subflow": "Load Subflow", - "FileSubflow": "File Subflow", - "InMemorySubflow": "In Memory Subflow" + "FileSubflow": "Load Subflow", } diff --git a/folder_paths.py b/folder_paths.py index bc9d6ae22..64964bd87 100644 --- a/folder_paths.py +++ b/folder_paths.py @@ -2,7 +2,6 @@ import os import time supported_pt_extensions = set(['.ckpt', '.pt', '.bin', '.pth', '.safetensors']) -supported_subflow_extensions = set(['.json', '.png']) folder_names_and_paths = {} @@ -30,22 +29,17 @@ folder_names_and_paths["custom_nodes"] = ([os.path.join(base_path, "custom_nodes folder_names_and_paths["hypernetworks"] = ([os.path.join(models_dir, "hypernetworks")], supported_pt_extensions) -folder_names_and_paths["subflows"] = ([os.path.join(base_path, "subflows")], supported_subflow_extensions) folder_names_and_paths["classifiers"] = ([os.path.join(models_dir, "classifiers")], {""}) output_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "output") temp_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "temp") input_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "input") -subflows_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "subflows") filename_list_cache = {} if not os.path.exists(input_directory): os.makedirs(input_directory) -if not os.path.exists(subflows_directory): - os.makedirs(subflows_directory) - def set_output_directory(output_dir): global output_directory output_directory = output_dir @@ -70,10 +64,6 @@ def get_input_directory(): global input_directory return input_directory -def get_subflows_directory(): - global subflows_directory - return subflows_directory - #NOTE: used in http server so don't put folders that should not be accessed remotely def get_directory_by_type(type_name): if type_name == "output": @@ -82,8 +72,6 @@ def get_directory_by_type(type_name): return get_temp_directory() if type_name == "input": return get_input_directory() - if type_name == "subflows": - return get_subflows_directory() return None @@ -99,9 +87,6 @@ def annotated_filepath(name): elif name.endswith("[temp]"): base_dir = get_temp_directory() name = name[:-7] - elif name.endswith("[subflows]"): - base_dir = get_subflows_directory() - name = name[:-11] else: return name, None diff --git a/web/extensions/core/subflow.js b/web/extensions/core/subflow.js index 2d1616e0f..a4b2c33eb 100644 --- a/web/extensions/core/subflow.js +++ b/web/extensions/core/subflow.js @@ -120,8 +120,6 @@ app.registerExtension({ if (nodeData.name == "FileSubflow") { nodeType.prototype.onConfigure = function() { refreshWidgets(this, this.subflow, true); }; nodeType.prototype.refreshNode = function(subflow, filename) { refreshNode(this, subflow, filename); }; - nodeType.prototype.getExportedOutput = function(slot) { return this.subflow.extras.outputSlots[slot]; } - nodeType.prototype.getExportedInput = function(slot) { return this.subflow.extras.inputSlots[slot]; } nodeData.input.required = { subflow: ["SUBFLOWUPLOAD"] }; } diff --git a/web/lib/litegraph.core.js b/web/lib/litegraph.core.js index 5e9169692..a56bf4db9 100644 --- a/web/lib/litegraph.core.js +++ b/web/lib/litegraph.core.js @@ -12953,7 +12953,6 @@ LGraphNode.prototype.executeAction = function(action) }; LGraphCanvas.onMenuNodeExport = function(value, options, e, menu, node) { - console.log(node); if (!node) { throw "no node passed"; } @@ -13057,63 +13056,6 @@ LGraphNode.prototype.executeAction = function(action) return false; }; - // LGraphCanvas.onDecoupleSubflow = function(value, options, e, menu, node) { - // const { subflow } = node; - // if (!subflow) return; - - // const subgraph = new LGraph( subflow ); - - // for (const node of subgraph._nodes) { - // console.log(node); - // graph.add(node); - // } - // }; - - LGraphCanvas.onCollapseToSubflow = function(value, options, e, menu, node) { - const calculatePosition = (nodes) => { - const sum = [0, 0]; - const N = nodes.length; - for (const node of nodes) { - sum[0] += node.pos[0]; - sum[1] += node.pos[1]; - } - return [Math.round(sum[0])/N, Math.round(sum[1]/N)]; - }; - - var graphcanvas = LGraphCanvas.active_canvas; - if (graphcanvas.selected_nodes && Object.keys(graphcanvas.selected_nodes).length > 1){ - const nodes = Object.values(graphcanvas.selected_nodes); - - - // New subflow is the current graph - non included nodes - const subgraph = new LGraph(graph.serialize()); - const subgraphNodes = subgraph._nodes.map(n => n.id); - const nodesToKeep = nodes.map(n => n.id); - - for (const n of subgraphNodes) { - if(!nodesToKeep.includes(n)) { - subgraph.remove(subgraph.getNodeById(n)); - } - } - const subflow = subgraph.serialize(); - const subflowNode = LiteGraph.createNode("InMemorySubflow"); - subflowNode.updateSubflowPrompt(subflow); - subflowNode.pos = calculatePosition(subflow.nodes); - subflowNode.size[0] = 180; - subflowNode.refreshNode(subflow); - graph.add(subflowNode); - - // remove selected nodes - for (const node of nodes) { - graph.remove(node); - } - } - - console.log(graph._nodes); - - return false; - }; - LGraphCanvas.onMenuNodeRemove = function(value, options, e, menu, node) { if (!node) { throw "no node passed"; @@ -13373,19 +13315,8 @@ LGraphNode.prototype.executeAction = function(action) has_submenu: true, callback: LGraphCanvas.onNodeAlign, }); - options.push({ - content: "Collapse to Subflow", - callback: LGraphCanvas.onCollapseToSubflow - }); } - // if (Object.keys(this.selected_nodes).length == 1 && node.subflow) { - // options.push({ - // content: "Decouple Subflow", - // callback: LGraphCanvas.onDecoupleSubflow, - // }); - // } - options.push(null, { content: "Remove", disabled: !(node.removable !== false && !node.block_delete ), diff --git a/web/scripts/widgets.js b/web/scripts/widgets.js index 8f4d5d250..9d999f8ac 100644 --- a/web/scripts/widgets.js +++ b/web/scripts/widgets.js @@ -573,7 +573,6 @@ export const ComfyWidgets = { uploadWidget = node.addWidget("button", "choose file with subflow", "subflow", () => { fileInput.click(); }); - console.log(node.widgets); uploadWidget.serialize = false; // Add handler to check if an image is being dragged over our node @@ -588,7 +587,6 @@ export const ComfyWidgets = { // On drop upload files node.onDragDrop = function (e) { - console.log("onDragDrop called"); let handled = false; for (const file of e.dataTransfer.files) { if (file.type === "image/png" || file.type === "application/json") {