f4b415c54f
web-platform-ci / TypeScript、Lint、Unit、Build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled
web-platform-ci / TypeScript、Lint、Unit、Build (pull_request) Has been cancelled
web-platform-ci / Playwright E2E (pull_request) Has been cancelled
本地强化学习训练服务
该服务把 Web 平台发出的受限训练请求转换为本机 unitree_rl_mjlab/scripts/train.py 子进程,并提供状态轮询、停止任务和 policy.onnx 下载接口。服务只绑定 127.0.0.1,不执行前端传入的任意命令。
启动
必须使用已经安装 mjlab、PyTorch 和训练工程依赖的 Python 解释器:
npm run training-server -- \
--trainer-root /path/to/unitree_rl_mjlab \
--trainer-python /path/to/training-env/bin/python
如:
npm run training-server -- --trainer-root /home/cen/Embodied_Workspace/unitree_rl_mjlab --trainer-python /home/cen/miniconda3/envs/unitree_rl_mjlab/bin/python
也可用 UNITREE_RL_MJLAB_ROOT 指定工程目录。默认端口是 8765。如果前端不是从 localhost 或 127.0.0.1 提供,可显式添加来源:
python training_server/server.py \
--trainer-root /path/to/unitree_rl_mjlab \
--allow-origin http://192.168.1.10:5173
服务一次只运行一个训练任务。停止服务或在界面点击“停止训练”会向整个训练进程组发送终止信号。训练请求的 W&B 模式默认为 offline,保留本地指标但不登录;也可以在界面选择完全禁用或在线模式。
接口
GET /api/training/health:运行环境、允许的任务和活动任务;POST /api/training/jobs:发起训练;GET /api/training/jobs/{id}:状态、迭代进度和最近日志;DELETE /api/training/jobs/{id}:停止训练;GET /api/training/jobs/{id}/artifacts/policy.onnx:下载本次生成的策略。
任务保存在服务内存中,服务重启后历史任务状态会丢失,但 mjlab 日志和 checkpoint 仍保留在训练工程中。
测试
npm run test:training-server