jobs.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. from datetime import datetime
  2. from zoneinfo import ZoneInfo
  3. from app.services.demand_pool_strategy_daily_alert import run_daily_strategy_alert
  4. from app.sync.demand_pool_sync import run_full_sync, run_today_incremental_sync
  5. def heartbeat_job() -> None:
  6. now = datetime.now(ZoneInfo("Asia/Shanghai")).isoformat()
  7. print(f"[scheduler] heartbeat at {now}")
  8. def demand_pool_full_sync_job() -> None:
  9. print("[scheduler] start full sync for demand pool")
  10. result = run_full_sync()
  11. print(f"[scheduler] full sync done: {result}")
  12. def demand_pool_today_incremental_sync_job() -> None:
  13. print("[scheduler] start incremental sync for demand pool")
  14. result = run_today_incremental_sync()
  15. print(f"[scheduler] incremental sync done: {result}")
  16. def demand_pool_daily_strategy_alert_job(partition_dt: str | None = None) -> None:
  17. print("[scheduler] start daily ODPS strategy alert for demand pool")
  18. try:
  19. result = run_daily_strategy_alert(partition_dt)
  20. print(f"[scheduler] daily strategy alert done: {result}")
  21. except Exception as exc:
  22. print(f"[scheduler] daily strategy alert failed: {exc}")
  23. raise