You've already forked DataMate
* fix(chart): update Helm chart helpers and values for improved configuration * feat(SynthesisTaskTab): enhance task table with tooltip support and improved column widths * feat(CreateTask, SynthFileTask): improve task creation and detail view with enhanced payload handling and UI updates * feat(SynthFileTask): enhance file display with progress tracking and delete action * feat(SynthFileTask): enhance file display with progress tracking and delete action * feat(SynthDataDetail): add delete action for chunks with confirmation prompt * feat(SynthDataDetail): update edit and delete buttons to icon-only format * feat(SynthDataDetail): add confirmation modals for chunk and synthesis data deletion * feat(DocumentSplitter): add enhanced document splitting functionality with CJK support and metadata detection * feat(DataSynthesis): refactor data synthesis models and update task handling logic * feat(DataSynthesis): streamline synthesis task handling and enhance chunk processing logic * feat(DataSynthesis): refactor data synthesis models and update task handling logic * fix(generation_service): ensure processed chunks are incremented regardless of question generation success * feat(CreateTask): enhance task creation with new synthesis templates and improved configuration options * feat(CreateTask): enhance task creation with new synthesis templates and improved configuration options * feat(CreateTask): enhance task creation with new synthesis templates and improved configuration options * feat(CreateTask): enhance task creation with new synthesis templates and improved configuration options * feat(model_chat): enhance JSON parsing by removing additional thought tags and improving fallback logic * feat(generation_service): add document filtering to remove short documents based on chunk size
DataMate Python Service (DataMate)
这是 DataMate 的 Python 服务,负责DataMate的数据合成、数据标注、数据评估等功能。
简要说明
- 框架:FastAPI
- 异步数据库/ORM:SQLAlchemy (async)
- 数据库迁移:Alembic
- 运行器:uvicorn
快速开始(开发)
前置条件
- Python 3.11+
- poetry 包管理器
- 克隆仓库
git clone git@github.com:ModelEngine-Group/DataMate.git
- 进入项目目录
cd runtime/datamate-python
- 安装依赖 由于项目使用poetry管理依赖,你可以使用以下命令安装::
poetry install
或者直接使用pip安装(如果poetry不可用):
pip install -e .
- 配置环境变量 复制环境变量示例文件并配置:
cp .env.example .env
编辑.env文件,设置必要的环境变量,如数据库连接、Label Studio配置等。
- 数据库迁移(开发环境):
alembic upgrade head
- 启动开发服务器(示例与常用参数):
- 本地开发(默认 host/port,自动重载):
set -a && source .env && set +a && poetry run uvicorn app.main:app --port 18000 --log-level debug --reload
或者
poetry run python -m app.main
- 指定主机与端口并打开调试日志:
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload --log-level debug
- 在生产环境使用多个 worker(不使用 --reload):
uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4 --log-level info --proxy-headers
- 使用环境变量启动(示例):
HOST=0.0.0.0 PORT=8000 uvicorn app.main:app --reload
注意:
--reload仅用于开发,会监视文件变化并重启进程;不要在生产中使用。--workers提供并发处理能力,但会增加内存占用;生产时通常配合进程管理或容器编排(Kubernetes)使用。- 若需要完整的生产部署建议使用 ASGI 服务器(如 gunicorn + uvicorn workers / 或直接使用 uvicorn 在容器中配合进程管理)。
访问 API 文档:
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc (推荐使用)
开发新功能
- 安装开发依赖:
poetry add xxx
使用(简要)
- 所有 API 路径以
/api前缀注册(见app/main.py中app.include_router(api_router, prefix="/api"))。 - 根路径
/返回服务信息和文档链接。
更多细节请查看 doc/usage.md(接口使用)和 doc/development.md(开发说明)。