runninghub-sdk 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- runninghub_sdk-1.0.0/PKG-INFO +229 -0
- runninghub_sdk-1.0.0/README.md +201 -0
- runninghub_sdk-1.0.0/pyproject.toml +50 -0
- runninghub_sdk-1.0.0/setup.cfg +4 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/__init__.py +104 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/client.py +744 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/config.py +95 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/exceptions.py +140 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/models/__init__.py +5 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/models/node_modifier.py +316 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/py.typed +1 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/typedefs/__init__.py +33 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/typedefs/errors.py +5 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/typedefs/task.py +171 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/typedefs/upload.py +42 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/utils/__init__.py +19 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk/utils/helpers.py +111 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk.egg-info/PKG-INFO +229 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk.egg-info/SOURCES.txt +20 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk.egg-info/dependency_links.txt +1 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk.egg-info/requires.txt +7 -0
- runninghub_sdk-1.0.0/src/runninghub_sdk.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: runninghub-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: RunningHub ComfyUI SDK - 轻松调用RunningHub的ComfyUI API
|
|
5
|
+
Author: RunningHub SDK
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/runninghub-ai/runninghub-sdk
|
|
8
|
+
Project-URL: Documentation, https://github.com/runninghub-ai/runninghub-sdk/tree/main/runninghub_sdk
|
|
9
|
+
Project-URL: Repository, https://github.com/runninghub-ai/runninghub-sdk
|
|
10
|
+
Project-URL: Issues, https://github.com/runninghub-ai/runninghub-sdk/issues
|
|
11
|
+
Keywords: runninghub,comfyui,ai,image-generation,sdk
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Requires-Python: >=3.8
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: httpx>=0.25.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: build>=1.2.2; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
27
|
+
Requires-Dist: twine>=5.1.1; extra == "dev"
|
|
28
|
+
|
|
29
|
+
# RunningHub ComfyUI SDK
|
|
30
|
+
|
|
31
|
+
`runninghub-sdk` 是一个面向 RunningHub ComfyUI OpenAPI 的 Python SDK,支持任务创建、状态轮询、结果查询、文件上传,以及用链式 NodeModifier 修改工作流节点参数。
|
|
32
|
+
|
|
33
|
+
这个子目录可以直接作为 Python 包发布根目录使用,也可以单独进入目录后执行构建和上传命令发布到 PyPI。
|
|
34
|
+
|
|
35
|
+
## 特性
|
|
36
|
+
|
|
37
|
+
- 同时支持同步和异步调用
|
|
38
|
+
- 基于 `httpx`,接口简单,依赖精简
|
|
39
|
+
- 提供完整类型注解,适合 IDE 自动补全
|
|
40
|
+
- 支持 `NodeModifier` 链式修改节点输入
|
|
41
|
+
- 支持图片、视频、音频、LoRA 等文件上传
|
|
42
|
+
- 支持自动轮询等待任务完成
|
|
43
|
+
|
|
44
|
+
## 安装
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install runninghub-sdk
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
如果你是在本仓库中本地开发,也可以进入 `runninghub_sdk` 目录后安装开发依赖:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install -e .[dev]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 快速开始
|
|
57
|
+
|
|
58
|
+
### 同步调用
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from runninghub_sdk import RunningHubClient, modify_nodes
|
|
62
|
+
|
|
63
|
+
with RunningHubClient(api_key="your-api-key") as client:
|
|
64
|
+
modifier = (
|
|
65
|
+
modify_nodes()
|
|
66
|
+
.text("6", "a cinematic sunset over the sea")
|
|
67
|
+
.seed("3", 12345)
|
|
68
|
+
.steps("3", 25)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
task = client.run_with_modifier("workflow-id", modifier)
|
|
72
|
+
outputs = client.wait_for_completion(task.task_id)
|
|
73
|
+
|
|
74
|
+
for output in outputs:
|
|
75
|
+
print(output.file_url)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 异步调用
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import asyncio
|
|
82
|
+
|
|
83
|
+
from runninghub_sdk import RunningHubClient, modify_nodes
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
async def main() -> None:
|
|
87
|
+
async with RunningHubClient(api_key="your-api-key") as client:
|
|
88
|
+
modifier = modify_nodes().text("6", "a beautiful landscape")
|
|
89
|
+
task = await client.async_run_with_modifier("workflow-id", modifier)
|
|
90
|
+
outputs = await client.async_wait_for_completion(task.task_id)
|
|
91
|
+
|
|
92
|
+
for output in outputs:
|
|
93
|
+
print(output.file_url)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
asyncio.run(main())
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## 核心能力
|
|
100
|
+
|
|
101
|
+
### 任务接口
|
|
102
|
+
|
|
103
|
+
| 同步方法 | 异步方法 | 说明 |
|
|
104
|
+
|---------|---------|------|
|
|
105
|
+
| `run()` | `async_run()` | 发起任务 |
|
|
106
|
+
| `run_with_modifier()` | `async_run_with_modifier()` | 使用修改器发起任务 |
|
|
107
|
+
| `get_status()` | `async_get_status()` | 查询任务状态 |
|
|
108
|
+
| `get_outputs()` | `async_get_outputs()` | 查询任务输出 |
|
|
109
|
+
| `wait_for_completion()` | `async_wait_for_completion()` | 轮询直到任务完成 |
|
|
110
|
+
| `query_v2()` | `async_query_v2()` | 调用 V2 查询接口 |
|
|
111
|
+
|
|
112
|
+
### 文件上传
|
|
113
|
+
|
|
114
|
+
| 同步方法 | 异步方法 | 说明 |
|
|
115
|
+
|---------|---------|------|
|
|
116
|
+
| `upload_file()` | `async_upload_file()` | 上传通用文件 |
|
|
117
|
+
| `upload_image()` | `async_upload_image()` | 上传图片 |
|
|
118
|
+
| `upload_lora()` | `async_upload_lora()` | 上传 LoRA |
|
|
119
|
+
|
|
120
|
+
### 工作流读取
|
|
121
|
+
|
|
122
|
+
| 同步方法 | 异步方法 | 说明 |
|
|
123
|
+
|---------|---------|------|
|
|
124
|
+
| `get_workflow_json()` | `async_get_workflow_json()` | 获取工作流 JSON 字符串 |
|
|
125
|
+
| `get_workflow_json_parsed()` | `async_get_workflow_json_parsed()` | 获取解析后的工作流对象 |
|
|
126
|
+
|
|
127
|
+
## NodeModifier
|
|
128
|
+
|
|
129
|
+
`NodeModifier` 用于用链式 API 构造 `node_info_list`,让工作流参数修改更直观。
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from runninghub_sdk import modify_nodes
|
|
133
|
+
|
|
134
|
+
modifier = (
|
|
135
|
+
modify_nodes()
|
|
136
|
+
.text("6", "a portrait in film style")
|
|
137
|
+
.negative_text("7", "blurry, low quality")
|
|
138
|
+
.seed("3", 12345)
|
|
139
|
+
.steps("3", 25)
|
|
140
|
+
.cfg("3", 7.5)
|
|
141
|
+
.size("5", 1024, 768)
|
|
142
|
+
.sampler("3", "dpmpp_2m")
|
|
143
|
+
.scheduler("3", "karras")
|
|
144
|
+
.image("10", "uploaded-file.png")
|
|
145
|
+
)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
常用方法如下:
|
|
149
|
+
|
|
150
|
+
| 方法 | 说明 |
|
|
151
|
+
|------|------|
|
|
152
|
+
| `set(node_id, field_name, value)` | 通用设置 |
|
|
153
|
+
| `text(node_id, text)` | 设置提示词 |
|
|
154
|
+
| `negative_text(node_id, text)` | 设置负面提示词 |
|
|
155
|
+
| `seed(node_id, seed)` | 设置随机种子 |
|
|
156
|
+
| `steps(node_id, steps)` | 设置采样步数 |
|
|
157
|
+
| `cfg(node_id, cfg)` | 设置 CFG |
|
|
158
|
+
| `size(node_id, width, height)` | 设置图像尺寸 |
|
|
159
|
+
| `sampler(node_id, name)` | 设置采样器 |
|
|
160
|
+
| `scheduler(node_id, name)` | 设置调度器 |
|
|
161
|
+
| `denoise(node_id, value)` | 设置去噪强度 |
|
|
162
|
+
| `image(node_id, file_name)` | 设置图片文件 |
|
|
163
|
+
| `video(node_id, file_name)` | 设置视频文件 |
|
|
164
|
+
| `audio(node_id, file_name)` | 设置音频文件 |
|
|
165
|
+
| `lora(node_id, file_name)` | 设置 LoRA 文件 |
|
|
166
|
+
| `checkpoint(node_id, name)` | 设置模型名 |
|
|
167
|
+
|
|
168
|
+
## 错误处理
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from runninghub_sdk import ErrorCode, RunningHubError, TaskError, TimeoutError
|
|
172
|
+
|
|
173
|
+
try:
|
|
174
|
+
outputs = client.wait_for_completion(task.task_id)
|
|
175
|
+
except TimeoutError as error:
|
|
176
|
+
print(f"任务超时: {error.task_id}")
|
|
177
|
+
except TaskError as error:
|
|
178
|
+
print(f"任务失败: {error.failed_reason}")
|
|
179
|
+
except RunningHubError as error:
|
|
180
|
+
if error.code == ErrorCode.API_KEY_INVALID:
|
|
181
|
+
print("API Key 无效")
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 类型定义
|
|
185
|
+
|
|
186
|
+
SDK 暴露了常用类型,便于静态检查和 IDE 补全:
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from runninghub_sdk import (
|
|
190
|
+
CreateTaskResponse,
|
|
191
|
+
NodeInput,
|
|
192
|
+
TaskOutput,
|
|
193
|
+
TaskStatus,
|
|
194
|
+
UploadResponseData,
|
|
195
|
+
)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## 更多示例
|
|
199
|
+
|
|
200
|
+
更多可运行示例见 [EXAMPLES.md](EXAMPLES.md)。
|
|
201
|
+
|
|
202
|
+
## 在 `runninghub_sdk` 目录发布到 PyPI
|
|
203
|
+
|
|
204
|
+
进入当前目录后执行:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
python -m pip install -U build twine
|
|
208
|
+
python -m build
|
|
209
|
+
python -m twine check dist/*
|
|
210
|
+
python -m twine upload dist/*
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
如果你使用 API Token,推荐先设置环境变量:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
export TWINE_USERNAME=__token__
|
|
217
|
+
export TWINE_PASSWORD=pypi-xxxxxxxxxxxxxxxxxxxx
|
|
218
|
+
python -m twine upload dist/*
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
发布前建议先上传到 TestPyPI 做一次验证:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
python -m twine upload --repository testpypi dist/*
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## License
|
|
228
|
+
|
|
229
|
+
MIT
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# RunningHub ComfyUI SDK
|
|
2
|
+
|
|
3
|
+
`runninghub-sdk` 是一个面向 RunningHub ComfyUI OpenAPI 的 Python SDK,支持任务创建、状态轮询、结果查询、文件上传,以及用链式 NodeModifier 修改工作流节点参数。
|
|
4
|
+
|
|
5
|
+
这个子目录可以直接作为 Python 包发布根目录使用,也可以单独进入目录后执行构建和上传命令发布到 PyPI。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- 同时支持同步和异步调用
|
|
10
|
+
- 基于 `httpx`,接口简单,依赖精简
|
|
11
|
+
- 提供完整类型注解,适合 IDE 自动补全
|
|
12
|
+
- 支持 `NodeModifier` 链式修改节点输入
|
|
13
|
+
- 支持图片、视频、音频、LoRA 等文件上传
|
|
14
|
+
- 支持自动轮询等待任务完成
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install runninghub-sdk
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
如果你是在本仓库中本地开发,也可以进入 `runninghub_sdk` 目录后安装开发依赖:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install -e .[dev]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 快速开始
|
|
29
|
+
|
|
30
|
+
### 同步调用
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from runninghub_sdk import RunningHubClient, modify_nodes
|
|
34
|
+
|
|
35
|
+
with RunningHubClient(api_key="your-api-key") as client:
|
|
36
|
+
modifier = (
|
|
37
|
+
modify_nodes()
|
|
38
|
+
.text("6", "a cinematic sunset over the sea")
|
|
39
|
+
.seed("3", 12345)
|
|
40
|
+
.steps("3", 25)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
task = client.run_with_modifier("workflow-id", modifier)
|
|
44
|
+
outputs = client.wait_for_completion(task.task_id)
|
|
45
|
+
|
|
46
|
+
for output in outputs:
|
|
47
|
+
print(output.file_url)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 异步调用
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
import asyncio
|
|
54
|
+
|
|
55
|
+
from runninghub_sdk import RunningHubClient, modify_nodes
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
async def main() -> None:
|
|
59
|
+
async with RunningHubClient(api_key="your-api-key") as client:
|
|
60
|
+
modifier = modify_nodes().text("6", "a beautiful landscape")
|
|
61
|
+
task = await client.async_run_with_modifier("workflow-id", modifier)
|
|
62
|
+
outputs = await client.async_wait_for_completion(task.task_id)
|
|
63
|
+
|
|
64
|
+
for output in outputs:
|
|
65
|
+
print(output.file_url)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
asyncio.run(main())
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 核心能力
|
|
72
|
+
|
|
73
|
+
### 任务接口
|
|
74
|
+
|
|
75
|
+
| 同步方法 | 异步方法 | 说明 |
|
|
76
|
+
|---------|---------|------|
|
|
77
|
+
| `run()` | `async_run()` | 发起任务 |
|
|
78
|
+
| `run_with_modifier()` | `async_run_with_modifier()` | 使用修改器发起任务 |
|
|
79
|
+
| `get_status()` | `async_get_status()` | 查询任务状态 |
|
|
80
|
+
| `get_outputs()` | `async_get_outputs()` | 查询任务输出 |
|
|
81
|
+
| `wait_for_completion()` | `async_wait_for_completion()` | 轮询直到任务完成 |
|
|
82
|
+
| `query_v2()` | `async_query_v2()` | 调用 V2 查询接口 |
|
|
83
|
+
|
|
84
|
+
### 文件上传
|
|
85
|
+
|
|
86
|
+
| 同步方法 | 异步方法 | 说明 |
|
|
87
|
+
|---------|---------|------|
|
|
88
|
+
| `upload_file()` | `async_upload_file()` | 上传通用文件 |
|
|
89
|
+
| `upload_image()` | `async_upload_image()` | 上传图片 |
|
|
90
|
+
| `upload_lora()` | `async_upload_lora()` | 上传 LoRA |
|
|
91
|
+
|
|
92
|
+
### 工作流读取
|
|
93
|
+
|
|
94
|
+
| 同步方法 | 异步方法 | 说明 |
|
|
95
|
+
|---------|---------|------|
|
|
96
|
+
| `get_workflow_json()` | `async_get_workflow_json()` | 获取工作流 JSON 字符串 |
|
|
97
|
+
| `get_workflow_json_parsed()` | `async_get_workflow_json_parsed()` | 获取解析后的工作流对象 |
|
|
98
|
+
|
|
99
|
+
## NodeModifier
|
|
100
|
+
|
|
101
|
+
`NodeModifier` 用于用链式 API 构造 `node_info_list`,让工作流参数修改更直观。
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from runninghub_sdk import modify_nodes
|
|
105
|
+
|
|
106
|
+
modifier = (
|
|
107
|
+
modify_nodes()
|
|
108
|
+
.text("6", "a portrait in film style")
|
|
109
|
+
.negative_text("7", "blurry, low quality")
|
|
110
|
+
.seed("3", 12345)
|
|
111
|
+
.steps("3", 25)
|
|
112
|
+
.cfg("3", 7.5)
|
|
113
|
+
.size("5", 1024, 768)
|
|
114
|
+
.sampler("3", "dpmpp_2m")
|
|
115
|
+
.scheduler("3", "karras")
|
|
116
|
+
.image("10", "uploaded-file.png")
|
|
117
|
+
)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
常用方法如下:
|
|
121
|
+
|
|
122
|
+
| 方法 | 说明 |
|
|
123
|
+
|------|------|
|
|
124
|
+
| `set(node_id, field_name, value)` | 通用设置 |
|
|
125
|
+
| `text(node_id, text)` | 设置提示词 |
|
|
126
|
+
| `negative_text(node_id, text)` | 设置负面提示词 |
|
|
127
|
+
| `seed(node_id, seed)` | 设置随机种子 |
|
|
128
|
+
| `steps(node_id, steps)` | 设置采样步数 |
|
|
129
|
+
| `cfg(node_id, cfg)` | 设置 CFG |
|
|
130
|
+
| `size(node_id, width, height)` | 设置图像尺寸 |
|
|
131
|
+
| `sampler(node_id, name)` | 设置采样器 |
|
|
132
|
+
| `scheduler(node_id, name)` | 设置调度器 |
|
|
133
|
+
| `denoise(node_id, value)` | 设置去噪强度 |
|
|
134
|
+
| `image(node_id, file_name)` | 设置图片文件 |
|
|
135
|
+
| `video(node_id, file_name)` | 设置视频文件 |
|
|
136
|
+
| `audio(node_id, file_name)` | 设置音频文件 |
|
|
137
|
+
| `lora(node_id, file_name)` | 设置 LoRA 文件 |
|
|
138
|
+
| `checkpoint(node_id, name)` | 设置模型名 |
|
|
139
|
+
|
|
140
|
+
## 错误处理
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from runninghub_sdk import ErrorCode, RunningHubError, TaskError, TimeoutError
|
|
144
|
+
|
|
145
|
+
try:
|
|
146
|
+
outputs = client.wait_for_completion(task.task_id)
|
|
147
|
+
except TimeoutError as error:
|
|
148
|
+
print(f"任务超时: {error.task_id}")
|
|
149
|
+
except TaskError as error:
|
|
150
|
+
print(f"任务失败: {error.failed_reason}")
|
|
151
|
+
except RunningHubError as error:
|
|
152
|
+
if error.code == ErrorCode.API_KEY_INVALID:
|
|
153
|
+
print("API Key 无效")
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## 类型定义
|
|
157
|
+
|
|
158
|
+
SDK 暴露了常用类型,便于静态检查和 IDE 补全:
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from runninghub_sdk import (
|
|
162
|
+
CreateTaskResponse,
|
|
163
|
+
NodeInput,
|
|
164
|
+
TaskOutput,
|
|
165
|
+
TaskStatus,
|
|
166
|
+
UploadResponseData,
|
|
167
|
+
)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## 更多示例
|
|
171
|
+
|
|
172
|
+
更多可运行示例见 [EXAMPLES.md](EXAMPLES.md)。
|
|
173
|
+
|
|
174
|
+
## 在 `runninghub_sdk` 目录发布到 PyPI
|
|
175
|
+
|
|
176
|
+
进入当前目录后执行:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
python -m pip install -U build twine
|
|
180
|
+
python -m build
|
|
181
|
+
python -m twine check dist/*
|
|
182
|
+
python -m twine upload dist/*
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
如果你使用 API Token,推荐先设置环境变量:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
export TWINE_USERNAME=__token__
|
|
189
|
+
export TWINE_PASSWORD=pypi-xxxxxxxxxxxxxxxxxxxx
|
|
190
|
+
python -m twine upload dist/*
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
发布前建议先上传到 TestPyPI 做一次验证:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
python -m twine upload --repository testpypi dist/*
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "runninghub-sdk"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "RunningHub ComfyUI SDK - 轻松调用RunningHub的ComfyUI API"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.8"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "RunningHub SDK"}
|
|
10
|
+
]
|
|
11
|
+
keywords = ["runninghub", "comfyui", "ai", "image-generation", "sdk"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.8",
|
|
17
|
+
"Programming Language :: Python :: 3.9",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
dependencies = [
|
|
24
|
+
"httpx>=0.25.0",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
dev = [
|
|
29
|
+
"build>=1.2.2",
|
|
30
|
+
"pytest>=7.0.0",
|
|
31
|
+
"pytest-asyncio>=0.21.0",
|
|
32
|
+
"twine>=5.1.1",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/runninghub-ai/runninghub-sdk"
|
|
37
|
+
Documentation = "https://github.com/runninghub-ai/runninghub-sdk/tree/main/runninghub_sdk"
|
|
38
|
+
Repository = "https://github.com/runninghub-ai/runninghub-sdk"
|
|
39
|
+
Issues = "https://github.com/runninghub-ai/runninghub-sdk/issues"
|
|
40
|
+
|
|
41
|
+
[build-system]
|
|
42
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
43
|
+
build-backend = "setuptools.build_meta"
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.packages.find]
|
|
46
|
+
where = ["src"]
|
|
47
|
+
include = ["runninghub_sdk*"]
|
|
48
|
+
|
|
49
|
+
[tool.setuptools.package-data]
|
|
50
|
+
runninghub_sdk = ["py.typed"]
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""
|
|
2
|
+
RunningHub ComfyUI SDK
|
|
3
|
+
|
|
4
|
+
一个轻量级的Python SDK,用于调用RunningHub的ComfyUI API。
|
|
5
|
+
|
|
6
|
+
示例:
|
|
7
|
+
from runninghub_sdk import RunningHubClient, modify_nodes
|
|
8
|
+
|
|
9
|
+
# 同步使用
|
|
10
|
+
client = RunningHubClient(api_key="your-api-key")
|
|
11
|
+
task = client.run("workflow-id")
|
|
12
|
+
outputs = client.wait_for_completion(task.task_id)
|
|
13
|
+
|
|
14
|
+
# 异步使用
|
|
15
|
+
async with RunningHubClient(api_key="your-api-key") as client:
|
|
16
|
+
task = await client.async_run("workflow-id")
|
|
17
|
+
outputs = await client.async_wait_for_completion(task.task_id)
|
|
18
|
+
|
|
19
|
+
# 使用节点修改器
|
|
20
|
+
modifier = (
|
|
21
|
+
modify_nodes()
|
|
22
|
+
.text("6", "a beautiful sunset")
|
|
23
|
+
.seed("3", 12345)
|
|
24
|
+
.steps("3", 25)
|
|
25
|
+
)
|
|
26
|
+
task = client.run_with_modifier("workflow-id", modifier)
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
__version__ = "1.0.0"
|
|
30
|
+
|
|
31
|
+
# 主类
|
|
32
|
+
from .client import RunningHubClient, create_client
|
|
33
|
+
|
|
34
|
+
# 类型导出
|
|
35
|
+
from .typedefs import (
|
|
36
|
+
# 任务类型
|
|
37
|
+
TaskStatus,
|
|
38
|
+
NodeInput,
|
|
39
|
+
CreateTaskRequest,
|
|
40
|
+
CreateTaskResponse,
|
|
41
|
+
TaskOutput,
|
|
42
|
+
V2QueryResult,
|
|
43
|
+
TaskFailedReason,
|
|
44
|
+
WaitForCompletionOptions,
|
|
45
|
+
# 上传类型
|
|
46
|
+
UploadResponseData,
|
|
47
|
+
LoraUploadResponse,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# 异常类导出 (包含 ErrorCode 和 ERROR_MESSAGES)
|
|
51
|
+
from .exceptions import (
|
|
52
|
+
RunningHubError,
|
|
53
|
+
TaskError,
|
|
54
|
+
UploadError,
|
|
55
|
+
TimeoutError,
|
|
56
|
+
NetworkError,
|
|
57
|
+
ValidationError,
|
|
58
|
+
ErrorCode,
|
|
59
|
+
ERROR_MESSAGES,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# 工具类导出
|
|
63
|
+
from .models import NodeModifier, modify_nodes
|
|
64
|
+
|
|
65
|
+
# 配置模块导出
|
|
66
|
+
from .config import get_api_key, get_base_url, get_timeout, load_env_file
|
|
67
|
+
|
|
68
|
+
__all__ = [
|
|
69
|
+
# 版本
|
|
70
|
+
"__version__",
|
|
71
|
+
# 主类
|
|
72
|
+
"RunningHubClient",
|
|
73
|
+
"create_client",
|
|
74
|
+
# 任务类型
|
|
75
|
+
"TaskStatus",
|
|
76
|
+
"NodeInput",
|
|
77
|
+
"CreateTaskRequest",
|
|
78
|
+
"CreateTaskResponse",
|
|
79
|
+
"TaskOutput",
|
|
80
|
+
"V2QueryResult",
|
|
81
|
+
"TaskFailedReason",
|
|
82
|
+
"WaitForCompletionOptions",
|
|
83
|
+
# 上传类型
|
|
84
|
+
"UploadResponseData",
|
|
85
|
+
"LoraUploadResponse",
|
|
86
|
+
# 错误类型
|
|
87
|
+
"ErrorCode",
|
|
88
|
+
"ERROR_MESSAGES",
|
|
89
|
+
# 异常类
|
|
90
|
+
"RunningHubError",
|
|
91
|
+
"TaskError",
|
|
92
|
+
"UploadError",
|
|
93
|
+
"TimeoutError",
|
|
94
|
+
"NetworkError",
|
|
95
|
+
"ValidationError",
|
|
96
|
+
# 工具类
|
|
97
|
+
"NodeModifier",
|
|
98
|
+
"modify_nodes",
|
|
99
|
+
# 配置
|
|
100
|
+
"get_api_key",
|
|
101
|
+
"get_base_url",
|
|
102
|
+
"get_timeout",
|
|
103
|
+
"load_env_file",
|
|
104
|
+
]
|