Skip to content

Commit 800998d

Browse files
committed
add label studio adapter; increase Nginx file size limit
1 parent 2c089c1 commit 800998d

47 files changed

Lines changed: 4380 additions & 4 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-%:
88
$(MAKE) $*-docker-build
99

1010
.PHONY: build
11-
build: backend-docker-build frontend-docker-build runtime-docker-build
11+
build: backend-docker-build frontend-docker-build runtime-docker-build label-studio-adapter-docker-build
1212

1313
.PHONY: create-namespace
1414
create-namespace:
@@ -81,6 +81,10 @@ frontend-docker-build:
8181
runtime-docker-build:
8282
docker build -t runtime:$(VERSION) . -f scripts/images/runtime/Dockerfile
8383

84+
.PHONY: label-studio-adapter-docker-build
85+
label-studio-adapter-docker-build:
86+
sh scripts/images/label-studio-adapter/build.sh
87+
8488
.PHONY: backend-docker-install
8589
backend-docker-install:
8690
cd deployment/docker/data-mate && docker-compose up -d backend
@@ -105,6 +109,14 @@ runtime-docker-install:
105109
runtime-docker-uninstall:
106110
cd deployment/docker/data-mate && docker-compose down runtime
107111

112+
.PHONY: label-platform-docker-install
113+
label-platform-docker-install:
114+
cd deployment/docker/label-platform && docker-compose -f docker-compose.label-studio.yml -f docker-compose.label-studio-adapter.yml up -d
115+
116+
.PHONY: label-platform-docker-uninstall
117+
label-platform-docker-uninstall:
118+
cd deployment/docker/label-platform && docker-compose -f docker-compose.label-studio.yml -f docker-compose.label-studio-adapter.yml down
119+
108120
.PHONY: runtime-k8s-install
109121
runtime-k8s-install: create-namespace
110122
helm upgrade kuberay-operator deployment/helm/ray/kuberay-operator --install -n $(NAMESPACE)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
services:
2+
adapter:
3+
image: label-studio-adapter:latest
4+
container_name: label-studio-adapter
5+
ports:
6+
- "18000:18000"
7+
environment:
8+
# Database Configuration
9+
MYSQL_HOST: mysql
10+
MYSQL_PORT: 3306
11+
MYSQL_USER: label_studio_user
12+
MYSQL_PASSWORD: user_password
13+
MYSQL_DATABASE: label_studio_adapter
14+
MYSQL_ROOT_PASSWORD: Huawei@123 # 用于初始化数据库和用户
15+
16+
# Label Studio Configuration
17+
LABEL_STUDIO_BASE_URL: http://label-studio:8080
18+
LABEL_STUDIO_USER_TOKEN: DA2NzIwMDk0OCwiaWF0IjoxNzYwMDAwOTQ4LCJq
19+
LABEL_STUDIO_LOCAL_BASE: /label-studio/local_files
20+
LABEL_STUDIO_FILE_PATH_PREFIX: /data/local-files/?d=
21+
22+
# DM Service Configuration
23+
DM_SERVICE_BASE_URL: http://backend:8080/api
24+
DM_FILE_PATH_PREFIX: /
25+
26+
# Application Configuration
27+
HOST: 0.0.0.0
28+
PORT: 18000
29+
DEBUG: true
30+
LOG_LEVEL: INFO
31+
SECRET_KEY: ""
32+
ACCESS_TOKEN_EXPIRE_MINUTES: 30
33+
depends_on:
34+
mysql:
35+
condition: service_healthy
36+
networks:
37+
- edatamate
38+
volumes:
39+
# 注意:不要挂载 .:/app,否则会覆盖容器内的 alembic.ini 等配置文件
40+
# - .:/app
41+
# 挂载 Label Studio 的本地文件存储目录(与 Label Studio 容器共享)
42+
- label_studio_data:/label-studio/local_files
43+
# 注意:需要容器以 root 或有权限的用户运行以修改目录权限
44+
user: root
45+
46+
volumes:
47+
label_studio_data:
48+
49+
networks:
50+
edatamate:
51+
driver: bridge
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
services:
2+
label-studio:
3+
image: heartexlabs/label-studio:latest
4+
ports:
5+
- "8000:8080"
6+
environment:
7+
# Label Studio 基础配置
8+
LABEL_STUDIO_HOST: ${LABEL_STUDIO_BASE_URL:-http://localhost:8000}
9+
10+
# 本地文件服务配置
11+
LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED: "true"
12+
LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT: /label-studio/local_files
13+
14+
# 自动创建用户配置
15+
LABEL_STUDIO_USERNAME: ${LABEL_STUDIO_USERNAME:-datamanager@huawei.com}
16+
LABEL_STUDIO_PASSWORD: ${LABEL_STUDIO_PASSWORD:-DataManager123}
17+
LABEL_STUDIO_USER_TOKEN: DA2NzIwMDk0OCwiaWF0IjoxNzYwMDAwOTQ4LCJq
18+
LABEL_STUDIO_ENABLE_LEGACY_API_TOKEN: "true"
19+
20+
# 数据库配置
21+
DJANGO_DB: default
22+
POSTGRE_HOST: label-studio-db
23+
POSTGRE_PORT: 5432
24+
POSTGRE_NAME: labelstudio
25+
POSTGRE_USER: labelstudio
26+
POSTGRE_PASSWORD: labelstudio@4321
27+
# Label Studio 以 root 运行,以免使用本地文件的时候出现权限问题
28+
user: root
29+
networks:
30+
- edatamate
31+
volumes:
32+
- label_studio_data:/label-studio/data
33+
- label_studio_local:/label-studio/local_files
34+
depends_on:
35+
label-studio-db:
36+
condition: service_healthy
37+
38+
# LS DB
39+
label-studio-db:
40+
image: postgres:latest
41+
restart: unless-stopped
42+
environment:
43+
POSTGRES_DATABASE: ${POSTGRES_DATABASE:-labelstudio}
44+
POSTGRES_USER: ${POSTGRES_USER:-labelstudio}
45+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-labelstudio@4321}
46+
POSTGRES_HOST_AUTH_METHOD: trust
47+
ports:
48+
- "${DB_PORT:-5432}:5432"
49+
volumes:
50+
- label_studio_db_data:/var/lib/postgresql/data
51+
healthcheck:
52+
test:
53+
[
54+
"CMD-SHELL",
55+
"pg_isready -U ${POSTGRES_USER:-labelstudio} -d ${POSTGRES_DATABASE:-labelstudio}",
56+
]
57+
interval: 10s
58+
timeout: 5s
59+
retries: 5
60+
networks:
61+
- edatamate
62+
63+
volumes:
64+
label_studio_db_data:
65+
label_studio_data:
66+
label_studio_local:
67+
68+
networks:
69+
edatamate:
70+
driver: bridge

deployment/docker/datamate/docker-compose.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ services:
1313
- log_volume:/var/log/data-mate
1414
networks: [ edatamate ]
1515
depends_on:
16-
- mysql
16+
mysql:
17+
condition: service_healthy
1718

1819
# 2) frontend(NodePort 30000)
1920
frontend:
2021
container_name: frontend
2122
image: frontend
2223
restart: on-failure
2324
ports:
24-
- "30000:80" # nodePort → hostPort
25+
- "30000:80" # nodePort → hostPort
2526
volumes:
2627
- log_volume:/var/log/data-mate
2728
networks: [ edatamate ]
@@ -35,14 +36,33 @@ services:
3536
restart: on-failure
3637
environment:
3738
MYSQL_ROOT_PASSWORD: Huawei@123
39+
MYSQL_DATABASE: label_studio_adapter
40+
MYSQL_USER: label_studio_user
41+
MYSQL_PASSWORD: user_password
3842
ports:
3943
- "3306:3306"
4044
volumes:
4145
- mysql_volume:/var/lib/mysql
4246
- ../../../scripts/db:/docker-entrypoint-initdb.d
4347
- ./utf8.cnf:/etc/mysql/conf.d/utf8.cnf
4448
- log_volume:/var/log/data-mate
45-
networks: [ edatamate ]
49+
networks: [edatamate]
50+
healthcheck:
51+
test:
52+
[
53+
"CMD",
54+
"mysqladmin",
55+
"ping",
56+
"-h",
57+
"localhost",
58+
"-u",
59+
"root",
60+
"-pHuawei@123",
61+
]
62+
interval: 10s
63+
timeout: 5s
64+
retries: 5
65+
start_period: 40s
4666

4767
runtime:
4868
container_name: runtime
@@ -68,6 +88,9 @@ services:
6888
- log_volume:/var/log/data-mate
6989
- dataset_volume:/dataset
7090
- flow_volume:/flow
91+
depends_on:
92+
mysql:
93+
condition: service_healthy
7194

7295
volumes:
7396
dataset_volume:
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# ====================================
2+
# Label Studio Adapter Configuration
3+
# ====================================
4+
5+
# =========================
6+
# 应用程序配置
7+
# =========================
8+
APP_NAME="Label Studio Adapter"
9+
APP_VERSION="1.0.0"
10+
APP_DESCRIPTION="Adapter for integrating Data Management System with Label Studio"
11+
DEBUG=true
12+
13+
# =========================
14+
# 服务器配置
15+
# =========================
16+
HOST=0.0.0.0
17+
PORT=18000
18+
19+
# =========================
20+
# 日志配置
21+
# =========================
22+
LOG_LEVEL=INFO
23+
24+
# =========================
25+
# Label Studio 服务配置
26+
# =========================
27+
# Label Studio 服务地址(根据部署方式调整)
28+
# Docker 环境:http://label-studio:8080
29+
# 本地开发:http://127.0.0.1:8000
30+
LABEL_STUDIO_BASE_URL=http://label-studio:8080
31+
32+
# Label Studio 用户名和密码(用于自动创建用户)
33+
LABEL_STUDIO_USERNAME=admin@example.com
34+
LABEL_STUDIO_PASSWORD=password
35+
36+
# Label Studio API 认证 Token(Legacy Token,推荐使用)
37+
# 从 Label Studio UI 的 Account & Settings > Access Token 获取
38+
LABEL_STUDIO_USER_TOKEN=your-label-studio-token-here
39+
40+
# Label Studio 本地文件存储基础路径(容器内路径,用于 Docker 部署时的权限检查)
41+
LABEL_STUDIO_LOCAL_BASE=/label-studio/local_files
42+
43+
# Label Studio 本地文件服务路径前缀(任务数据中的文件路径前缀)
44+
LABEL_STUDIO_FILE_PATH_PREFIX=/data/local-files/?d=
45+
46+
# Label Studio 容器中的本地存储路径(用于配置 Local Storage)
47+
LABEL_STUDIO_LOCAL_STORAGE_DATASET_BASE_PATH=/label-studio/local_files/dataset
48+
LABEL_STUDIO_LOCAL_STORAGE_UPLOAD_BASE_PATH=/label-studio/local_files/upload
49+
50+
# Label Studio 任务列表分页大小
51+
LS_TASK_PAGE_SIZE=1000
52+
53+
# =========================
54+
# Data Management 服务配置
55+
# =========================
56+
# DM 服务地址
57+
DM_SERVICE_BASE_URL=http://data-engine:8080
58+
59+
# DM 存储文件夹前缀(通常与 Label Studio 的 local-files 文件夹映射一致)
60+
DM_FILE_PATH_PREFIX=/
61+
62+
# =========================
63+
# Adapter 数据库配置 (MySQL)
64+
# =========================
65+
# 优先级1:如果配置了 MySQL,将优先使用 MySQL 数据库
66+
MYSQL_HOST=adapter-db
67+
MYSQL_PORT=3306
68+
MYSQL_USER=label_studio_user
69+
MYSQL_PASSWORD=user_password
70+
MYSQL_DATABASE=label_studio_adapter
71+
72+
# =========================
73+
# Label Studio 数据库配置 (PostgreSQL)
74+
# =========================
75+
# 仅在使用 docker-compose.label-studio.yml 启动 Label Studio 时需要配置
76+
POSTGRES_HOST=label-studio-db
77+
POSTGRES_PORT=5432
78+
POSTGRES_USER=labelstudio
79+
POSTGRES_PASSWORD=labelstudio@4321
80+
POSTGRES_DATABASE=labelstudio
81+
82+
# =========================
83+
# SQLite 数据库配置(兜底选项)
84+
# =========================
85+
# 优先级3:如果没有配置 MySQL/PostgreSQL,将使用 SQLite
86+
SQLITE_PATH=./data/labelstudio_adapter.db
87+
88+
# =========================
89+
# 可选:直接指定数据库 URL
90+
# =========================
91+
# 如果设置了此项,将覆盖上面的 MySQL/PostgreSQL/SQLite 配置
92+
# DATABASE_URL=postgresql+asyncpg://user:password@host:port/database
93+
94+
# =========================
95+
# 安全配置
96+
# =========================
97+
# 密钥(生产环境务必修改)
98+
SECRET_KEY=your-secret-key-change-this-in-production
99+
100+
# Token 过期时间(分钟)
101+
ACCESS_TOKEN_EXPIRE_MINUTES=30
102+
103+
# =========================
104+
# CORS 配置
105+
# =========================
106+
# 允许的来源(生产环境建议配置具体域名)
107+
ALLOWED_ORIGINS=["*"]
108+
109+
# 允许的 HTTP 方法
110+
ALLOWED_METHODS=["*"]
111+
112+
# 允许的请求头
113+
ALLOWED_HEADERS=["*"]
114+
115+
# =========================
116+
# Docker Compose 配置
117+
# =========================
118+
# Docker Compose 项目名称前缀
119+
COMPOSE_PROJECT_NAME=ls-adapter
120+
121+
# =========================
122+
# 同步配置(未来扩展)
123+
# =========================
124+
# 批量同步任务的批次大小
125+
SYNC_BATCH_SIZE=100
126+
127+
# 同步失败时的最大重试次数
128+
MAX_RETRIES=3
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Local Development Environment Files
2+
.env
3+
.dev.env
4+
5+
# logs
6+
logs/

0 commit comments

Comments
 (0)