xgboost_tests.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from typing import Optional
  2. from ray_release.test import Test
  3. from ray_release.result import Result
  4. def handle_result(
  5. test: Test,
  6. result: Result,
  7. ) -> Optional[str]:
  8. test_name = test["name"]
  9. time_taken = result.results.get("time_taken", float("inf"))
  10. num_terminated = result.results.get("trial_states", {}).get("TERMINATED", 0)
  11. if test_name.startswith("xgboost_tune_"):
  12. msg = ""
  13. if test_name == "xgboost_tune_small":
  14. target_terminated = 4
  15. target_time = 90
  16. elif test_name == "xgboost_tune_4x32":
  17. target_terminated = 4
  18. target_time = 120
  19. elif test_name == "xgboost_tune_32x4":
  20. target_terminated = 32
  21. target_time = 600
  22. else:
  23. return None
  24. if num_terminated < target_terminated:
  25. msg += (
  26. f"Some trials failed "
  27. f"(num_terminated={num_terminated} < {target_terminated}). "
  28. )
  29. if time_taken > target_time:
  30. msg += (
  31. f"Took too long to complete "
  32. f"(time_taken={time_taken} > {target_time}). "
  33. )
  34. return msg or None
  35. else:
  36. # train scripts
  37. if test_name == "xgboost_train_small":
  38. # Leave a couple of seconds for ray connect setup
  39. # (without connect it should finish in < 30)
  40. target_time = 45
  41. elif test_name == "xgboost_train_moderate":
  42. target_time = 60
  43. elif test_name == "xgboost_train_gpu":
  44. target_time = 40
  45. else:
  46. return None
  47. if time_taken > target_time:
  48. return (
  49. f"Took too long to complete "
  50. f"(time_taken={time_taken:.2f} > {target_time}). "
  51. )
  52. return None