run.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. """Multi-GPU + LSTM learning tests for RLlib (torch and tf).
  2. """
  3. import json
  4. import os
  5. from pathlib import Path
  6. from ray.rllib.utils.test_utils import run_learning_tests_from_yaml
  7. if __name__ == "__main__":
  8. # Get path of this very script to look for yaml files.
  9. abs_yaml_path = Path(__file__).parent
  10. print("abs_yaml_path={}".format(abs_yaml_path))
  11. yaml_files = abs_yaml_path.rglob("*.yaml")
  12. yaml_files = sorted(
  13. map(lambda path: str(path.absolute()), yaml_files), reverse=True
  14. )
  15. # Run all tests in the found yaml files.
  16. results = run_learning_tests_from_yaml(yaml_files)
  17. test_output_json = os.environ.get(
  18. "TEST_OUTPUT_JSON", "/tmp/rllib_multi_gpu_with_lstm_learning_tests.json"
  19. )
  20. with open(test_output_json, "wt") as f:
  21. json.dump(results, f)
  22. if len(results["not_passed"]) > 0:
  23. raise ValueError(
  24. "Not all learning tests successfully learned the tasks.\n"
  25. f"Results=\n{results}"
  26. )
  27. else:
  28. print("Ok.")