Skip to content

Commit b14068f

Browse files
feat: multiple output images; replace http polling with websocket to check when a workflow is done (#118)
* feat: move stuff around * feat: removed polling; added websocket; allow multiple output images; * ci: enable dry-run for semantic release; removed unused python setup * ci: updated to python 3.11 * docs: updated conventions to reflect the current state of the repo * fix: moved code back into stage 1 * chore: rename "tests_deactivated.json" to "tests.json" * ci: temporarly allow "feat/refactor" to trigger semantic-release * chore(release): 4.1.0 # [4.1.0](4.0.1...4.1.0) (2025-05-02) ### Bug Fixes * moved code back into stage 1 ([d9ed145](d9ed145)) ### Features * move stuff around ([2b2bc12](2b2bc12)) * removed polling; added websocket; allow multiple output images; ([79a560f](79a560f)) * ci: properly enable dry-run * feat: don't return "refresh_worker" in output; remove log spamming in check_server * refactor: download the models separately * feat: refactor the whole docs to make them more clear; replaced "snapshot" with a simplified, custom docker image BREAKING CHANGE * fix: use proper ending for "if" BREAKING CHANGE: api output is not compatible anymore * docs: added all possible comfyui folders; simplified guide of method 1 * fix(model): flux.1-schnell is gated * feat: update to 0.3.30 * test: don't run "snapshot_restoration" tests * chore: force local images * docs: lowercase for code comments * ci: run release for changes in "main" * fix: workflow trigger * ci: build only base for now --------- Co-authored-by: semantic-release-bot <[email protected]>
1 parent 88b5f4a commit b14068f

27 files changed

+1588
-923
lines changed

.github/workflows/dev.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ jobs:
1313
- name: Checkout
1414
uses: actions/checkout@v3
1515

16-
- name: Set up Python
17-
uses: useblacksmith/setup-python@v6
18-
with:
19-
python-version: "3.10"
20-
21-
- name: Install dependencies
22-
run: pip install -r requirements.txt
23-
2416
- name: Clear space to remove unused folders
2517
run: |
2618
rm -rf /usr/share/dotnet

.github/workflows/release.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Release
1+
name: release
22

33
on:
44
workflow_dispatch:
5-
# push:
6-
# branches:
7-
# - "main"
5+
push:
6+
branches:
7+
- "main"
88

99
jobs:
1010
release:
@@ -21,14 +21,6 @@ jobs:
2121
with:
2222
persist-credentials: false
2323

24-
- name: Set up Python
25-
uses: useblacksmith/setup-python@v6
26-
with:
27-
python-version: "3.10"
28-
29-
- name: Install dependencies
30-
run: pip install -r requirements.txt
31-
3224
- name: Clear space to remove unused folders
3325
run: |
3426
rm -rf /usr/share/dotnet
@@ -55,6 +47,7 @@ jobs:
5547
uses: codfish/semantic-release-action@v3
5648
id: semanticrelease
5749
with:
50+
dry-run: true
5851
additional-packages: |
5952
['@semantic-release/git', '@semantic-release/changelog', '@semantic-release/exec']
6053
env:

.github/workflows/test.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,10 @@ jobs:
1919
- name: Set up Python
2020
uses: useblacksmith/setup-python@v6
2121
with:
22-
python-version: "3.10"
22+
python-version: "3.11"
2323

2424
- name: Install dependencies
2525
run: pip install -r requirements.txt
2626

2727
- name: Run Python tests
2828
run: python -m unittest discover
29-
30-
- name: Run snapshot restoration tests
31-
run: |
32-
chmod +x tests/test_restore_snapshot.sh
33-
./tests/test_restore_snapshot.sh

.releaserc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"branches": [
3-
"main"
3+
"main",
4+
"feat/refactor"
45
],
56
"tagFormat": "${version}",
67
"plugins": [

.runpod/hub.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,6 @@
1919
"description": "When enabled, the worker will stop after each finished job to have a clean state",
2020
"default": false
2121
}
22-
},
23-
{
24-
"key": "COMFY_POLLING_INTERVAL_MS",
25-
"input": {
26-
"name": "Polling Interval (ms)",
27-
"type": "number",
28-
"description": "Time to wait between poll attempts in milliseconds",
29-
"default": 250
30-
}
31-
},
32-
{
33-
"key": "COMFY_POLLING_MAX_RETRIES",
34-
"input": {
35-
"name": "Max Polling Retries",
36-
"type": "number",
37-
"description": "Maximum number of poll attempts. Increase for longer workflows",
38-
"default": 500
39-
}
4022
}
4123
]
4224
}

.runpod/tests.json

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,11 @@
7373
{
7474
"key": "REFRESH_WORKER",
7575
"value": "false"
76-
},
77-
{
78-
"key": "COMFY_POLLING_INTERVAL_MS",
79-
"value": "250"
80-
},
81-
{
82-
"key": "COMFY_POLLING_MAX_RETRIES",
83-
"value": "500"
8476
}
8577
],
8678
"allowedCudaVersions": [
8779
"12.7",
88-
"12.6",
89-
"12.5",
90-
"12.4",
91-
"12.3",
92-
"12.2",
93-
"12.1"
80+
"12.6"
9481
]
9582
}
9683
}

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# [4.1.0](https://github.com/runpod-workers/worker-comfyui/compare/4.0.1...4.1.0) (2025-05-02)
2+
3+
4+
### Bug Fixes
5+
6+
* moved code back into stage 1 ([d9ed145](https://github.com/runpod-workers/worker-comfyui/commit/d9ed14571308ad27481ae2dda4762d32b73b5d20))
7+
8+
9+
### Features
10+
11+
* move stuff around ([2b2bc12](https://github.com/runpod-workers/worker-comfyui/commit/2b2bc1238dec5715092fa4b3e1418b8a443a409b))
12+
* removed polling; added websocket; allow multiple output images; ([79a560f](https://github.com/runpod-workers/worker-comfyui/commit/79a560f46fbd303828175d138098faebd4baa97e))
13+
114
# [3.6.0](https://github.com/blib-la/runpod-worker-comfy/compare/3.5.0...3.6.0) (2025-03-12)
215

316

Dockerfile

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ENV DEBIAN_FRONTEND=noninteractive
66
# Prefer binary wheels over source distributions for faster pip installations
77
ENV PIP_PREFER_BINARY=1
88
# Ensures output from python is printed immediately to the terminal without buffering
9-
ENV PYTHONUNBUFFERED=1
9+
ENV PYTHONUNBUFFERED=1
1010
# Speed up some cmake builds
1111
ENV CMAKE_BUILD_PARALLEL_LEVEL=8
1212

@@ -30,7 +30,7 @@ RUN pip install uv
3030
RUN uv pip install comfy-cli --system
3131

3232
# Install ComfyUI
33-
RUN /usr/bin/yes | comfy --workspace /comfyui install --version 0.3.29 --cuda-version 12.6 --nvidia --skip-manager
33+
RUN /usr/bin/yes | comfy --workspace /comfyui install --version 0.3.30 --cuda-version 12.6 --nvidia
3434

3535
# Change working directory to ComfyUI
3636
WORKDIR /comfyui
@@ -41,21 +41,14 @@ ADD src/extra_model_paths.yaml ./
4141
# Go back to the root
4242
WORKDIR /
4343

44-
# install dependencies
45-
RUN uv pip install runpod requests --system
44+
# Install Python runtime dependencies for the handler
45+
RUN uv pip install runpod requests websocket-client --system
4646

47+
# Add application code and scripts
48+
ADD src/start.sh handler.py test_input.json ./
49+
RUN chmod +x /start.sh
4750

48-
# Add files
49-
ADD src/start.sh src/restore_snapshot.sh src/rp_handler.py test_input.json ./
50-
RUN chmod +x /start.sh /restore_snapshot.sh
51-
52-
# Optionally copy the snapshot file
53-
ADD *snapshot*.json /
54-
55-
# Restore the snapshot to install custom nodes
56-
RUN /restore_snapshot.sh
57-
58-
# Start container
51+
# Set the default command to run when starting the container
5952
CMD ["/start.sh"]
6053

6154
# Stage 2: Download models
@@ -73,32 +66,35 @@ RUN mkdir -p models/checkpoints models/vae models/unet models/clip
7366

7467
# Download checkpoints/vae/unet/clip models to include in image based on model type
7568
RUN if [ "$MODEL_TYPE" = "sdxl" ]; then \
76-
wget -O models/checkpoints/sd_xl_base_1.0.safetensors https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors && \
77-
wget -O models/vae/sdxl_vae.safetensors https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors && \
78-
wget -O models/vae/sdxl-vae-fp16-fix.safetensors https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl_vae.safetensors; \
79-
elif [ "$MODEL_TYPE" = "sd3" ]; then \
80-
wget --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/checkpoints/sd3_medium_incl_clips_t5xxlfp8.safetensors https://huggingface.co/stabilityai/stable-diffusion-3-medium/resolve/main/sd3_medium_incl_clips_t5xxlfp8.safetensors; \
81-
elif [ "$MODEL_TYPE" = "flux1-schnell" ]; then \
82-
wget -O models/unet/flux1-schnell.safetensors https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/flux1-schnell.safetensors && \
83-
wget -O models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors && \
84-
wget -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
85-
wget -O models/vae/ae.safetensors https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/ae.safetensors; \
86-
elif [ "$MODEL_TYPE" = "flux1-dev" ]; then \
87-
# Full precision FLUX.1 dev
88-
wget --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/unet/flux1-dev.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/flux1-dev.safetensors && \
89-
wget -O models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors && \
90-
wget -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
91-
wget --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/vae/ae.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/ae.safetensors; \
92-
elif [ "$MODEL_TYPE" = "flux1-dev-fp8" ]; then \
93-
# Default model if none specified during build
94-
wget -O models/checkpoints/flux1-dev-fp8.safetensors https://huggingface.co/Comfy-Org/flux1-dev/resolve/main/flux1-dev-fp8.safetensors; \
69+
wget -q -O models/checkpoints/sd_xl_base_1.0.safetensors https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors && \
70+
wget -q -O models/vae/sdxl_vae.safetensors https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors && \
71+
wget -q -O models/vae/sdxl-vae-fp16-fix.safetensors https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl_vae.safetensors; \
72+
fi
73+
74+
RUN if [ "$MODEL_TYPE" = "sd3" ]; then \
75+
wget -q --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/checkpoints/sd3_medium_incl_clips_t5xxlfp8.safetensors https://huggingface.co/stabilityai/stable-diffusion-3-medium/resolve/main/sd3_medium_incl_clips_t5xxlfp8.safetensors; \
76+
fi
77+
78+
RUN if [ "$MODEL_TYPE" = "flux1-schnell" ]; then \
79+
wget -q --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/unet/flux1-schnell.safetensors https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/flux1-schnell.safetensors && \
80+
wget -q -O models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors && \
81+
wget -q -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
82+
wget -q --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/vae/ae.safetensors https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/ae.safetensors; \
83+
fi
84+
85+
RUN if [ "$MODEL_TYPE" = "flux1-dev" ]; then \
86+
wget -q --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/unet/flux1-dev.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/flux1-dev.safetensors && \
87+
wget -q -O models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors && \
88+
wget -q -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
89+
wget -q --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/vae/ae.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/ae.safetensors; \
90+
fi
91+
92+
RUN if [ "$MODEL_TYPE" = "flux1-dev-fp8" ]; then \
93+
wget -q -O models/checkpoints/flux1-dev-fp8.safetensors https://huggingface.co/Comfy-Org/flux1-dev/resolve/main/flux1-dev-fp8.safetensors; \
9594
fi
9695

9796
# Stage 3: Final image
9897
FROM base AS final
9998

10099
# Copy models from stage 2 to the final image
101-
COPY --from=downloader /comfyui/models /comfyui/models
102-
103-
# Start container
104-
CMD ["/start.sh"]
100+
COPY --from=downloader /comfyui/models /comfyui/models

0 commit comments

Comments
 (0)