From 3badd4d5e8753a619f5ceab2c4e5a9058bb84771 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 11 Jun 2026 14:59:10 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E8=A1=A5=E5=85=A8README=20=E2=80=94=20?= =?UTF-8?q?=E6=A1=A5=E6=8E=A5=E6=9E=B6=E6=9E=84/API/=E9=9B=86=E6=88=90?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 830bd7c..cac39e6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,88 @@ -# pipeline +# Pipeline — Sage 产线前端桥接模块 +Sage 平台的产线管理前端模块,通过 HTTP 调用 Hermes Pipeline API 实现产线的提交、查看和管理。 + +## 功能 + +- **产线列表**:查看当前用户的所有产线任务 +- **产线详情**:查看产线节点树、各步骤状态 +- **产线提交**:创建新的产线任务 +- **节点查看**:查看特定节点的输入/输出和版本历史 + +## 架构 + +本模块是 Sage 的前端桥接层,不包含数据库表。它通过 HTTP API 与 Hermes Pipeline 后端(pipeline-app)通信。 + +``` +Sage UI (.ui) → pipeline 模块 (.dspy) → HTTP → Hermes Pipeline API (pipeline-app:9090) +``` + +## 目录结构 + +``` +pipeline/ +├── pipeline/ # Python 包 +│ ├── __init__.py +│ └── init.py # HTTP 客户端 + ServerEnv 注册 +├── wwwroot/ +│ └── api/ +│ ├── pipeline_list.dspy # 产线列表 +│ ├── pipeline_detail.dspy # 产线详情 +│ ├── pipeline_submit.dspy # 提交产线 +│ └── pipeline_node.dspy # 节点查看 +├── scripts/ +│ └── load_path.py # RBAC 权限注册 +├── pyproject.toml +└── README.md +``` + +## API 配置 + +在 `pipeline/init.py` 中配置 Hermes Pipeline API 地址: + +```python +PIPELINE_API_BASE = "https://token.opencomputing.cn/pipeline/v1" +``` + +## Sage 集成步骤 + +### 1. 安装模块 +```bash +cd ~/repos/pipeline && ~/repos/sage/py3/bin/pip install . +``` + +### 2. 注册模块加载 +编辑 `~/repos/sage/app/sage.py`: +```python +from pipeline.init import load_pipeline +# 在 init() 函数中添加: +load_pipeline() +``` + +### 3. wwwroot 软链接 +```bash +cd ~/repos/sage/wwwroot +ln -sf ~/repos/pipeline/wwwroot pipeline +``` + +### 4. RBAC 权限 +```bash +cd ~/repos/sage && ./py3/bin/python ~/repos/pipeline/scripts/load_path.py +``` + +## 函数注册 + +`init.py` 中注册的函数: + +| 函数名 | 说明 | +|--------|------| +| `hermes_pipeline_list(user_id)` | 获取用户产线列表 | +| `hermes_pipeline_detail(pipeline_id)` | 获取产线详情 | +| `hermes_pipeline_submit(data)` | 提交新产线任务 | +| `hermes_pipeline_node(pipeline_id, step, version)` | 获取节点详情 | + +## 注意事项 + +- 本模块不创建数据库表,数据存储在 pipeline-app 后端 +- API 请求超时默认 120 秒,提交产线为 30 秒 +- 使用 aiohttp 异步 HTTP 客户端