help="The directory in which to find all yamls to test.")
if __name__ == "__main__":
args = parser.parse_args()
// Bazel regression test mode: Get path to look for yaml files from argv[2].
// Get the path or single file to use.
rllib_dir = Path(__file__).parent.parent
print("rllib dir={}".format(rllib_dir))
if not os.path.isdir(os.path.join(rllib_dir, args.yaml_dir)):
raise ValueError("yaml-dir ({}) not found!".format(args.yaml_dir))
yaml_files = rllib_dir.rglob(args.yaml_dir + "/*.yaml")
yaml_files = sorted(
map(lambda path: str(path.absolute()), yaml_files), reverse=True)
print("Will run the following regression tests:")
for yaml_file in yaml_files:
print("->", yaml_file)
// Loop through all collected files.
for yaml_file in yaml_files:
experiments = yaml.load(open(yaml_file).read())
assert len(experiments) == 1,\
"Error, can only run a single experiment per yaml file!"
print("== Test config ==")
print(yaml.dump(experiments))
// Add torch option to exp configs.
for exp in experiments.values():
if args.torch:
exp["config"]["use_pytorch"] = True
// Try running each test 3 times and make sure it reaches the given
// reward.
passed = False
for i in range(3):
try:
ray.init(num_cpus=5)