Skip to content

Commit dc01c24

Browse files
committed
deploy doc
1 parent 68ccdf0 commit dc01c24

4 files changed

Lines changed: 112 additions & 5 deletions

File tree

.github/workflows/deploy_doc.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
2+
#
3+
name: Deploy VitePress site to Pages
4+
5+
on:
6+
# 在针对 `main` 分支的推送上运行。如果你
7+
# 使用 `master` 分支作为默认分支,请将其更改为 `master`
8+
push:
9+
branches: [master]
10+
11+
# 允许你从 Actions 选项卡手动运行此工作流程
12+
workflow_dispatch:
13+
14+
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
21+
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
22+
concurrency:
23+
group: pages
24+
cancel-in-progress: false
25+
26+
jobs:
27+
# 构建工作
28+
build:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
35+
# - uses: pnpm/action-setup@v3 # 如果使用 pnpm,请取消此区域注释
36+
# with:
37+
# version: 9
38+
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释
39+
- name: Setup Node
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: 20
43+
cache: npm # 或 pnpm / yarn
44+
- name: Setup Pages
45+
uses: actions/configure-pages@v4
46+
- name: Install dependencies
47+
run: npm ci # 或 pnpm install / yarn install / bun install
48+
- name: Build with VitePress
49+
run: npm run docs:build # 或 pnpm docs:build / yarn docs:build / bun run docs:build
50+
- name: Upload artifact
51+
uses: actions/upload-pages-artifact@v3
52+
with:
53+
path: docs/.vitepress/dist
54+
55+
# 部署工作
56+
deploy:
57+
environment:
58+
name: github-pages
59+
url: ${{ steps.deployment.outputs.page_url }}
60+
needs: build
61+
runs-on: ubuntu-latest
62+
name: Deploy
63+
steps:
64+
- name: Deploy to GitHub Pages
65+
id: deployment
66+
uses: actions/deploy-pages@v4

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ You can test the function directly in the beeline command line as shown below
287287
2 rows selected (0.003 seconds)
288288
```
289289
You can see that recall, recommendation reasons, and deduplication are all working.
290+
290291
4. Create API Interface
291292
Refer to the following SQL to expose the SQL function as an API interface:
292293
```sql

README_zh.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# SQLRec
2+
23
一个支持使用SQL进行开发的推荐引擎,目标是让懂数据科学的人,包括数据分析师、数据工程师、后端开发等,都能快速搭建生产可用的推荐系统。系统架构参考下图,SQLRec将底层的组件访问、模型训练、推理等流程使用SQL封装,上层推荐业务逻辑仅使用SQL进行描述即可。
34

4-
![system_architecture](docs/public/sqlrec_arch.png)
5+
![system\_architecture](docs/public/sqlrec_arch.png)
56

67
sqlRec有以下特点:
8+
79
- 云原生,自带基于minikube的部署脚本,可以一键部署SQLRec系统和相关的依赖服务
810
- 扩展了SQL语法,让使用SQL描述推荐系统业务逻辑变得可能
911
- 基于calcite实现了一个高效的SQL执行引擎,可以满足推荐系统的实时性要求
@@ -15,9 +17,11 @@ sqlRec有以下特点:
1517
## 快速开始
1618

1719
### 服务部署
20+
1821
SQLRec目前支持AMD64的Linux系统,后续会支持MacOS。注意,部署需要至少32GB的内存、256GB磁盘空间、可靠的互联网连接(如果使用加速器,注意使用tun模式)。
1922

2023
按下述命令部署SQLRec系统:
24+
2125
```bash
2226
# clone sqlrec repository
2327
git clone https://github.com/sqlrec/sqlrec.git
@@ -43,7 +47,9 @@ kubectl get pod --ALL
4347
cd ..
4448
bash ./bin/beeline.sh
4549
```
50+
4651
注意:
52+
4753
- 上述基于minikube的部署方案仅用于测试,生产环境需要先部署可靠的大数据基础设施,然后参考deploy下的脚本初始化数据库、部署SQLRec deployment
4854
- 如果需要重新部署,可以先通过minikube delete删除集群
4955
- 有一些组件没有默认部署,比如kyuubi、jupyter等,如果需要,可以在deploy目录执行对应的部署脚本,比如`bash ./kyuubi/deploy.sh`
@@ -52,30 +58,39 @@ bash ./bin/beeline.sh
5258
### 连接SQLRec服务
5359

5460
#### 使用beeline
61+
5562
SQLRec实现了hive thrift接口,你可以使用beeline连接SQLRec服务,然后像使用hive一样使用它。
63+
5664
```bash
5765
bash ./bin/beeline.sh
5866
```
5967

6068
#### 使用python
69+
6170
可以在Jupyter Notebook中使用python连接SQLRec服务,并使用python工具分析推荐数据,参考下述代码:
71+
6272
- 使用deploy目录的脚本部署Jupyter
73+
6374
```bash
6475
cd deploy
6576
bash ./jupyter/deploy.sh
6677
# wait pod ready
6778
```
79+
6880
- 浏览器打开Jupyter Notebook,比如`http://127.0.0.1:30280`,使用env.sh中的账号密码登录
6981
- 新建python3 notebook
7082
- 安装依赖
83+
7184
```bash
7285
%pip install pandas
7386
%pip install pyhive
7487
%pip install sasl
7588
%pip install thrift
7689
%pip install thrift-sasl
7790
```
91+
7892
- 连接SQLRec服务,运行sql语句
93+
7994
```python
8095
from pyhive import hive
8196
import pandas as pd
@@ -85,9 +100,11 @@ pd.read_sql("select * from `user_interest_category1` where `user_id` = 1000001",
85100
```
86101

87102
### SQL开发
103+
88104
执行`bash ./bin/beeline.sh`命令连接SQLRec服务,参考下述流程开发推荐需要的数据表、SQL函数、API接口等:
89105

90106
1.初始化数据表,注意可以通过`kubectl get node -o wide`命令获取minikube节点的ip地址,你可能需要替换下述代码的ip地址
107+
91108
```sql
92109
SET table.sql-dialect = default;
93110

@@ -139,7 +156,9 @@ CREATE TABLE IF NOT EXISTS `rec_log_kafka` (
139156
'format' = 'json'
140157
);
141158
```
142-
2. 写入测试数据
159+
160+
1. 写入测试数据
161+
143162
```sql
144163
INSERT INTO `user_interest_category1` VALUES
145164
(1000001, 'pc', 100),
@@ -161,7 +180,9 @@ select * from `user_interest_category1` where `user_id` = 1000001;
161180

162181
select * from `category1_hot_item` where `category1` = 'pc';
163182
```
183+
164184
3.开发sql函数
185+
165186
```sql
166187
-- define function save rec data to kafka and redis
167188
create or replace sql function save_rec_item;
@@ -245,15 +266,17 @@ call save_rec_item(final_rec_data) async;
245266

246267
return final_rec_data;
247268
```
248-
上面SQL定义了推荐函数test_rec,可以发现SQL函数定义语法是:
269+
270+
上面SQL定义了推荐函数test\_rec,可以发现SQL函数定义语法是:
271+
249272
- `create or replace sql function`加函数名开头
250273
- `define input table`定义输入参数,可以为空或者定义多个
251274
- `cache table`缓存中间计算结果,可以缓存SELECT语句、SQL函数调用的执行结果
252275
- `call`调用其他函数, 可以通过async关键字异步调用
253276
- `return`返回计算结果,可以为空
254277

255-
256278
可以直接在beeline命令行测试函数,如下所示
279+
257280
```sql
258281
0: jdbc:hive2://192.168.49.2:30300/default> cache table t1 as select cast(1000001 as bigint) as id;
259282
+-------------+--------+
@@ -286,14 +309,20 @@ return final_rec_data;
286309
+----------+----------+------------+---------------------------------------+----------------+---------------------------------------+
287310
2 rows selected (0.003 seconds)
288311
```
312+
289313
可以发现,召回、推荐理由、去重都已经生效。
290-
4. 创建API接口
314+
315+
1. 创建API接口
291316
参考下述SQL将SQL函数暴露为API接口:
317+
292318
```sql
293319
create or replace api test_rec with test_rec;
294320
```
321+
295322
### 推荐测试
323+
296324
使用下述命令进行推荐测试:
325+
297326
```bash
298327
yi@debian12:~$ curl -X POST http://192.168.49.2:30301/api/v1/test_rec \
299328
-H "Content-Type: application/json" \
@@ -302,17 +331,22 @@ yi@debian12:~$ curl -X POST http://192.168.49.2:30301/api/v1/test_rec \
302331
```
303332

304333
## 性能测试
334+
305335
benchmark目录下有测试脚本,可以参考如下命令进行测试:
336+
306337
```bash
307338
bash init.sh
308339
bash benchmark.sh
309340
```
341+
310342
默认的测试配置如下:
343+
311344
- 10W用户、10W物品数据
312345
- 推荐流程包含4路召回:全局高热、用户兴趣类目高热、itemcf、向量检索(8维,user embedding固定),以及曝光去重、类目打散
313346
- 使用10并发测试单个SQLRec实例
314347

315348
在AMD Ryzen 5600H、32GB DDR4内存机器上测试结果如下:
349+
316350
```
317351
Thread Stats Avg Stdev Max +/- Stdev
318352
Latency 9.23ms 5.04ms 48.96ms 90.50%
@@ -324,8 +358,11 @@ Transfer/sec: 1.93MB
324358
```
325359

326360
## 路线图
361+
327362
### 1.0版本什么时候发布
363+
328364
1.0之前版本都是beta版本,不建议线上使用,不保证接口兼容性。目前无规划发布时间,将在下述功能完善后发布:
365+
329366
- 完善的单元测试、集成测试、效果测试覆盖
330367
- 优化代码质量,目前仍很多细节要打磨
331368
- 支持降级和超时配置
@@ -334,6 +371,7 @@ Transfer/sec: 1.93MB
334371
- c++模型serving
335372

336373
### 后续功能规划
374+
337375
- 前端UI,用于查看当前执行DAG、SQL代码、统计信息等
338376
- 进一步优化SQL语法兼容性、运行性能
339377
- 更多开箱可用的UDF、模型等
@@ -342,3 +380,4 @@ Transfer/sec: 1.93MB
342380
- GPU训练、推理支持
343381
- 支持认证、鉴权
344382
- 最佳实践教程,包括搜索、推荐等
383+

docs/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { defineConfig } from 'vitepress'
44
export default defineConfig({
55
title: "SQLRec",
66
description: "SQLRec docs",
7+
base: '/sqlrec/',
78
locales: {
89
root: {
910
label: '简体中文',

0 commit comments

Comments
 (0)