#!/usr/bin/env python3
"""手动执行树热度驱动的需求分级。

统筹规划 Agent 先落库当天全量节点组计划，再由多个 worker 领取任务并调用分级 Agent。

用法:
    python jobs/grade_demand_pool.py                  # 默认业务日、5 个 worker
    python jobs/grade_demand_pool.py 20260716         # 指定业务日
    python jobs/grade_demand_pool.py 20260716 5       # 指定业务日 + 5 个并发 worker
"""
from __future__ import annotations

import logging
import sys

from supply_infra.scheduler.jobs.grade_demand_pool import grade_demand_pool

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


def main(
    biz_dt: str | None = None,
    workers_arg: str | None = None,
) -> dict:
    workers = int(workers_arg) if workers_arg else 5

    result = grade_demand_pool(
        biz_dt,
        workers=workers,
        with_orchestrate=True,
    )
    print(result)
    return result


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