pipeline/README.md

89 lines
2.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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 客户端