get_test_summary.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import csv
  2. import os
  3. from typing import Optional
  4. import click
  5. from ray_release.buildkite.concurrency import get_test_resources
  6. from ray_release.config import read_and_validate_release_test_collection
  7. @click.command()
  8. @click.option(
  9. "--test-collection-file",
  10. multiple=True,
  11. type=str,
  12. help="Test collection file, relative path to ray repo.",
  13. )
  14. @click.option(
  15. "--output",
  16. default=None,
  17. type=str,
  18. help="CSV output file",
  19. )
  20. def main(test_collection_file: Optional[str] = None, output: Optional[str] = None):
  21. output = output or os.path.join(os.path.dirname(__file__), "test_summary.csv")
  22. tests = read_and_validate_release_test_collection(
  23. test_collection_file or ["release/release_tests.yaml"]
  24. )
  25. with open(output, "w") as f:
  26. writer = csv.DictWriter(f, fieldnames=["name", "group", "num_cpus", "num_gpus"])
  27. writer.writeheader()
  28. for test in tests:
  29. name = test["name"]
  30. cpus, gpus = get_test_resources(test)
  31. group = test["group"]
  32. writer.writerow(
  33. {
  34. "name": name,
  35. "group": group,
  36. "num_cpus": cpus,
  37. "num_gpus": gpus,
  38. }
  39. )
  40. if __name__ == "__main__":
  41. main()