run_connect_tests.py 949 B

1234567891011121314151617181920212223242526272829303132333435
  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. results = run()
  18. exp_analysis = results._experiment_analysis
  19. end_time = time.time()
  20. result = {
  21. "time_taken": end_time - start_time,
  22. "trial_states": {t.config["framework"]: t.status for t in exp_analysis.trials},
  23. }
  24. test_output_json = os.environ.get("TEST_OUTPUT_JSON", "/tmp/release_test_out.json")
  25. with open(test_output_json, "wt") as f:
  26. json.dump(result, f)
  27. print("Ok.")