Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ Align the columns to match the surrounding rows (use spaces to pad to the same c

---

## Patching an extension

When an extension needs a local fix that isn't upstream yet, don't fork it — add a patch under `patches/<slug>/` instead. See `patches/README.md` for the format. It's applied automatically by `patch_extension` (called from `install_extension` in `entrypoint.sh`) on every install/update, so no wiring is needed elsewhere.

```sh
git diff > patches/<slug>/001-short-description.patch
```

---

### Checklist

- [ ] `extensions.sh` — `install_extension` line added in alphabetical order
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

All notable changes to this project will be documented in this file.

## 0.33.0 - 2026-08-25

### <!-- 0 -->🚀 Features

* **comfy**: Bump to v0.33.1
* <https://github.com/Comfy-Org/ComfyUI/releases/tag/v0.33.1>
* **core**: Add a patch support for extensions (#37)
* Introduces a new feature that allows users to [apply patches to extensions](patches/README.md) in the ComfyUI project. The patch support enables users to modify and enhance the functionality of extensions without directly altering the original source code.
* Thanks @algonixdev for the patch support implementation.
* **deps**: Bump pytorch to 2.13.0

## 0.32.0 - 2026-08-05

### <!-- 0 -->🚀 Features
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ RUN set -ex \
"app/models" \
"app/output" \
"app/user" \
"patches" \
&& chown -R comfyui:comfyui .

COPY --chown=comfyui --chmod=0755 ./entrypoint.sh .
COPY --chown=comfyui --chmod=0644 ./extensions.sh .
COPY --chown=comfyui --chmod=0755 ./patches ./patches

EXPOSE 8188
ENTRYPOINT ["/opt/comfyui/entrypoint.sh"]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Contents:
* [New Manager](https://blog.comfy.org/p/meet-the-new-comfyui-manager) enabled by default.
* Do not run as root, UID/GID are configurables.
* A set of [pre-installed extensions](#pre-installed-extensions).
* Custom patch extensions support (see [`patches/README.md`](patches/README.md)).

> [!WARNING]
> This project does not provide models, you must download those manually and put them in `./data/models`.
Expand Down
60 changes: 52 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@

set -eu

# Important locations
COMFYUI_HOME="${COMFYUI_HOME:-/opt/comfyui}"
COMFYUI_CUSTOM_NODES_DIR="${COMFYUI_HOME}/app/custom_nodes"
COMFYUI_MODELS_DIR="${COMFYUI_HOME}/app/models"
COMFYUI_PATCHES_DIR="${COMFYUI_HOME}/patches"
COMFYUI_PROFILE_DIR="${COMFYUI_HOME}/app/user"

# Run as
PUID=${PUID:-1000}
PGID=${PGID:-1000}

# Uv settings
export UV_CACHE_DIR="${COMFYUI_HOME}/python/cache"
export UV_HTTP_TIMEOUT="60"
export VIRTUAL_ENV="${COMFYUI_HOME}/python/venv"
Expand All @@ -27,25 +35,62 @@ function install_extension() {
local name="$1"; shift
local url="$1"; shift

if [[ ! -d "${COMFYUI_HOME}/app/custom_nodes/${name}" ]]
if [[ ! -d "${COMFYUI_CUSTOM_NODES_DIR}/${name}" ]]
then
log "Installing ${name}..."
git clone "${url}" "${COMFYUI_HOME}/app/custom_nodes/${name}" --recurse-submodules
git clone "${url}" "${COMFYUI_CUSTOM_NODES_DIR}/${name}" --recurse-submodules
else
log "Updating ${name}..."
(cd "${COMFYUI_HOME}/app/custom_nodes/${name}" \
(cd "${COMFYUI_CUSTOM_NODES_DIR}/${name}" \
&& git fetch --prune --prune-tags --recurse-submodules \
&& git reset --hard --recurse-submodules "@{upstream}")
fi

# Re-applied patches since a fresh clone or hard reset
# always lands on unpatched upstream code.
patch_extension "${name}"
}

# Apply local patches on top of an extension, if any exist.
# See patches/README.md for more information.
function patch_extension() {
local name="$1"; shift
local patch_dir="${COMFYUI_PATCHES_DIR}/${name}"
local ext_dir="${COMFYUI_CUSTOM_NODES_DIR}/${name}"

if [[ ! -d "${patch_dir}" ]]; then
return 0
fi

if [[ ! -d "${ext_dir}" ]]
then
log "Cannot patch ${name}: extension is not installed"
return 1
fi

local patch_file
for patch_file in "${patch_dir}"/*.patch
do
[[ -e "${patch_file}" ]] || continue

if (cd "${ext_dir}" && git apply --check --reverse "${patch_file}" 2>/dev/null)
then
log "Patch $(basename "${patch_file}") already applied to ${name}, skipping..."
continue
fi

log "Applying patch $(basename "${patch_file}") to ${name}..."
(cd "${ext_dir}" && git apply "${patch_file}")
done
}

function remove_extension() {
local name="$1"; shift

if [[ -d "${COMFYUI_HOME}/app/custom_nodes/${name}" ]]
if [[ -d "${COMFYUI_CUSTOM_NODES_DIR}/${name}" ]]
then
log "Removing extension ${name}..."
rm -rf "${COMFYUI_HOME}/app/custom_nodes/${name}"
rm -rf "${COMFYUI_CUSTOM_NODES_DIR:?}/${name}"
fi
}

Expand Down Expand Up @@ -89,7 +134,7 @@ function setup_dirs() {

for model_dir in "${model_dirs[@]}"
do
local model_path="${COMFYUI_HOME}/app/models/${model_dir}"
local model_path="${COMFYUI_MODELS_DIR}/${model_dir}"
if [ ! -d "${model_path}" ]
then
log "Creating directory \"${model_path}\"..."
Expand Down Expand Up @@ -122,8 +167,7 @@ function fix_perms() {

function init_manager() {
# Init the manager config
local profile_dir="${COMFYUI_HOME}/app/user"
local manager_profile_dir="${profile_dir}/__manager"
local manager_profile_dir="${COMFYUI_PROFILE_DIR}/__manager"
local manager_config_file="${manager_profile_dir}/config.ini"

if [ ! -e "${manager_profile_dir}" ]
Expand Down
6 changes: 3 additions & 3 deletions metadata.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
COMFYUI_VERSION=0.30.0
UV_VERSION=0.11.23
COMFYUI_VERSION=0.33.1
UV_VERSION=0.12.5
COMFYTURE_IMAGE=bigbrozer/comfyture
COMFYTURE_VERSION=0.32.0
COMFYTURE_VERSION=0.33.0
44 changes: 44 additions & 0 deletions patches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Extension patches

Some extensions occasionally need a small local fix that isn't merged
upstream yet (a bug fix, a compatibility tweak, ...). Rather than forking the
extension, drop a patch here and it will be applied automatically every time
the extension is installed or updated (see `patch_extension` in
`entrypoint.sh`).

## Layout

```plain
patches/
└── <slug>/
├── 001-short-description.patch
└── 002-another-fix.patch
```

- `<slug>` must match the extension's `install_extension` slug in
`extensions.sh`.
- Patch files are applied in lexical order, hence the numeric prefix.
- An extension with no `patches/<slug>/` directory is left untouched.

See `_example/001-fix-deprecated-numpy-alias.patch` for a worked example
(fixing a `np.float` deprecated-alias crash in a fictitious node) — copy its
layout, renaming `_example` to the real extension's slug. `_example` itself
is never applied to anything: no extension is named `_example` in
`extensions.sh`.

## Creating a patch

Clone an extension's repo somewhere (e.g. `/tmp/comfyture/<slug>`). From inside the repo, make your fix, then:

```sh
git diff > ./patches/<slug>/001-short-description.patch
```

## Notes

- `install_extension` always leaves the extension at a clean upstream state
(fresh clone, or `git reset --hard` on update), so patches are re-applied
on every container start — no manual reapplication needed.
- If a patch fails to apply (e.g. upstream changed the patched lines), the
container will fail to start with a `git apply` error; refresh the patch
against the new upstream code.
11 changes: 11 additions & 0 deletions patches/_example/001-fix-deprecated-numpy-alias.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
diff --git a/nodes.py b/nodes.py
index 543ed3f..e07a297 100644
--- a/nodes.py
+++ b/nodes.py
@@ -7,5 +7,5 @@ class ExampleUpscaleNode:

def process(self, image, scale):
array = image.cpu().numpy()
- array = array.astype(np.float)
+ array = array.astype(np.float32)
return (torch.from_numpy(array * scale),)
13 changes: 13 additions & 0 deletions patches/comfyui-ollama/001-fix-context-keyerror.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CompfyuiOllama.py b/CompfyuiOllama.py
index baa8025..ac4a2d5 100644
--- a/CompfyuiOllama.py
+++ b/CompfyuiOllama.py
@@ -385,7 +385,7 @@ format: {format}
if debug_print:
print("saving context to node memory.")

- return ollama_response_text, ollama_response_thinking, response['context'], meta,
+ return ollama_response_text, ollama_response_thinking, response.get('context', []), meta,


class OllamaChat:
Loading
Loading