Conversation
refactor(后端): 扩展用户模型和API响应字段 style(导航): 优化用户头像和下拉菜单样式 docs: 添加用户头像功能相关文档 test(实验): 增强表单验证和错误处理
- 添加用户模型完整字段(email, full_name, role等) - 实现用户权限系统(admin, developer, viewer) - 开发后台管理页面,支持用户增删改查 - 优化登录页面和表单验证 - 移除Profit-Loss页面 - 更新数据库结构和初始化脚本 - 添加权限控制路由和API - 优化实验运行日志和性能计算 - 修复YAML编辑器性能问题 - 更新前端路由和导航菜单
feat(frontend): 实现benchmark样例选择功能 feat(experiment): 增强实验状态跟踪功能,添加进度、开始/结束时间字段 refactor(frontend): 国际化调整,将界面文本改为中文 feat(navigation): 添加用户管理链接入口 perf(task): 优化任务执行逻辑,添加进度更新 docs: 添加实现计划文档
重构实验运行流程,从直接后台运行改为任务队列方式 - 新增Task模型和服务类,用于管理实验任务 - 实现任务工作器,处理待执行任务 - 修改实验运行API,改为创建任务 - 前端添加benchmark选择功能
- 添加用户角色管理功能,确保admin用户具有管理员权限 - 修改用户头像点击行为,管理员直接跳转管理页面 - 优化select元素样式解决可见性问题 - 在登录后存储用户信息到localStorage - 添加实验管理页面的权限控制 - 更新相关文档和修复计划
添加reset_task.py用于重置任务和实验状态 在train.py中导入sqlalchemy的func函数
- 添加因子管理相关API、模型和前端页面 - 实现数据管理功能,包括股票数据模型和API - 更新前端导航栏添加因子管理和数据管理入口 - 修复实验日志功能,支持实时查看运行日志 - 优化用户认证和权限控制逻辑 - 添加QLib服务集成支持 - 更新数据库初始化脚本和文档
添加实验列表按创建时间排序功能,支持卡片和列表两种显示样式切换 修改时间戳转换格式,移除时区信息并简化为日期格式
refactor(实验列表): 优化布局和样式,增加卡片/列表视图切换功能 feat(因子服务): 添加Qlib因子服务获取实际因子定义 fix(数据库): 移除因子名称唯一约束,更新数据库结构 chore: 添加相关文档和计划文件
- 添加react-select依赖 - 修改vite配置中的代理目标端口 - 更新package.json文件
- 后端添加实验状态立即更新为pending的功能 - 启动任务执行器以处理待运行实验 - 添加GPU支持并优化模型训练性能 - 扩展回测结果数据,包括月度收益、回撤曲线等指标 - 前端优化实验状态实时更新和日志显示频率 - 改进回测结果展示,添加多种图表和详细指标
重构后端架构,移除主应用中的任务处理逻辑,改为独立的训练节点服务 添加训练节点实现,从数据库获取任务并执行训练 添加前后端解耦方案文档和部署计划文档
refactor(frontend): 调整全局样式使界面更紧凑 docs: 添加前后端联调测试计划和样式调整计划文档 build: 添加python-dotenv和httpx依赖 style: 更新日志导入路径
refactor(数据库): 迁移SQLite到MySQL,更新数据库连接配置 fix(日志): 解决日志频繁刷新问题,优化日志存储和查询 feat(任务管理): 添加任务重试机制和状态管理功能 docs: 更新相关文档,包括联调测试计划和优化方案 style: 统一代码格式,修复代码分析警告 test: 添加多种测试脚本,包括远程连接和API测试
refactor(backend): 重构监控和训练服务以增强稳定性 fix(backend): 修复benchmark服务目录不存在时的处理 test: 添加benchmark服务测试脚本 docs: 添加全面测试报告文档 style: 优化日志格式和错误处理 chore: 更新supervisor配置和nginx路径
refactor: 重构系统监控服务以支持服务状态检查 feat(frontend): 新增风险管理和回测页面 style: 更新前端样式以支持新功能 docs: 添加服务状态监控相关文档 test: 添加服务状态监控测试用例 chore: 更新依赖和配置文件
添加 email_verified、verification_token 和 verification_token_expiry 字段以支持邮箱验证功能
fix: 修复基准目录路径问题 refactor: 重构用户认证服务 chore: 更新依赖版本 docs: 添加测试脚本和说明
refactor: 将直接使用axios改为使用axios实例 style(导航): 添加下拉菜单样式和交互逻辑 fix(后端): 修复任务创建时实验状态更新问题
refactor: 重构主API路由分离训练相关端点 style: 更新前端服务状态显示样式 test: 添加训练服务器连接及API测试脚本 chore: 添加训练服务器启动脚本及supervisor配置
…ster train/tasks routes, CORS fix, data import script, automated test script, startup scripts Agent-Logs-Url: https://github.com/zhostev/qlib_t/sessions/510c756a-7ce2-43da-a2b9-b6dcaece6b59 Co-authored-by: zhostev <57177476+zhostev@users.noreply.github.com>
…et key generation, test assertions Agent-Logs-Url: https://github.com/zhostev/qlib_t/sessions/510c756a-7ce2-43da-a2b9-b6dcaece6b59 Co-authored-by: zhostev <57177476+zhostev@users.noreply.github.com>
Add integration testing infrastructure, data import, and dev startup scripts
|
@zhostev please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
This PR appears to introduce a full-stack “QLib AI” management platform setup, including a new Vite/React frontend, Docker-based deployment, and a large backend surface area (auth, tasks, monitoring, QLib integration, benchmarks, and various DB/scripts).
Changes:
- Added Docker assets (compose + backend/frontend Dockerfiles) and Nginx config for serving the frontend and proxying
/api. - Implemented/added substantial backend modules: auth, experiments/tasks APIs, monitoring, remote training client, QLib helpers, schemas/models.
- Added various operational/debug scripts and test reports for environment validation, DB fixes, and manual testing.
Reviewed changes
Copilot reviewed 125 out of 7606 changed files in this pull request and generated 24 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/nginx.conf | Adds Nginx server block to serve SPA and proxy /api. |
| frontend/index.html | Adds Vite/React HTML entrypoint. |
| frontend/eslint.config.js | Adds ESLint flat config for TS/React. |
| frontend/README.md | Adds Vite template README. |
| docker/init.sql | Seeds DB with admin user + initial config template. |
| docker/frontend.Dockerfile | Builds + serves frontend via serve. |
| docker/docker-compose.yml | Adds compose stack for backend/worker/frontend/mysql. |
| docker/backend.Dockerfile | Builds backend image including local QLib build. |
| collect_benchmark_configs.py | Script to collect benchmark YAML configs. |
| backend_supervisor_train.conf | Supervisor config for training server. |
| backend_supervisor.conf | Supervisor config for backend server. |
| backend/update_tasks_table.py | Script to alter tasks table to add retry columns. |
| backend/update_experiment_config.py | Script to normalize timestamps inside experiment configs (sqlite). |
| backend/update_db_schema.py | Script to drop/recreate factors indexes. |
| backend/update_admin_password.py | Script to update admin password in a remote MySQL DB. |
| backend/test_websocket.py | Manual WebSocket communication test script. |
| backend/test_training_api.py | Manual training API test script. |
| backend/test_run_experiment.py | Manual script to create/run a task for an experiment. |
| backend/test_remote_server.py | Manual script to test remote server health/status. |
| backend/test_remote_client.py | Manual script to test RemoteClient behaviors. |
| backend/test_qlib_service.py | Manual script to test QLibService and stock data fetching. |
| backend/test_performance_calc.py | Manual script to validate performance calculation logic. |
| backend/test_local_websocket.py | Manual local WebSocket test script. |
| backend/test_full_flow.sh | Shell script to run an end-to-end flow via API calls. |
| backend/test_db_connection.py | Script to test DB connectivity using DATABASE_URL. |
| backend/test_benchmark_service.py | Script to debug benchmark directory scanning. |
| backend/test_benchmark_fix.py | Script to verify benchmark service behavior under missing dirs. |
| backend/test_benchmark_dir_fixed.py | Script to validate benchmark dir path calculation. |
| backend/test_benchmark_dir.py | Script to validate benchmark dir path calculation. |
| backend/supervisor_train_worker.conf | Supervisor config for training worker process. |
| backend/supervisor_monitoring.conf | Supervisor config for monitoring process. |
| backend/start_worker.sh | Startup script for task worker module. |
| backend/start_train_server.sh | Startup script for training server via uvicorn. |
| backend/run_monitoring.py | Monitoring loop runner with detailed logging. |
| backend/reset_task.py | Script to reset a task/experiment status to pending. |
| backend/reset_factors.py | Script to delete factors and reset factor_group counts. |
| backend/reset_experiment_status.py | Script to reset an experiment status and create a new task. |
| backend/reset_db.py | Script to drop and recreate DB tables. |
| backend/reset_admin_password.py | Script to reset admin password using DATABASE_URL. |
| backend/requirements.txt | Adds backend Python dependencies. |
| backend/qlib_ai_api.logrotate | Logrotate config for uvicorn log. |
| backend/init_db.py | DB initialization script with factor + stock data seeding. |
| backend/fix_user_table.py | Script to alter remote users table schema + create admin. |
| backend/fix_tasks_table.py | Script to alter tasks table columns based on parsed DATABASE_URL. |
| backend/fix_experiment_config.py | Script to fix experiment config JSON and remove invalid params. |
| backend/fix_admin_user.py | Script to create/fix admin user using app services. |
| backend/create_ultimate_test_experiment.py | Script to create a test experiment + task. |
| backend/create_test_experiment.py | Script to create a test experiment. |
| backend/create_task_for_experiment.py | Script to create a task for an existing experiment. |
| backend/create_simple_experiment.py | Script to create a simplified experiment + task. |
| backend/create_log_table.py | Script to create all tables including experiment log table. |
| backend/create_fixed_experiment.py | Script to create a “fixed” experiment + task. |
| backend/create_final_test_experiment.py | Script to create a final test experiment + task. |
| backend/create_admin.py | Script to create/update admin user. |
| backend/check_users.py | Script to list users from a remote MySQL DB. |
| backend/check_ultimate_experiment.py | Script to inspect experiment performance payload shape. |
| backend/check_tables.py | Script to inspect DB tables and tasks schema. |
| backend/check_performance.py | Script to inspect performance field on an experiment. |
| backend/check_final_experiment.py | Script to inspect final experiment results. |
| backend/check_factors.py | Script to inspect factor counts by group. |
| backend/check_experiments.py | Script to list experiments and performance keys. |
| backend/check_experiment_logs.py | Script to print experiment logs (legacy). |
| backend/check_experiment_config.py | Script to dump experiment config. |
| backend/check_experiment_9.py | Script to inspect experiment 9 results. |
| backend/check_experiment_8.py | Script to inspect experiment 8 status and recent logs. |
| backend/check_experiment_7.py | Script to inspect experiment 7 status and logs. |
| backend/check_existing_config.py | Script to inspect config structure for an experiment. |
| backend/check_db.py | Script to validate DB and basic table queries. |
| backend/app/yaml/parser.py | Adds YAML parsing/generation/validation helpers. |
| backend/app/utils/remote_client.py | Adds async remote training server client (HTTP + WS). |
| backend/app/utils/queue.py | Adds DB-backed task queue helper + processor. |
| backend/app/utils/config_validation.py | Adds environment/DB/training-server validation functions. |
| backend/app/tasks/task_worker.py | Adds async task worker for processing pending tasks. |
| backend/app/services/training_client.py | Adds httpx-based client to trigger training via API. |
| backend/app/services/task.py | Adds TaskService including retry handling + status updates. |
| backend/app/services/qlib_service.py | Adds QLibService with instrument + stock data helpers. |
| backend/app/services/qlib_factor.py | Adds QlibFactorService to fetch factor definitions. |
| backend/app/services/monitoring.py | Adds system monitoring using psutil + remote checks. |
| backend/app/services/model_version.py | Adds CRUD-ish model version service functions. |
| backend/app/services/factor.py | Adds factor + factor group service functions. |
| backend/app/services/experiment.py | Adds experiment CRUD with timestamp conversion. |
| backend/app/services/email_service.py | Adds SMTP email verification + password reset flow. |
| backend/app/services/data.py | Adds stock data CRUD + QLib refresh + alignment logic. |
| backend/app/services/config.py | Adds config CRUD. |
| backend/app/services/benchmark.py | Adds benchmark discovery under benchmarks directory. |
| backend/app/services/auth.py | Adds authentication helpers + password hashing. |
| backend/app/services/analysis.py | Adds analysis data generation (mock/derived). |
| backend/app/schemas/model_version.py | Adds pydantic schemas for model versions. |
| backend/app/schemas/factor.py | Adds pydantic schemas for factors/factor groups. |
| backend/app/schemas/experiment.py | Adds pydantic schemas for experiments. |
| backend/app/schemas/data.py | Adds pydantic schemas for stock data. |
| backend/app/schemas/config.py | Adds pydantic schemas for configs. |
| backend/app/schemas/auth.py | Adds pydantic schemas for auth/user. |
| backend/app/models/user.py | Adds SQLAlchemy User model with verification/reset fields. |
| backend/app/models/task.py | Adds SQLAlchemy Task model with retry fields. |
| backend/app/models/stock_data.py | Adds SQLAlchemy StockData model. |
| backend/app/models/model_version.py | Adds SQLAlchemy ModelVersion model. |
| backend/app/models/log.py | Adds SQLAlchemy ExperimentLog model. |
| backend/app/models/factor.py | Adds SQLAlchemy Factor/FactorGroup models. |
| backend/app/models/experiment.py | Adds SQLAlchemy Experiment model + ExperimentLog relationship. |
| backend/app/models/config.py | Adds SQLAlchemy Config model + ConfigType enum. |
| backend/app/db/database.py | Adds SQLAlchemy engine/session setup and get_db dependency. |
| backend/app/config.py | Adds Settings object w/ DB, security, training server, SMTP, CORS. |
| backend/app/api/train.py | Adds train task manager endpoints + WS updates (simulated training). |
| backend/app/api/tasks.py | Adds task listing/detail + cancel/retry endpoints. |
| backend/app/api/monitoring.py | Adds monitoring endpoints incl. health + service status. |
| backend/app/api/models.py | Adds model-version endpoints. |
| backend/app/api/factors.py | Adds factor + factor-group endpoints. |
| backend/app/api/experiments.py | Adds experiments endpoints + run + logs + analysis endpoints. |
| backend/app/api/deps.py | Adds auth dependencies / role guards for routes. |
| backend/app/api/data.py | Adds stock data endpoints + QLib instruments/features + align endpoint. |
| backend/app/api/configs.py | Adds config endpoints with YAML validation. |
| backend/app/api/benchmarks.py | Adds benchmark endpoints. |
| backend/app/api/auth.py | Adds auth endpoints: token/login + user admin CRUD + register/verify/reset. |
| backend/app/api/init.py | Registers API routers under the main API router. |
| backend/add_missing_columns.py | Script to alter tasks table columns. |
| backend/TEST_REPORT.md | Adds integration test report doc. |
| backend/COMPREHENSIVE_TEST_REPORT.md | Adds comprehensive integration/test report doc. |
| .trae/documents/增加用户信息头像到右上角.md | Adds design/notes doc for user avatar UI. |
| .trae/documents/优化用户头像和显示层面.md | Adds design/notes doc for user avatar UI refinement. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from fastapi.security import OAuth2PasswordBearer | ||
| from jose import JWTError, jwt | ||
| from sqlalchemy.orm import Session | ||
| from app.db.database import get_db, settings |
There was a problem hiding this comment.
app.db.database (as added in this PR) defines engine/SessionLocal/Base/get_db but does not define settings, so this import will raise ImportError and prevent the API from starting. Fix by importing settings from app.config instead (and update other files with the same pattern, e.g. app/api/auth.py and app/services/email_service.py).
| from app.db.database import get_db, settings | |
| from app.db.database import get_db | |
| from app.config import settings |
| import secrets | ||
| from sqlalchemy.orm import Session | ||
| from app.models.user import User | ||
| from app.db.database import settings |
There was a problem hiding this comment.
Same issue as deps.py: settings is defined in app.config, not app.db.database. This will crash imports at runtime; switch to from app.config import settings (and keep DB-related imports in app.db.database).
| from app.db.database import settings | |
| from app.config import settings |
| r"mysql://", | ||
| r"mysql\+pymysql://", | ||
| r"postgresql://", | ||
| r"postgresql\+psycopg2://", | ||
| r"sqlite://" |
There was a problem hiding this comment.
DATABASE_URL validation is currently incorrect for URLs like mysql+pymysql://... and postgresql+psycopg2://... because the patterns contain backslashes (regex-escaped) but you perform a plain substring check. Replace DB_URL_PATTERNS with literal prefixes (no escaping) or actually use regex matching via re.search.
| r"mysql://", | |
| r"mysql\+pymysql://", | |
| r"postgresql://", | |
| r"postgresql\+psycopg2://", | |
| r"sqlite://" | |
| "mysql://", | |
| "mysql+pymysql://", | |
| "postgresql://", | |
| "postgresql+psycopg2://", | |
| "sqlite://" |
| db_url = os.environ["DATABASE_URL"] | ||
| valid_db_url = any(pattern in db_url for pattern in ConfigValidator.DB_URL_PATTERNS) |
There was a problem hiding this comment.
DATABASE_URL validation is currently incorrect for URLs like mysql+pymysql://... and postgresql+psycopg2://... because the patterns contain backslashes (regex-escaped) but you perform a plain substring check. Replace DB_URL_PATTERNS with literal prefixes (no escaping) or actually use regex matching via re.search.
| def authenticate_user(db: Session, username: str, password: str): | ||
| # For development purposes, allow admin user with fixed password | ||
| if username == "admin" and password == "admin123": |
There was a problem hiding this comment.
This introduces a hard-coded authentication backdoor for the admin account. This must be removed or strictly gated behind an explicit development-only feature flag (e.g., an env var that defaults to disabled) to avoid shipping an account takeover vector.
| @@ -0,0 +1,7 @@ | |||
| -- 创建管理员用户 | |||
| INSERT INTO users (username, password_hash, created_at, updated_at) | |||
| VALUES ('admin', '$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW', NOW(), NOW()); | |||
There was a problem hiding this comment.
This seeds a globally known admin username with a precomputed bcrypt hash, while app/services/auth.py uses pbkdf2_sha256 only. Besides being a security risk (predictable seeded admin), it will also cause authentication inconsistencies. Seed users via the same hash scheme as the application (and avoid shipping default admin credentials in production; require setting via env/one-time bootstrap).
| VALUES ('admin', '$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW', NOW(), NOW()); | |
| VALUES ('admin', NULL, NOW(), NOW()); |
| database_url = os.getenv("DATABASE_URL", "sqlite:///./test.db") | ||
|
|
||
| # Security settings | ||
| secret_key = os.getenv("SECRET_KEY", "your-secret-key-here") |
There was a problem hiding this comment.
Security-sensitive defaults are committed (fallback SECRET_KEY and SMTP credentials). In production, these should not have hard-coded fallbacks; require env vars (fail fast on missing), and remove any real credentials from the codebase (rotate the exposed SMTP password).
| smtp_username = os.getenv("SMTP_USERNAME", "qlib@uszho.com") | ||
| smtp_password = os.getenv("SMTP_PASSWORD", "Moshou99") |
There was a problem hiding this comment.
Security-sensitive defaults are committed (fallback SECRET_KEY and SMTP credentials). In production, these should not have hard-coded fallbacks; require env vars (fail fast on missing), and remove any real credentials from the codebase (rotate the exposed SMTP password).
| - DATABASE_URL=mysql+pymysql://user:password@mysql:3306/qlib_management | ||
| - SECRET_KEY=your-secret-key-here |
There was a problem hiding this comment.
Compose file contains default credentials and SECRET_KEY. Even for dev, this pattern often gets promoted to production accidentally. Prefer using an .env file (not committed) or compose secrets: / environment overrides, and ensure production deployments require non-default values.
| @@ -0,0 +1,182 @@ | |||
| # QLib分布式管理平台 - 全面联调与测试报告 | |||
There was a problem hiding this comment.
The PR title (\"烦烦烦\") and the PR description template are not filled in (no summary/motivation/testing), but the diff introduces major product + infrastructure changes. Please update the PR title to a conventional-commit style summary and fill in Description/Motivation/Testing so reviewers can validate intent and scope.
Description
Motivation and Context
How Has This Been Tested?
pytest qlib/tests/test_all_pipeline.pyunder upper directory ofqlib.Screenshots of Test Results (if appropriate):
Types of changes