Skip to content

Commit 175d9de

Browse files
authored
[Feature] Add Label Studio adapter module and its build scipts.
[Feature] Add Label Studio adapter module and its build scipts.
2 parents e8e2c1a + c6fbc5a commit 175d9de

40 files changed

+2902
-0
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
docker build -t label-studio-adapter:$(VERSION) . -f scripts/images/label-studio-adapter/Dockerfile
87+
8488
.PHONY: backend-docker-install
8589
backend-docker-install:
8690
cd deployment/docker/data-mate && docker-compose up -d backend
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=[email protected]
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/
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# path to migration scripts.
5+
# this is typically a path given in POSIX (e.g. forward slashes)
6+
# format, relative to the token %(here)s which refers to the location of this
7+
# ini file
8+
script_location = %(here)s/alembic
9+
10+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
11+
# Uncomment the line below if you want the files to be prepended with date and time
12+
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
13+
# for all available tokens
14+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
15+
16+
# sys.path path, will be prepended to sys.path if present.
17+
# defaults to the current working directory. for multiple paths, the path separator
18+
# is defined by "path_separator" below.
19+
prepend_sys_path = .
20+
21+
22+
# timezone to use when rendering the date within the migration file
23+
# as well as the filename.
24+
# If specified, requires the python>=3.9 or backports.zoneinfo library and tzdata library.
25+
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
26+
# string value is passed to ZoneInfo()
27+
# leave blank for localtime
28+
# timezone =
29+
30+
# max length of characters to apply to the "slug" field
31+
# truncate_slug_length = 40
32+
33+
# set to 'true' to run the environment during
34+
# the 'revision' command, regardless of autogenerate
35+
# revision_environment = false
36+
37+
# set to 'true' to allow .pyc and .pyo files without
38+
# a source .py file to be detected as revisions in the
39+
# versions/ directory
40+
# sourceless = false
41+
42+
# version location specification; This defaults
43+
# to <script_location>/versions. When using multiple version
44+
# directories, initial revisions must be specified with --version-path.
45+
# The path separator used here should be the separator specified by "path_separator"
46+
# below.
47+
# version_locations = %(here)s/bar:%(here)s/bat:%(here)s/alembic/versions
48+
49+
# path_separator; This indicates what character is used to split lists of file
50+
# paths, including version_locations and prepend_sys_path within configparser
51+
# files such as alembic.ini.
52+
# The default rendered in new alembic.ini files is "os", which uses os.pathsep
53+
# to provide os-dependent path splitting.
54+
#
55+
# Note that in order to support legacy alembic.ini files, this default does NOT
56+
# take place if path_separator is not present in alembic.ini. If this
57+
# option is omitted entirely, fallback logic is as follows:
58+
#
59+
# 1. Parsing of the version_locations option falls back to using the legacy
60+
# "version_path_separator" key, which if absent then falls back to the legacy
61+
# behavior of splitting on spaces and/or commas.
62+
# 2. Parsing of the prepend_sys_path option falls back to the legacy
63+
# behavior of splitting on spaces, commas, or colons.
64+
#
65+
# Valid values for path_separator are:
66+
#
67+
# path_separator = :
68+
# path_separator = ;
69+
# path_separator = space
70+
# path_separator = newline
71+
#
72+
# Use os.pathsep. Default configuration used for new projects.
73+
path_separator = os
74+
75+
# set to 'true' to search source files recursively
76+
# in each "version_locations" directory
77+
# new in Alembic version 1.10
78+
# recursive_version_locations = false
79+
80+
# the output encoding used when revision files
81+
# are written from script.py.mako
82+
# output_encoding = utf-8
83+
84+
# database URL. This is consumed by the user-maintained env.py script only.
85+
# other means of configuring database URLs may be customized within the env.py
86+
# file.
87+
# sqlalchemy.url = driver://user:pass@localhost/dbname
88+
# 注释掉默认 URL,我们将在 env.py 中从应用配置读取
89+
90+
91+
[post_write_hooks]
92+
# post_write_hooks defines scripts or Python functions that are run
93+
# on newly generated revision scripts. See the documentation for further
94+
# detail and examples
95+
96+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
97+
# hooks = black
98+
# black.type = console_scripts
99+
# black.entrypoint = black
100+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
101+
102+
# lint with attempts to fix using "ruff" - use the module runner, against the "ruff" module
103+
# hooks = ruff
104+
# ruff.type = module
105+
# ruff.module = ruff
106+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
107+
108+
# Alternatively, use the exec runner to execute a binary found on your PATH
109+
# hooks = ruff
110+
# ruff.type = exec
111+
# ruff.executable = ruff
112+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
113+
114+
# Logging configuration. This is also consumed by the user-maintained
115+
# env.py script only.
116+
[loggers]
117+
keys = root,sqlalchemy,alembic
118+
119+
[handlers]
120+
keys = console
121+
122+
[formatters]
123+
keys = generic
124+
125+
[logger_root]
126+
level = WARNING
127+
handlers = console
128+
qualname =
129+
130+
[logger_sqlalchemy]
131+
level = WARNING
132+
handlers =
133+
qualname = sqlalchemy.engine
134+
135+
[logger_alembic]
136+
level = INFO
137+
handlers =
138+
qualname = alembic
139+
140+
[handler_console]
141+
class = StreamHandler
142+
args = (sys.stderr,)
143+
level = NOTSET
144+
formatter = generic
145+
146+
[formatter_generic]
147+
format = %(levelname)-5.5s [%(name)s] %(message)s
148+
datefmt = %H:%M:%S
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Generic single-database configuration.

0 commit comments

Comments
 (0)