#!/usr/bin/env python3
"""单独执行 category_tree_weight 四维排名归一化打分。

用法:
    python jobs/run_category_tree_rank_scores.py 20260714
    python jobs/run_category_tree_rank_scores.py          # 默认当天

前置: 指定 biz_dt 的 category_tree_weight 已全部写入（可先跑 run_category_tree_weight.py）。
"""

from __future__ import annotations

import logging
import sys
from datetime import datetime

from supply_infra.scheduler.jobs.update_category_tree_rank_scores import (
    update_category_tree_rank_scores,
)

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)


def main(biz_dt: str | None = None) -> dict:
    if biz_dt is None:
        biz_dt = datetime.now().strftime("%Y%m%d")
    result = update_category_tree_rank_scores(biz_dt)
    print(result)
    return result


if __name__ == "__main__":
    date_arg = sys.argv[1] if len(sys.argv) > 1 else None
    main(date_arg)
