Skip to content

feat: multiple output images; replace http polling with websocket to check when a workflow is done #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2b2bc12
feat: move stuff around
TimPietrusky Apr 30, 2025
79a560f
feat: removed polling; added websocket; allow multiple output images;
TimPietrusky Apr 30, 2025
b514f7c
ci: enable dry-run for semantic release; removed unused python setup
TimPietrusky May 2, 2025
1dcaa3a
ci: updated to python 3.11
TimPietrusky May 2, 2025
506f732
docs: updated conventions to reflect the current state of the repo
TimPietrusky May 2, 2025
d9ed145
fix: moved code back into stage 1
TimPietrusky May 2, 2025
a42d39d
chore: rename "tests_deactivated.json" to "tests.json"
TimPietrusky May 2, 2025
258253c
Merge branch 'main' into feat/refactor
TimPietrusky May 2, 2025
0f6773f
Merge branch 'main' into feat/refactor
TimPietrusky May 2, 2025
6f3a9e7
ci: temporarly allow "feat/refactor" to trigger semantic-release
TimPietrusky May 2, 2025
e7f847f
chore(release): 4.1.0
semantic-release-bot May 2, 2025
0be5686
ci: properly enable dry-run
TimPietrusky May 2, 2025
2c24b92
Merge branch 'feat/refactor' of github.com:runpod-workers/worker-comf…
TimPietrusky May 2, 2025
77039c9
feat: don't return "refresh_worker" in output; remove log spamming in…
TimPietrusky May 2, 2025
7b6b10f
refactor: download the models separately
TimPietrusky May 2, 2025
3588cdb
feat: refactor the whole docs to make them more clear; replaced "snap…
TimPietrusky May 2, 2025
0cb8e18
fix: use proper ending for "if"
TimPietrusky May 2, 2025
ddc6c32
docs: added all possible comfyui folders; simplified guide of method 1
TimPietrusky May 2, 2025
5929ac6
fix(model): flux.1-schnell is gated
TimPietrusky May 2, 2025
a3d9613
feat: update to 0.3.30
TimPietrusky May 2, 2025
91b9149
test: don't run "snapshot_restoration" tests
TimPietrusky May 2, 2025
edebfb1
chore: force local images
TimPietrusky May 2, 2025
3f58fb7
docs: lowercase for code comments
TimPietrusky May 2, 2025
eb9a1b0
ci: run release for changes in "main"
TimPietrusky May 2, 2025
238c6c5
fix: workflow trigger
TimPietrusky May 2, 2025
f91efef
ci: build only base for now
TimPietrusky May 2, 2025
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
8 changes: 0 additions & 8 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: useblacksmith/setup-python@v6
with:
python-version: "3.10"

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

- name: Clear space to remove unused folders
run: |
rm -rf /usr/share/dotnet
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Release
name: release

on:
workflow_dispatch:
# push:
# branches:
# - "main"
push:
branches:
- "main"

jobs:
release:
Expand All @@ -21,14 +21,6 @@ jobs:
with:
persist-credentials: false

- name: Set up Python
uses: useblacksmith/setup-python@v6
with:
python-version: "3.10"

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

- name: Clear space to remove unused folders
run: |
rm -rf /usr/share/dotnet
Expand All @@ -55,6 +47,7 @@ jobs:
uses: codfish/semantic-release-action@v3
id: semanticrelease
with:
dry-run: true
additional-packages: |
['@semantic-release/git', '@semantic-release/changelog', '@semantic-release/exec']
env:
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ jobs:
- name: Set up Python
uses: useblacksmith/setup-python@v6
with:
python-version: "3.10"
python-version: "3.11"

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

- name: Run Python tests
run: python -m unittest discover

- name: Run snapshot restoration tests
run: |
chmod +x tests/test_restore_snapshot.sh
./tests/test_restore_snapshot.sh
3 changes: 2 additions & 1 deletion .releaserc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"branches": [
"main"
"main",
"feat/refactor"
],
"tagFormat": "${version}",
"plugins": [
Expand Down
18 changes: 0 additions & 18 deletions .runpod/hub.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,6 @@
"description": "When enabled, the worker will stop after each finished job to have a clean state",
"default": false
}
},
{
"key": "COMFY_POLLING_INTERVAL_MS",
"input": {
"name": "Polling Interval (ms)",
"type": "number",
"description": "Time to wait between poll attempts in milliseconds",
"default": 250
}
},
{
"key": "COMFY_POLLING_MAX_RETRIES",
"input": {
"name": "Max Polling Retries",
"type": "number",
"description": "Maximum number of poll attempts. Increase for longer workflows",
"default": 500
}
}
]
}
Expand Down
15 changes: 1 addition & 14 deletions .runpod/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,11 @@
{
"key": "REFRESH_WORKER",
"value": "false"
},
{
"key": "COMFY_POLLING_INTERVAL_MS",
"value": "250"
},
{
"key": "COMFY_POLLING_MAX_RETRIES",
"value": "500"
}
],
"allowedCudaVersions": [
"12.7",
"12.6",
"12.5",
"12.4",
"12.3",
"12.2",
"12.1"
"12.6"
]
}
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# [4.1.0](https://github.com/runpod-workers/worker-comfyui/compare/4.0.1...4.1.0) (2025-05-02)


### Bug Fixes

* moved code back into stage 1 ([d9ed145](https://github.com/runpod-workers/worker-comfyui/commit/d9ed14571308ad27481ae2dda4762d32b73b5d20))


### Features

* move stuff around ([2b2bc12](https://github.com/runpod-workers/worker-comfyui/commit/2b2bc1238dec5715092fa4b3e1418b8a443a409b))
* removed polling; added websocket; allow multiple output images; ([79a560f](https://github.com/runpod-workers/worker-comfyui/commit/79a560f46fbd303828175d138098faebd4baa97e))

# [3.6.0](https://github.com/blib-la/runpod-worker-comfy/compare/3.5.0...3.6.0) (2025-03-12)


Expand Down
72 changes: 34 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV DEBIAN_FRONTEND=noninteractive
# Prefer binary wheels over source distributions for faster pip installations
ENV PIP_PREFER_BINARY=1
# Ensures output from python is printed immediately to the terminal without buffering
ENV PYTHONUNBUFFERED=1
ENV PYTHONUNBUFFERED=1
# Speed up some cmake builds
ENV CMAKE_BUILD_PARALLEL_LEVEL=8

Expand All @@ -30,7 +30,7 @@ RUN pip install uv
RUN uv pip install comfy-cli --system

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

# Change working directory to ComfyUI
WORKDIR /comfyui
Expand All @@ -41,21 +41,14 @@ ADD src/extra_model_paths.yaml ./
# Go back to the root
WORKDIR /

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

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

# Add files
ADD src/start.sh src/restore_snapshot.sh src/rp_handler.py test_input.json ./
RUN chmod +x /start.sh /restore_snapshot.sh

# Optionally copy the snapshot file
ADD *snapshot*.json /

# Restore the snapshot to install custom nodes
RUN /restore_snapshot.sh

# Start container
# Set the default command to run when starting the container
CMD ["/start.sh"]

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

# Download checkpoints/vae/unet/clip models to include in image based on model type
RUN if [ "$MODEL_TYPE" = "sdxl" ]; then \
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 && \
wget -O models/vae/sdxl_vae.safetensors https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors && \
wget -O models/vae/sdxl-vae-fp16-fix.safetensors https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl_vae.safetensors; \
elif [ "$MODEL_TYPE" = "sd3" ]; then \
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; \
elif [ "$MODEL_TYPE" = "flux1-schnell" ]; then \
wget -O models/unet/flux1-schnell.safetensors https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/flux1-schnell.safetensors && \
wget -O models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors && \
wget -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
wget -O models/vae/ae.safetensors https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/ae.safetensors; \
elif [ "$MODEL_TYPE" = "flux1-dev" ]; then \
# Full precision FLUX.1 dev
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 && \
wget -O models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors && \
wget -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
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; \
elif [ "$MODEL_TYPE" = "flux1-dev-fp8" ]; then \
# Default model if none specified during build
wget -O models/checkpoints/flux1-dev-fp8.safetensors https://huggingface.co/Comfy-Org/flux1-dev/resolve/main/flux1-dev-fp8.safetensors; \
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 && \
wget -q -O models/vae/sdxl_vae.safetensors https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors && \
wget -q -O models/vae/sdxl-vae-fp16-fix.safetensors https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl_vae.safetensors; \
fi

RUN if [ "$MODEL_TYPE" = "sd3" ]; then \
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; \
fi

RUN if [ "$MODEL_TYPE" = "flux1-schnell" ]; then \
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 && \
wget -q -O models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors && \
wget -q -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
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; \
fi

RUN if [ "$MODEL_TYPE" = "flux1-dev" ]; then \
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 && \
wget -q -O models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors && \
wget -q -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
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; \
fi

RUN if [ "$MODEL_TYPE" = "flux1-dev-fp8" ]; then \
wget -q -O models/checkpoints/flux1-dev-fp8.safetensors https://huggingface.co/Comfy-Org/flux1-dev/resolve/main/flux1-dev-fp8.safetensors; \
fi

# Stage 3: Final image
FROM base AS final

# Copy models from stage 2 to the final image
COPY --from=downloader /comfyui/models /comfyui/models

# Start container
CMD ["/start.sh"]
COPY --from=downloader /comfyui/models /comfyui/models
Loading