-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval_traj.py
More file actions
50 lines (42 loc) · 1.44 KB
/
eval_traj.py
File metadata and controls
50 lines (42 loc) · 1.44 KB
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
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import json
import os
from reward_function import get_config_model_name, score_trajectory
def main() -> None:
parser = argparse.ArgumentParser(description="Single trajectory evaluator")
parser.add_argument("--traj-dir", type=str, required=True, help="Path to single trajectory directory")
parser.add_argument(
"--config",
type=str,
default="config.yaml",
help="Path to config yaml. Defaults to ./config.yaml (current working directory).",
)
parser.add_argument(
"--output-dir",
type=str,
default="",
help="Directory for evaluation artifacts. Defaults to ./multi_agent_eval_outputs/<model_name>/<task_name>/",
)
args = parser.parse_args()
config_path = args.config
run_name = get_config_model_name(config_path)
resolved_output_dir = args.output_dir.strip()
if not resolved_output_dir:
task_name = os.path.basename(os.path.abspath(args.traj_dir).rstrip("/"))
resolved_output_dir = os.path.join(
os.getcwd(),
"multi_agent_eval_outputs",
run_name,
task_name,
)
result = score_trajectory(
traj_dir=args.traj_dir,
agent_name=None,
config_path=config_path,
output_dir=resolved_output_dir,
)
print(json.dumps(result, ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()