-
Notifications
You must be signed in to change notification settings - Fork 0
/
replay.py
40 lines (36 loc) · 1.21 KB
/
replay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import argparse
import glob
import os
import subprocess
from pathlib import Path
def main(args):
env_dir = Path(args.replay_path) / args.env
for entry in sorted(glob.glob(os.path.join(env_dir, "**/*.demo"), recursive=True)):
task = "/".join(Path(entry).parents._parts[2:-1])
seed = Path(entry).stem.split("_")[-1]
command = [
"python",
"-m",
f"balrog_demo.envs.{args.env}.replay_{args.env}",
"--replay_path",
args.replay_path,
"--env",
args.env,
"--task",
task,
"--seed",
seed,
"--record",
"records",
"--no-render",
]
if args.env == "nle" or args.env == "minihack":
command.append("--vlm")
command.append("True")
subprocess.run(command, shell=False)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--replay_path", type=str, default=None, help="Path to the replay directory", required=True)
parser.add_argument("--env", type=str, default=None, help="Name of the environment to use", required=True)
args = parser.parse_args()
main(args)