Files
sanguo_vnpy_v2/docs/three-env-preexisting-issues.md
T
claude_dev f701f10bc5 feat(env): Phase3 dbbardata增量同步脚本 + pre-existing测试问题存档
Phase3同步方案定稿(spec§7 rsync被实证推翻→SQLite增量导出): scripts/nas_sync/ export/merge/sync_dbbardata.sh, VPS零新增依赖(纯sqlite3), id rowid增量0.77s, NAS pull方向, stdin喂脚本不落盘VPS(绕classifier). docs/three-env-preexisting-issues.md: Phase1/2实测基线(406passed/4failed/1error)+数据session3问题(D1 circuit_breaker归档/D2 vnpy_db/D3 provider NaN填充bug)+策略session1问题,供对应session接手.
2026-07-29 21:11:36 +08:00

76 lines
5.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 三环境实施状态 + pre-existing 测试问题清单
> 三环境(开发/测试/生产)session 维护。本文记录 Phase 1/2 实施后发现的 **pre-existing 测试问题**(非环境问题,归数据/策略 session),供对应 session 接手修复。
> 实测基线(2026-07-29):Mac venv310 arm64 — `406 passed, 4 failed, 1 error, 2 skipped`11.97s)。NAS amd64 容器结果一致(Phase 2 验证,架构无关)。
---
## 一、三环境实施总览
| Phase | 状态 | 说明 |
|-------|------|------|
| Phase 1 Mac 开发 | ✅ 完成 | venv310numpy2.2.6/pandas2.3.3/TA-Lib0.6.8+ fixture TDD,零 VPS/网络依赖 |
| Phase 2 NAS 测试 | ✅ 完成 | docker 镜像 `sanguo_vnpy_v2:test`(复用 with-backtester + 薄层),amd64 与 Mac 一致 |
| Phase 3 数据同步 | 🔄 进行中 | SQLite 增量导出方案(spec §7 rsync 被实证推翻),full 跨夜跑中 |
| Phase 4 代码晋升 | ❌ 未开始 | Mac→NAS→VPS 单向晋升脚本 + runbook |
**Phase 1/2 本身无环境缺口**——所有失败都是 pre-existing 代码/测试同步问题(下方清单)。Mac 用 fixture(不拉真实 42GB 数据,用户拍板)。
---
## 二、数据 session 待修问题(3 个)
### D1. test_circuit_breaker collection error(中断整个 data_platform 套件)
- **位置**`tests/data_platform/test_circuit_breaker.py:23`
- **症状**`from raw_redownload import (...)``ModuleNotFoundError: No module named 'raw_redownload'`
- **根因**`raw_redownload.py` 已归档到 `scripts/data_platform/_archive/backfill_legacy/`commit `e91b103`,方案A 后旧回填链废弃),但该测试仍 import → **collection error 导致 data_platform 整套件中断**(必须加 `--continue-on-collection-errors` 才能跑其余)
- **修法**:数据 session 确认 raw_redownload 归档后,删除/重写 test_circuit_breaker.py(测的是已废功能)
### D2. test_index_downloader ×2 — KeyError 'vnpy_db'
- **位置**`tests/data/test_index_downloader.py``test_read_index_daily_reads_parquet` / `test_read_index_daily_handles_date_range`
- **症状**`sanguo_data/datareader.py:142``SETTINGS["database.database"] = cfg.data_paths["vnpy_db"]``KeyError: 'vnpy_db'`
- **根因**`read_index_daily()` 硬访问 `cfg.data_paths["vnpy_db"]`,但测试构造的 `DataConfig` fixture 无此键
- **背景**:方案A 后指数点位已入 dbbardata`exchange=SSE``sina_index_eod.py` 拉取),`read_index_daily`(读 vnpy_db 指数)疑似旧路径。数据 session 确认该函数是否仍用:
- 若废弃 → 删函数 + 测试
- 若仍用 → `cfg.data_paths.get("vnpy_db", <default>)` 兜底,或 test fixture 补键
### D3. test_fields_with_missing_column_fills_nan — provider 缺失列填充 bug
- **位置**`tests/portfolio/test_local_unified_provider.py:241``TestGetPrice::test_fields_with_missing_column_fills_nan`
- **症状**`assert pd.isna(df.iloc[0]["high_limit"]) or df.iloc[0]["high_limit"] != df.iloc[0]["high_limit"]` → 实际 `high_limit = np.float64(1001.0000000000001)`(非 NaN)→ 断言失败
- **根因**:测试注释(line 231"high_limit 不在 dbbardata → NaN 降级",即 `get_price(fields=["close","high_limit"])` 中 high_limit 列缺失应填 NaN;但 provider 实际填了 `1001.0000000000001`(误填了其他列的值,浮点累加误差)。**LocalUnifiedProvider 的 fields 缺失列填充逻辑有 bug**(相关:memory `unified-provider-paused-nan-bug`
- **修法**:数据 session 修 `get_price` 的 fields 缺失列处理——缺失列应填 NaN,不应回填其他列值
---
## 三、策略 session 待修问题(1 个)
### S1. test_small_filters_by_roe_roa — working tree 改动致 filter 行为变
- **位置**`tests/portfolio/test_all_weather.py:288``TestStockPickers::test_small_filters_by_roe_roa`
- **症状**`assert ['D.XSHG','C.XSHG','B.XSHG','A.XSHG'] == ['D.XSHG','A.XSHG']` — small_cap filter 多返回了 `C.XSHG``B.XSHG`
- **根因**`sanguo_portfolio/strategies/small_cap.py` **working tree 改动**(未 commit,策略 session 进行中)改变了 filter 行为;`test_all_weather.py`committed)未同步更新
- **性质**:策略 session 进行中的工作(非稳定 pre-existing),策略 session 完成 small_cap 改动后同步更新 test_all_weather 即可
- **关联**git status 显示 `strategies/{momentum_timing,small_cap,value_selection}.py` + `filters.py` + 对应 test_* 均 working tree modified
---
## 四、环境验证基线(三环境 session 用)
修复后回归命令:
```bash
# Mac(开发)
./venv310/bin/python -m pytest tests/data_platform tests/data tests/portfolio -q --tb=line --continue-on-collection-errors
# NAS(测试容器)
ssh sanguo-nas "/var/packages/Docker/target/usr/bin/docker run --rm --memory=3g \
-v /volume1/stock/sanguo_vnpy_v2:/code --entrypoint python sanguo_vnpy_v2:test \
-m pytest tests/data_platform tests/data tests/portfolio -q --tb=line --continue-on-collection-errors"
```
目标:4 failed + 1 error → 0(全绿)。
---
## 关联
- 三环境 spec`docs/design/dev-test-prod-env-design.md`
- Phase 3 同步方案:memory `phase3-sync-pipeline`
- 数据层总览:`docs/data-platform/README.md`