scheduler.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """Scheduler API helpers."""
  2. from __future__ import annotations
  3. from typing import Any
  4. from supply_infra.scheduler.constants import SUPPLY_PIPELINE_JOB_ID
  5. from supply_infra.scheduler.manual_jobs import (
  6. get_manual_run,
  7. list_manual_jobs,
  8. trigger_manual_job,
  9. )
  10. def list_triggerable_jobs() -> list[dict[str, Any]]:
  11. return list_manual_jobs()
  12. def run_scheduler_job(
  13. job_id: str,
  14. *,
  15. biz_dt: str | None = None,
  16. partition_date: str | None = None,
  17. wait: bool = False,
  18. ) -> dict[str, Any]:
  19. return trigger_manual_job(
  20. job_id,
  21. biz_dt=biz_dt,
  22. partition_date=partition_date,
  23. wait=wait,
  24. )
  25. def get_scheduler_job_run(run_id: str) -> dict[str, Any] | None:
  26. return get_manual_run(run_id)
  27. def run_supply_pipeline(
  28. *,
  29. biz_dt: str | None = None,
  30. ) -> dict[str, Any]:
  31. """异步执行供给数据全流程,立即返回 run_id。"""
  32. return run_scheduler_job(
  33. SUPPLY_PIPELINE_JOB_ID,
  34. biz_dt=biz_dt,
  35. wait=False,
  36. )