run_connect_tests.py 906 B

12345678910111213141516171819202122232425262728293031323334
  1. """Connect tests for Tune & RLlib.
  2. Runs a couple of hard learning tests using Anyscale connect.
  3. """
  4. import json
  5. import os
  6. import time
  7. import ray
  8. from ray.rllib.examples.tune.framework import run
  9. if __name__ == "__main__":
  10. addr = os.environ.get("RAY_ADDRESS")
  11. job_name = os.environ.get("RAY_JOB_NAME", "rllib_connect_tests")
  12. if addr is not None and addr.startswith("anyscale://"):
  13. ray.init(address=addr, job_name=job_name)
  14. else:
  15. ray.init(address="auto")
  16. start_time = time.time()
  17. exp_analysis = run()
  18. end_time = time.time()
  19. result = {
  20. "time_taken": end_time - start_time,
  21. "trial_states": {t.config["framework"]: t.status for t in exp_analysis.trials},
  22. }
  23. test_output_json = os.environ.get("TEST_OUTPUT_JSON", "/tmp/release_test_out.json")
  24. with open(test_output_json, "wt") as f:
  25. json.dump(result, f)
  26. print("Ok.")