舒適的彈射器
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。