hub-gif 6280e436d8 feat(pipeline): JD 流水线 CSV 纯中文表头与模块目录重构
- 统一 csv_schema 与搜索/合并/评价/商详导出为纯中文列名,入库与视图按中文表头解析

- 竞品分析报告兼容新旧表头;新增 csv_header_rewrite 与 rewrite_pipeline_csv_headers 管理命令

- 调整 pipeline 至 jd、llm、reporting、demos 子包并更新任务与测试引用

- 新增购买者优惠摘要抽取、合并表 regen/ingest 命令、0016 迁移及相关测试

Made-with: Cursor
2026-04-15 16:02:29 +08:00

34 lines
1.3 KiB
Python
Raw Permalink 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.

# -*- coding: utf-8 -*-
"""补全并规范化已有 run 目录下的 ``keyword_pipeline_merged.csv``lean 列序,与 detail_ware 对齐)。"""
from __future__ import annotations
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from pipeline.ingest import resolve_and_validate_run_dir
from pipeline.jd.merged_regen import write_keyword_pipeline_merged_lean_csv
class Command(BaseCommand):
help = "将 keyword_pipeline_merged.csv 重写为 lean 宽表列序,并刷新榜单/购买者摘要列。"
def add_arguments(self, parser) -> None:
parser.add_argument(
"--run-dir",
type=str,
required=True,
help="相对 data/JD 的子路径,或位于 data/JD 下的绝对路径",
)
def handle(self, *args, **options):
if not (settings.LOW_GI_PROJECT_ROOT or "").strip():
raise CommandError("请在 .env 中配置 LOW_GI_PROJECT_ROOT")
raw = str(options["run_dir"] or "").strip()
try:
run_path = resolve_and_validate_run_dir(raw)
except ValueError as e:
raise CommandError(str(e)) from e
n, p = write_keyword_pipeline_merged_lean_csv(run_path)
self.stdout.write(self.style.SUCCESS(f"已写 {n} 行 -> {p}"))