Nodes/ComfyUI-DMXAPI/DMXAPI 節點自我更新
ComfyUI Node

DMXAPI 節點自我更新

Updating a node pack from the canvas, and why nothing happens twice

By mch000534·Created 2 months ago·Updated 11 days ago· 1
DMXAPI 節點自我更新
    • REPORT
    • UPDATE_AVAILABLE
    • APPLIED
    • LOCAL_SHA
    • REMOTE_SHA
    ◄modecheck_only►
    ◄run_trigger0►
    ◄repo_owner_repomch000534/ComfyUI-DMXAPI►
    ◄branchmain►
    ◄install_requirementstrue►
    ◄force_updatefalse►
    ◄timeout_seconds20►
    ◄max_retries3►

    A node that updates its own pack is a slightly strange thing to find on a canvas, and it exists for a mundane reason: everything in ComfyUI-DMXAPI requires a restart. ComfyUI only scans custom_nodes/ at boot, so every update, every .env edit, every key change means quitting the app. This node is the author's attempt to make the "is there a newer version, and can I get it without a terminal" loop into a button.

    It also doesn't call DMXAPI. Neither this node nor the SetAPIKey one touches the API - they work on GitHub and on a local file.

    What it does

    Two modes, and the default one is the safe one.

    check_only compares your local copy against the main branch on GitHub and reports. That's it - the source is explicit that it writes no files under any circumstances, and that this holds even if you turn on force_update (which is ignored in this mode). Run it first; there's no reason not to.

    apply downloads the current main archive and replaces the package's code. Unlike the pack's standalone no-git install scripts, which overwrite the whole folder, apply preserves your .env and your .git, and any file that exists only on your machine is kept rather than deleted, with a warning logged. Then, unless you turn install_requirements off, it runs pip install -r requirements.txt using sys.executable - the interpreter ComfyUI is actually running on, which is the correct one to use and not always what a node reaches for.

    And then it stops short: you still have to restart ComfyUI. Same reason as always.

    There's a settings-screen version too: category DMXAPI → 自我更新, with a "check for updates" and an "apply update" toggle that spring back to off when the action finishes, plus a confirmation dialog before applying. Identical logic, different door.

    How it works

    Local version is read as git rev-parse HEAD if the folder is a git checkout, then a local marker file, then "unknown". The remote side is GitHub's REST API for the branch head. apply fetches from codeload.github.com first and falls back to github.com/.../archive/...zip - the same two sources the pack's install scripts use.

    The inputs

    • mode - check_only (default) or apply.
    • run_trigger - an integer that means nothing. It's a ComfyUI cache key, and it's the answer to the most common "bug" with this node (below).
    • install_requirements - default on.
    • force_update - apply only. Normally, if the SHAs match, or if GitHub can't be reached for the comparison, the node does nothing. Turn this on and it re-downloads and overwrites regardless. That's your escape hatch when the version check itself is broken.
    • repo_owner_repo, branch - mch000534/ComfyUI-DMXAPI and main. Only touch them if you're testing a fork.
    • timeout_seconds (20) and max_retries (3).

    Five outputs: REPORT (a human-readable string, also shown as a popup on the node), UPDATE_AVAILABLE, APPLIED, LOCAL_SHA and REMOTE_SHA. It's an output node, so it runs on its own without being wired to anything.

    Where people get burned

    "I ran it again and nothing happened." That's ComfyUI's cache. Identical inputs means the node doesn't re-execute - bump run_trigger to a new number every time you want it to actually do something. The tooltip says this plainly; it's still the number one misunderstanding.

    "Remote version: unavailable." GitHub gives an unauthenticated client 60 API requests per hour per IP, and the report tells you whether you hit the limit or simply can't reach GitHub. If you're rate-limited and you know there's a new version, force_update under apply skips the comparison and downloads anyway.

    Updates that don't show up. Restart. Every time. The node's own success message says so.

    One honest caveat. This node downloads code from GitHub and runs pip for you. On a pack whose whole purpose is phoning home with an API key, that's a lot of trust in one button - and this is the category of software that has already shipped malware once, with the ComfyUI_LLMVISION credential stealer. The mitigation here is boring and sufficient: it's a short, readable, MIT-licensed file in a repo you're already installing, and it points at a repo you can inspect. Read it once, then use the button.

    Installing the pack

    You can't have this node without the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mch000534/ComfyUI-DMXAPI
    /path/to/ComfyUI/.venv/bin/python -m pip install -r ComfyUI-DMXAPI/requirements.txt
    

    Or ComfyUI Manager, search DMXAPI. Then restart, search DMXAPI in the node menu, and drop in the self-update node.

    CategoryDMXAPI/Utility

    Inputs (8)

    NameTypeDefaultDescription
    modeCOMBOcheck_onlycheck_only:只比對本機與遠端版本,絕不動任何檔案。apply:下載並套用更新(保留 .env 與 .git),需要重啟 ComfyUI 才會生效。
    run_triggerINT00–18446744073709550000純粹作為 ComfyUI 快取鍵,本身無意義。同一組輸入不會重跑;要強制重新檢查/套用,請改動這個數字。
    repo_owner_repooptSTRINGmch000534/ComfyUI-DMXAPI格式 owner/repo,測試或 fork 情境可覆蓋,一般不需更動。
    branchoptSTRINGmain—
    install_requirementsoptBOOLEANtrueapply 成功後是否對目前這個 ComfyUI 直譯器執行 pip install -r requirements.txt。
    force_updateoptBOOLEANfalse只在 mode="apply" 時有效:本機與遠端版本相同、或連不上 GitHub 比對版本(例如 API 額度用完)時,平常會直接跳過不做任何事;開啟這個選項後即使沒偵測到差異也會強制重新下載並覆蓋套件程式碼(仍會保留 .env 與 .git)。mode="check_only" 時這個選項不生效,絕不會因為它而寫入任何檔案。
    timeout_secondsoptINT205–120—
    max_retriesoptINT30–10—

    Outputs (5)

    NameTypeDescription
    REPORTSTRING—
    UPDATE_AVAILABLEBOOLEAN—
    APPLIEDBOOLEAN—
    LOCAL_SHASTRING—
    REMOTE_SHASTRING—