Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Workers: node packs load whatever the case of their folder name

Adarshe900b1d1cb62
diff --git a/bin/lib/worker/inventory.mjs b/bin/lib/worker/inventory.mjs
index 1aec2afc..9c5a52d5 100644
--- a/bin/lib/worker/inventory.mjs
+++ b/bin/lib/worker/inventory.mjs
@@ -17,8 +17,11 @@ function sha256File(file) {
});
}
-/** The pack folders in ComfyUI's custom_nodes, named as the catalog names them, with their git commit. */
-export function nodePacks(comfyDir, index) {
+/**
+ * The pack folders in ComfyUI's custom_nodes that the catalog knows, matched whatever their case: { name (as the
+ * catalog names it), folder (as it is on disk, which is what ComfyUI's --whitelist-custom-nodes compares), commit }.
+ */
+export function packFolders(comfyDir, index) {
const dir = path.join(comfyDir ?? "", "custom_nodes");
if (!comfyDir || !fs.existsSync(dir)) return [];
const known = new Map();
@@ -32,11 +35,14 @@ export function nodePacks(comfyDir, index) {
if (!e.isDirectory() || e.name.startsWith(".") || e.name === "__pycache__") continue;
const name = known.get(e.name.toLowerCase());
if (!name) continue;
- out.push({ name, commit: gitCommit(path.join(dir, e.name)) });
+ out.push({ name, folder: e.name, commit: gitCommit(path.join(dir, e.name)) });
}
return out;
}
+/** The node packs as the studio sees them: the catalog's name and the commit. */
+export const nodePacks = (comfyDir, index) => packFolders(comfyDir, index).map(({ name, commit }) => ({ name, commit }));
+
function gitCommit(dir) {
try {
const head = fs.readFileSync(path.join(dir, ".git", "HEAD"), "utf8").trim();
diff --git a/bin/lib/worker/run.mjs b/bin/lib/worker/run.mjs
index 0858314e..45d33b4f 100644
--- a/bin/lib/worker/run.mjs
+++ b/bin/lib/worker/run.mjs
@@ -9,7 +9,7 @@ import { cleanJob, emptyFolders, allowedNodes, vetGraph } from "./checks.mjs";
import { folders, OwnComfy, PortBusy } from "./comfy.mjs";
import { PROTOCOL, readControl, writeControl, writeStatus } from "./config.mjs";
import { GpuWatch, othersOf, readGpu } from "./gpu.mjs";
-import { inventoryHash, modelFiles, nodePacks } from "./inventory.mjs";
+import { inventoryHash, modelFiles, packFolders } from "./inventory.mjs";
const here = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.resolve(here, "../../..");
@@ -60,6 +60,7 @@ export async function runWorker(cfg, deps) {
let troubleAt = 0;
let answer = null;
let inv = { files: [], nodePacks: [] };
+ let packs = [];
let invHash = null;
let gpuInfo = { otherApps: [], tempC: null };
let lastGpuAt = 0;
@@ -70,7 +71,8 @@ export async function runWorker(cfg, deps) {
const api = (p, init = {}) => fetchFn(`${site}${p}`, { ...init, headers: { ...(init.headers ?? {}), Authorization: `Bearer ${cfg.token}`, "User-Agent": `FuobeWorker/${VERSION}` } });
async function scan() {
- inv = { files: await modelFiles(cfg.modelDirs ?? [], index, path.join(cfg.workDir, "hash-cache.json")), nodePacks: nodePacks(cfg.comfyDir, index) };
+ packs = packFolders(cfg.comfyDir, index);
+ inv = { files: await modelFiles(cfg.modelDirs ?? [], index, path.join(cfg.workDir, "hash-cache.json")), nodePacks: packs.map(({ name, commit }) => ({ name, commit })) };
invHash = inventoryHash(inv);
}
await scan();
@@ -176,7 +178,8 @@ export async function runWorker(cfg, deps) {
} else {
try {
log("Starting its own ComfyUI.");
- await comfy.start(inv.nodePacks.map((p) => p.name));
+ // The packs by their folder names on disk, which is what ComfyUI matches (whatever the catalog's case).
+ await comfy.start(packs.map((p) => p.folder));
} catch (e) {
if (e instanceof PortBusy) {
comfyTrouble = "port-busy";
diff --git a/docs/gpu-workers.md b/docs/gpu-workers.md
index 4832da14..aaab9cfe 100644
--- a/docs/gpu-workers.md
+++ b/docs/gpu-workers.md
@@ -71,6 +71,7 @@ The worker always starts and stops its own ComfyUI process. It never uses a Comf
- gets the model folders through `extra_model_paths.yaml`;
- starts with `--disable-metadata` and `--disable-auto-launch`;
- loads only the custom node packs that the worker found (`--disable-all-custom-nodes --whitelist-custom-nodes …`).
+ The worker finds a pack whatever the case of its folder name, and gives ComfyUI the folder name as it is on disk.
**The port guard.** Before each start, the worker binds the port itself and releases it at once. If the bind fails,
another program is using the port. The worker then does not start ComfyUI, pauses itself (its state says "port-busy")
diff --git a/tests/worker-environment.test.ts b/tests/worker-environment.test.ts
index ed986da5..3418a65a 100644
--- a/tests/worker-environment.test.ts
+++ b/tests/worker-environment.test.ts
@@ -1,6 +1,32 @@
+import fs from "node:fs";
+import path from "node:path";
import { describe, expect, it } from "vitest";
+import { comfyArgs } from "../bin/lib/worker/comfy.mjs";
+import { nodePacks, packFolders } from "../bin/lib/worker/inventory.mjs";
import { minVramBytesFor, needsOf, VRAM_TOLERANCE } from "@/lib/lanes";
import type { RequirementIndex } from "@/lib/gpu/types";
+import { tempDir } from "./helpers/temp-dir";
+
+describe("the worker's node packs", () => {
+ it("are found whatever the case of their folder, and ComfyUI gets the folder's own name", () => {
+ const comfyDir = tempDir("fuobe-worker-packs-");
+ const nodes = path.join(comfyDir, "custom_nodes");
+ for (const d of ["comfyui-rmbg", "ComfyUI-QwenASR", "comfyui-videohelpersuite", "something-else"]) fs.mkdirSync(path.join(nodes, d), { recursive: true });
+ fs.mkdirSync(path.join(nodes, "comfyui-rmbg", ".git"));
+ fs.writeFileSync(path.join(nodes, "comfyui-rmbg", ".git", "HEAD"), `${"a".repeat(40)}\n`);
+ const index = { packs: { "ComfyUI-RMBG": { repo: "https://github.com/x/ComfyUI-RMBG.git" }, "ComfyUI-QwenASR": {}, "ComfyUI-VideoHelperSuite": { repo: "https://github.com/y/ComfyUI-VideoHelperSuite" } } };
+ const found = packFolders(comfyDir, index).sort((a, b) => a.name.localeCompare(b.name));
+ expect(found).toEqual([
+ { name: "ComfyUI-QwenASR", folder: "ComfyUI-QwenASR", commit: null },
+ { name: "ComfyUI-RMBG", folder: "comfyui-rmbg", commit: "a".repeat(40) },
+ { name: "ComfyUI-VideoHelperSuite", folder: "comfyui-videohelpersuite", commit: null },
+ ]);
+ // The studio sees the catalog's names; ComfyUI's whitelist gets the folders.
+ expect(nodePacks(comfyDir, index).map((p) => p.name).sort()).toEqual(["ComfyUI-QwenASR", "ComfyUI-RMBG", "ComfyUI-VideoHelperSuite"]);
+ const args = comfyArgs({ port: 8190, workDir: "/w" }, found.map((p) => p.folder));
+ expect(args.slice(args.indexOf("--whitelist-custom-nodes") + 1)).toEqual(["ComfyUI-QwenASR", "comfyui-rmbg", "comfyui-videohelpersuite"]);
+ });
+});
describe("VRAM: a card takes the lanes made for its size", () => {
const index = {