舒适的弹射器
1.0.0
?主页••功能••安装••使用•文档••API
✅要求 • CLI • ?Docker • ?限制
通过 ComfyUI API 以编程方式安排 ComfyUI 工作流程的 Python 库
分支 | 构建状态 | 自提交以来 | 最后一次提交 |
---|---|---|---|
掌握 | |||
发展 |
ComfyUI API Endpoint <| <= Comfy Catapult <=> HTTP Server <| <= Public users
<| <|
<| Your python program <| Your Webui/JS frontend
<| <|
<| Your workflows <|
<| Your HTTP server <|
Comfy Catapult 是一个库,用于通过现有 API 端点从 Python 程序调度和运行 ComfyUI 工作流程。 ComfyUI 通常通过为其用户界面托管此 API 端点来工作。
这使您可以更轻松地通过 UI 制作工作流程,然后从程序中使用它。
# Inside your environment:
# From pypi:
pip install comfy_catapult
# From git:
pip install git+https://github.com/realazthat/[email protected]
项目 | ComfyUI API 包装器 | 外包后端 | 分布式执行 | 包裹工作流程 | 工作室 |
---|---|---|---|---|---|
轻松工作室 | ? | ? | ? | ? | 是的 |
ComfyUI 服务工具包 | X | ? | ? | 是的 | ? |
ComfyUI_NetDist | X | ? | 是的 | ? | ? |
ComfyUI 脚本_示例 | 是的 | 不 | 不 | 不 | 不 |
comfyui-python-api | ? | ? | ? | 是的 | ? |
comfyui-部署 | ? | ? | ? | 是的 | ? |
ComfyUI 到 Python 扩展 | ? | ? | ? | 是的 | ? |
舒适脚本 | ? | ? | ? | 是的 | ? |
霍代利布 | ? | 是的 | ? | ? | ? |
comfyui云 | ? | 是的 | ? | ? | ? |
舒适跑步者 | ? | ? | ? | ? | ? |
ComfyUI-ComfyRun | ? | ? | ? | ? | ? |
来自comfy_catapult/catapult_base.py
:
async def Catapult (
self ,
* ,
job_id : JobID ,
prepared_workflow : dict ,
important : Sequence [ APINodeID ],
use_future_api : Literal [ True ],
job_debug_path : Optional [ Path ] = None
) -> Tuple [ JobStatus , 'asyncio.Future[dict]' ]:
来自examples/sdxlturbo_example_catapulter.py
:
class ExampleWorkflowInfo :
# Direct wrapper around the ComfyUI API.
client : ComfyAPIClientBase
# Job scheduler (the main point of this library).
catapult : ComfyCatapultBase
# Something to help with retrieving files from the ComfyUI storage.
remote : RemoteFileAPIBase
comfy_api_url : str
# This should be the workflow json as a dict.
workflow_template_dict : dict
# This should begin as a deep copy of the template.
workflow_dict : dict
# This will hold the node ids that we must have results for.
important : List [ APINodeID ]
# Make this any string unique to this job.
job_id : str
# When the job is complete, this will be the `/history` json/dictionary for
# this job.
job_history_dict : Optional [ dict ]
# These are inputs that modify this particular workflow.
ckpt_name : Optional [ str ]
positive_prompt : str
negative_prompt : str
# For this particular workflow, this will define the path to the output image.
output_path : Path
async def RunExampleWorkflow ( * , job_info : ExampleWorkflowInfo ):
# You have to write this function, to change the workflow_dict as you like.
await PrepareWorkflow ( job_info = job_info )
job_id : str = job_info . job_id
workflow_dict : dict = job_info . workflow_dict
important : List [ APINodeID ] = job_info . important
# Here the magic happens, the job is submitted to the ComfyUI server.
status , future = await job_info . catapult . Catapult (
job_id = job_id ,
prepared_workflow = workflow_dict ,
important = important ,
use_future_api = True )
# Wait for the job to complete.
while not future . done ():
status , _ = await job_info . catapult . GetStatus ( job_id = job_id )
print ( f'status: { status } ' , file = sys . stderr )
await asyncio . sleep ( 3 )
job_info . job_history_dict = await future
# Now that the job is done, you have to write something that will go and get
# the results you care about, if necessary.
await DownloadResults ( job_info = job_info )
在 ComfyUI 网页界面中:
Enable Dev mode Options
。Save (API format)
。 execute
选项:
用法示例:
python -m comfy_catapult.cli
execute --workflow-path ./test_data/sdxlturbo_example_api.json
3.8.0, 3.9.0, 3.10.0, 3.11.0, 3.12.0
,在 GitHub Actions 工作流程 (./.github/workflows/build-and-test.yml) 中测试。 Docker 镜像在每个标签处发布到 ghcr.io/realazthat/comfy-catapult。
# Use the published images at https://ghcr.io/realazthat/comfy-catapult.
docker run --rm --tty ghcr.io/realazthat/comfy-catapult:v3.0.0 --help
# /data in the docker image is the working directory, so paths are simpler.
docker run --rm --tty
-v " ${PWD} :/data "
-e " COMFY_API_URL= ${COMFY_API_URL} "
ghcr.io/realazthat/comfy-catapult:v3.0.0
execute --workflow-path ./test_data/sdxlturbo_example_api.json
如果您想自己构建镜像,可以使用存储库中的 Dockerfile。
# Build the docker image.
docker build -t my-comfy-catapult-image .
# Print usage.
docker run --rm --tty my-comfy-catapult-image --help
# /data in the docker image is the working directory, so paths are simpler.
docker run --rm --tty
-v " ${PWD} :/data "
-e " COMFY_API_URL= ${COMFY_API_URL} "
my-comfy-catapult-image
execute --workflow-path ./test_data/sdxlturbo_example_api.json
用于运行pre.sh
(类似 Linux 的环境)。
来自 ./.github/dependency.yml,它用于 GH 操作来对所有内容进行全新安装:
bash : scripts.
findutils : scripts.
grep : tests.
xxd : tests.
git : scripts, tests.
xxhash : scripts (changeguard).
rsync : out-of-directory test.
jq : dependency for [yq](https://github.com/kislyuk/yq), which is used to generate
the README; the README generator needs to use `tomlq` (which is a part of `yq`)
to query `pyproject.toml`.
需要pyenv
,或精确匹配的 python 版本,如 ./.python-version 中。
jq
,yq 所需的(安装),它本身是我们的./README.md
生成所必需的,它使用tomlq
(来自 yq 包)来包含 ./pyproject.toml 中的版本字符串。
act(在本地运行 GH 操作):
生成动画:
docker(用于构建 docker 映像)。
develop
分支。git add path/to/file.py
。bash scripts/pre.sh
,这将格式化、lint 并测试代码。git status
检查是否有任何更改(例如生成./README.md
),如果是,则git add
更改,然后返回上一步。git commit -m "..."
。develop
(如果您有权利,则推动开发)。 这些说明适用于项目的维护者。
develop
分支:运行bash ./scripts/pre.sh
以确保一切正常。develop
分支:遵循语义版本控制原则,在 ./pyproject.toml 中更改版本。还要根据需要修改[tool.comfy_catapult-project-metadata]
表中的last_release
和last_stable_release
。develop
分支:使用“准备发布 XYZ”等消息提交这些更改。 (参见上面的贡献部分)。master
分支:将develop
分支合并到master
分支: git checkout master && git merge develop --no-ff
。master
分支:标记版本:使用git tag -a vX.YZ -m "Version XYZ"
为版本创建 git 标签。bash ./scripts/utilities/deploy-to-pypi.sh
将版本发布到 PyPI。git push
和git push --tags
将提交和标签推送到 GitHub。git checkout develop && git merge master
--no-ff
选项将提交添加到 master 分支以进行合并,因此从 master 分支重新分叉开发分支。git push origin develop
将开发分支推送到 GitHub。