- 新增 report_db/ 包(models/schema/db,复用 news 项目实现,幂等 upsert) - reporter.py: _build_report_data + generate_report 写库返回 report_id - pipeline/cli 适配 report_id 返回值;HTML 渲染/上传保留 deprecated - 新增 tests/test_report_db.py;.env.example 增加 NEWS_DB_* 配置 - 已部署 pi5 并验证:真实生成 report_id=184(12 事件)+ 幂等覆盖
69 lines
2.2 KiB
Bash
Executable File
69 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# =============================================
|
|
# 国内服务器:全链路管道 M2 → M3 → M4 → M5 → M6 → 日报
|
|
# =============================================
|
|
# 用法:./scripts/pipeline.sh
|
|
# 前提:domestic_sync.sh 已完成
|
|
# =============================================
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
|
|
cd "$PROJECT_DIR"
|
|
|
|
echo "[$(date)] ═══ 全链路管道开始 ═══"
|
|
|
|
# 加载 .env
|
|
export $(grep -v '^#' .env | grep -v '^$' | xargs 2>/dev/null || true)
|
|
|
|
# ── M2: 正文提取 ──
|
|
echo "[$(date)] [M2] 正文提取..."
|
|
.venv/bin/python3 -c "
|
|
from extractor.pipeline import process_all_sources
|
|
stats = process_all_sources()
|
|
print(f'M2: {stats[\"total_articles\"]} 篇, {stats[\"elapsed_sec\"]:.0f}s')
|
|
"
|
|
|
|
# ── M3: 去重 ──
|
|
echo "[$(date)] [M3] 三层去重..."
|
|
.venv/bin/python3 -c "
|
|
from dedup.pipeline import dedup_all_sources
|
|
stats = dedup_all_sources()
|
|
print(f'M3: 唯一 {stats[\"unique\"]}/重复 {stats[\"duplicate\"]}, {stats[\"elapsed_sec\"]:.0f}s')
|
|
"
|
|
|
|
# ── M4: 翻译+事件 ──
|
|
echo "[$(date)] [M4] 翻译+事件抽取..."
|
|
.venv/bin/python3 -c "
|
|
from llm.pipeline import translate_all_deduped
|
|
stats = translate_all_deduped()
|
|
print(f'M4: {stats[\"success\"]}/{stats[\"total\"]} 篇, {stats[\"elapsed_sec\"]:.0f}s')
|
|
"
|
|
|
|
# ── M5: 向量生成 ──
|
|
echo "[$(date)] [M5] 向量生成..."
|
|
.venv/bin/python3 -c "
|
|
from embedding.pipeline import embed_all_events
|
|
stats = embed_all_events()
|
|
print(f'M5: {stats[\"success\"]}/{stats[\"total\"]} 篇, {stats[\"elapsed_sec\"]:.0f}s')
|
|
"
|
|
|
|
# ── M6: Qdrant 入库 ──
|
|
echo "[$(date)] [M6] Qdrant 入库..."
|
|
.venv/bin/python3 -c "
|
|
from vectorstore.pipeline import ingest_all_embeddings
|
|
stats = ingest_all_embeddings()
|
|
print(f'M6: {stats[\"ingested\"]}/{stats[\"total\"]} 条, {stats[\"elapsed_sec\"]:.0f}s')
|
|
"
|
|
|
|
# ── 日报 ──
|
|
echo "[$(date)] [日报] 生成日报(结构化入库)..."
|
|
.venv/bin/python3 -c "
|
|
from scheduler.reporter import generate_report
|
|
report_id = generate_report()
|
|
print(f'日报: report_id={report_id}' if report_id is not None else '日报: 无数据/失败')
|
|
"
|
|
|
|
echo "[$(date)] ═══ 全链路管道完成 ✅ ═══"
|