fix(HEL-199): 为补档工具补上仓库根 sys.path 引导

使 python3 tools/backfill_recent_snapshots.py --help 在干净环境下可直接运行,并同步文档运行示例为容器内执行。

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
总工
2026-08-27 15:12:42 +00:00
co-authored by Cursor multica-agent
parent 7ad445bc9f
commit 8e94c7b429
2 changed files with 9 additions and 3 deletions
+3 -3
View File
@@ -16,15 +16,15 @@
## 上线步骤(总工执行)
应用根目录
目标环境容器内执行(应用根目录;宿主机也可直接跑,脚本已自带仓库根 `sys.path` 引导)
```bash
# 1) 只读规划:区分已有、真正缺档;不会写入
python tools/backfill_recent_snapshots.py --account <管理员账号> --lookback 60 --dry-run --json
docker compose exec xiaobai-review python tools/backfill_recent_snapshots.py --account <管理员账号> --lookback 60 --dry-run --json
# 2) 正式补档:先走 SQLite backup API 写 data/backups/review-pre-recent-backfill-*.db
# 再对缺失交易日调用现有 sync_dashboard
python tools/backfill_recent_snapshots.py --account <管理员账号> --lookback 60 --json
docker compose exec xiaobai-review python tools/backfill_recent_snapshots.py --account <管理员账号> --lookback 60 --json
# 3) 验证
# GET /api/sentiment/history?trade_date=YYYY-MM-DD&limit=60
+6
View File
@@ -12,7 +12,13 @@ from __future__ import annotations
import argparse
import json
import sys
from datetime import date
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from backend.application import SERVICE
from backend.bootstrap.config import normalize_date