Skip to content

Commit a711ac9

Browse files
Refactor templates distribution into multi-package workspace (#259)
Co-authored-by: ComfyUI Wiki <[email protected]>
1 parent e310eeb commit a711ac9

File tree

44 files changed

+7457
-40
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+7457
-40
lines changed

.github/workflows/build-test.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Build & Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
build-and-test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: "20"
19+
cache: "npm"
20+
21+
- name: Install Node dependencies
22+
run: npm ci
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.12"
28+
29+
- name: Install Python tooling
30+
run: |
31+
python -m venv .venv
32+
source .venv/bin/activate
33+
pip install --upgrade pip build pytest ruff aiohttp twine
34+
35+
- name: Sync manifest and bundle assets
36+
run: |
37+
source .venv/bin/activate
38+
python scripts/sync_bundles.py
39+
40+
- name: Lint Python modules
41+
run: |
42+
source .venv/bin/activate
43+
ruff check scripts/sync_bundles.py packages/core packages/meta
44+
45+
- name: Build packages
46+
run: |
47+
source .venv/bin/activate
48+
rm -rf dist
49+
mkdir dist
50+
for pkg in core media_api media_video media_image media_other meta; do
51+
python -m build --outdir dist packages/$pkg
52+
done
53+
54+
- name: Run Nx build (sanity)
55+
env:
56+
NX_ADD_PLUGINS: "false"
57+
NX_DAEMON: "false"
58+
run: |
59+
source .venv/bin/activate
60+
npm run build:all
61+
62+
- name: Run tests
63+
env:
64+
PYTHONPATH: packages/meta/src:packages/core/src:packages/media_api/src:packages/media_video/src:packages/media_image/src:packages/media_other/src
65+
run: |
66+
source .venv/bin/activate
67+
pytest packages/core/tests

.github/workflows/publish.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,44 @@ jobs:
4242
- name: Checkout code
4343
uses: actions/checkout@v4
4444

45+
- name: Set up Node.js
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version: "20"
49+
cache: "npm"
50+
51+
- name: Install Node dependencies
52+
run: npm ci
53+
4554
- name: Set up Python
4655
uses: actions/setup-python@v4
4756
with:
4857
python-version: "3.x"
4958

50-
- name: Install build dependencies
51-
run: python -m pip install build
59+
- name: Install build tooling
60+
run: |
61+
python -m venv .venv
62+
source .venv/bin/activate
63+
pip install --upgrade pip build
5264
53-
- name: Setup package
65+
- name: Sync manifest and bundle assets
5466
run: |
55-
mkdir -p comfyui_workflow_templates/templates/
56-
cp -r templates/* comfyui_workflow_templates/templates/
67+
source .venv/bin/activate
68+
python scripts/sync_bundles.py
5769
58-
- name: Build package
59-
run: python -m build
70+
- name: Build packages
71+
run: |
72+
source .venv/bin/activate
73+
rm -rf dist
74+
mkdir dist
75+
for pkg in core media_api media_video media_image media_other meta; do
76+
python -m build --outdir dist packages/$pkg
77+
done
6078
6179
- name: Publish to PyPI
6280
uses: pypa/gh-action-pypi-publish@release/v1
6381
with:
82+
packages-dir: dist
6483
password: ${{ secrets.PYPI_TOKEN }}
6584
attestations: false
6685

.gitignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ pnpm-debug.log*
88
lerna-debug.log*
99

1010
node_modules
11+
.venv
12+
.nx
1113
dist
1214
dist-ssr
1315
*.local
@@ -49,6 +51,14 @@ dist.zip
4951
# Generated JSON Schemas
5052
/schemas/
5153

54+
# Generated manifest samples
55+
/prd/
56+
57+
# Generated bundle assets
58+
packages/*/src/**/templates/
59+
packages/*/src/**/__pycache__/
60+
packages/*/src/**/*.egg-info/
61+
5262
# Workflow templates assets
5363
# Hosted on https://github.com/Comfy-Org/workflow_templates
5464
/public/templates/
@@ -72,4 +82,4 @@ lychee_full_report.txt
7282
LINK_CHECKER_REPORT.md
7383

7484
# Asset validation report (generated by scripts)
75-
asset_validation_report.md
85+
asset_validation_report.md

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
include README.md
22
include LICENSE
3-
recursive-include comfyui_workflow_templates/templates *

README.md

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# workflow_templates
22

3-
ComfyUI workflow templates available in the app by clicking the **Workflow** button then the **Browse Templates** button.
3+
This repo hosts the official ComfyUI workflow templates. The repository now ships a
4+
**package-per-media** structure:
5+
6+
- `packages/core` – manifest + loader helpers shipped as `comfyui-workflow-templates-core`
7+
- `packages/media_*` – the actual template JSON + preview assets for each media type
8+
- `packages/meta` and the root `pyproject.toml` – the `comfyui-workflow-templates` meta package that depends on all others
9+
10+
Most contributors only touch the `templates/` folder and `bundles.json`, but the build
11+
pipeline now requires the helper scripts described below. See the sections on "Adding
12+
new templates" and "Publishing" for the exact steps.
413

514
- [workflow\_templates](#workflow_templates)
615
- [Adding New Templates](#adding-new-templates)
@@ -10,12 +19,13 @@ ComfyUI workflow templates available in the app by clicking the **Workflow** but
1019
- [4 — Choose Thumbnail Type](#4--choose-thumbnail-type)
1120
- [5 — Compress Assets](#5--compress-assets)
1221
- [6 — Rename and Move Files](#6--rename-and-move-files)
13-
- [7 — Add Entry to `index.json`](#7--add-entry-to-indexjson)
14-
- [8 — Embed Models](#8--embed-models)
15-
- [9 — Embed Node Versions (optional)](#9--embed-node-versions-optional)
16-
- [10 — Add Documentation Nodes (optional)](#10--add-documentation-nodes-optional)
17-
- [11 — Bump Version and Create PR](#11--bump-version-and-create-pr)
18-
- [12 — Add Translations](#12--add-translations)
22+
- [7 — Assign Bundle & Sync Assets](#7--assign-bundle--sync-assets)
23+
- [8 — Add Entry to `index.json`](#8--add-entry-to-indexjson)
24+
- [9 — Embed Models](#9--embed-models)
25+
- [10 — Embed Node Versions (optional)](#10--embed-node-versions-optional)
26+
- [11 — Add Documentation Nodes (optional)](#11--add-documentation-nodes-optional)
27+
- [12 — Bump Version and Create PR](#12--bump-version-and-create-pr)
28+
- [13 — Add Translations](#13--add-translations)
1929

2030
## Adding New Templates
2131

@@ -93,7 +103,22 @@ text_to_video_wan-1.webp
93103

94104
Then move the renamed files to your templates folder.
95105

96-
### 7 — Add Entry to `index.json`
106+
### 7 — Assign Bundle & Sync Assets
107+
108+
Each template lives in one bundle (`media-image`, `media-video`, etc.). Update
109+
[`bundles.json`](bundles.json) with the template ID so the correct media package ships it.
110+
After editing `templates/` or `bundles.json`, regenerate the manifest and copy assets into
111+
the package directories:
112+
113+
```bash
114+
python scripts/sync_bundles.py
115+
# or via Nx
116+
npm run sync
117+
```
118+
119+
This step must be run before committing; CI will fail if the manifest/bundles are out of sync.
120+
121+
### 8 — Add Entry to `index.json`
97122

98123
There's an [`index.json`](templates/index.json) file in the templates folder which is where template configurations are set. You will need to add your template to this file, using the fields outlined below:
99124

@@ -166,7 +191,7 @@ Now you can start ComfyUI (or refresh browser if already running) and test that
166191
>
167192
> Make sure to use double-quotes `"` instead of single-quotes `'` when adding things to json files
168193
169-
### 8 — Embed Models
194+
### 9 — Embed Models
170195

171196
Now we need to embed metadata for any models the template workflow uses. This way, the user can download and run the workflow without ever leaving ComfyUI.
172197

@@ -296,7 +321,7 @@ You can find the `hash` and `hash_type` for a model on huggingface (see below)or
296321
>
297322
> Ensure that the filename being downloaded from the links matches the filenames in the `widgets_values` exactly.
298323
299-
### 9 — Embed Node Versions (optional)
324+
### 10 — Embed Node Versions (optional)
300325

301326
If your template requires a specific version of Comfy or a custom node, you can specify that using the same process as with models.
302327

@@ -330,7 +355,7 @@ The Wan 2.1 workflow requires the SaveWEBM node which wasn't fully supported unt
330355

331356
This can help diagnose issues when others run the workflow and ensure the workflow is more reproducible.
332357

333-
### 10 — Add Documentation Nodes (optional)
358+
### 11 — Add Documentation Nodes (optional)
334359

335360
If your template corresponds with a page on https://github.com/comfyanonymous/ComfyUI_examples, https://docs.comfy.org/custom-nodes/workflow_templates, etc., you can add a `MarkdownNote` node with links:
336361

@@ -346,7 +371,22 @@ Raw markdown used:
346371
> [Wan 2.1 Tutorial - docs.comfy.org](https://docs.comfy.org/tutorials/video/wan/wan-video) — Explanation of concepts and step-by-step tutorial
347372
```
348373

349-
### 11 — Bump Version and Create PR
374+
### 12 — Bump Version and Create PR
375+
376+
Run the automated version helper before opening your PR. It looks at the latest git tag
377+
and bumps only the packages that changed (plus updates dependency pins):
378+
379+
```bash
380+
./scripts/bump_versions.py --dry-run # optional preview
381+
./scripts/bump_versions.py
382+
```
383+
384+
Then run the full validation script (which regenerates manifests, runs lint/tests, and
385+
builds wheels):
386+
387+
```bash
388+
./run_full_validation.sh
389+
```
350390

351391
1. Fully test the workflow: delete the models, input images, etc. and try it as a new user would. Ensure the process has no hiccups and you can generate the thumbnail image on the first execution (if applicable).
352392
2. Create a fork of https://github.com/Comfy-Org/workflow_templates (or just checkout a new branch if you are a Comfy-Org collaborator)
@@ -361,7 +401,7 @@ Here is the PR I made for the Wan template: https://github.com/Comfy-Org/workflo
361401

362402
Once the PR is merged, if you followed step 6 correctly, a new version will be published to the [comfyui-workflow-templates PyPi package](https://pypi.org/project/comfyui-workflow-templates).
363403

364-
### 12 — Add Translations
404+
### 13 — Add Translations
365405

366406
Make a PR in https://github.com/Comfy-Org/ComfyUI_frontend adding the mapping from your template filename (without extension) to the English display name title. The mapping goes in [`ComfyUI_frontend/src/locales/en/main.json`](https://github.com/Comfy-Org/ComfyUI_frontend/blob/9f0abac57ba0d5752c51198bf8a075b8336fdda1/src/locales/en/main.json#L480-L487).
367407

0 commit comments

Comments
 (0)