Skip to content

Commit 61a1e84

Browse files
Fix incorrect argument name for online WOSAC logging. (#260)
* Fix incorrect argument name. * Small revert. * Incorporate PR feedback.
1 parent dad4f76 commit 61a1e84

3 files changed

Lines changed: 12 additions & 14 deletions

File tree

pufferlib/config/ocean/drive.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ eval_interval = 1000
104104
; Path to dataset used for evaluation
105105
map_dir = "resources/drive/binaries/training"
106106
; Evaluation will run on the first num_maps maps in the map_dir directory
107-
num_maps = 20
107+
wosac_num_maps = 20
108108
backend = PufferEnv
109109
; WOSAC (Waymo Open Sim Agents Challenge) evaluation settings
110110
; If True, enables evaluation on realism metrics each time we save a checkpoint

pufferlib/pufferl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,12 +522,12 @@ def train(self):
522522
print(f"Failed to export model weights: {e}")
523523

524524
if self.config["eval"]["wosac_realism_eval"] and (
525-
self.epoch % self.config["eval"]["eval_interval"] == 0 or done_training
525+
(self.epoch - 1) % self.config["eval"]["eval_interval"] == 0 or done_training
526526
):
527527
pufferlib.utils.run_wosac_eval_in_subprocess(self.config, self.logger, self.global_step)
528528

529529
if self.config["eval"]["human_replay_eval"] and (
530-
self.epoch % self.config["eval"]["eval_interval"] == 0 or done_training
530+
(self.epoch - 1) % self.config["eval"]["eval_interval"] == 0 or done_training
531531
):
532532
pufferlib.utils.run_human_replay_eval_in_subprocess(self.config, self.logger, self.global_step)
533533

@@ -1040,7 +1040,7 @@ def eval(env_name, args=None, vecenv=None, policy=None):
10401040
wosac_enabled = args["eval"]["wosac_realism_eval"]
10411041
human_replay_enabled = args["eval"]["human_replay_eval"]
10421042
args["env"]["map_dir"] = args["eval"]["map_dir"]
1043-
args["env"]["num_maps"] = args["eval"]["num_maps"]
1043+
args["env"]["num_maps"] = args["eval"]["wosac_num_maps"]
10441044
args["env"]["use_all_maps"] = True
10451045
dataset_name = args["env"]["map_dir"].split("/")[-1]
10461046

pufferlib/utils.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ def run_wosac_eval_in_subprocess(config, logger, global_step):
9191
model_dir = os.path.join(config["data_dir"], f"{config['env']}_{run_id}")
9292
model_files = glob.glob(os.path.join(model_dir, "model_*.pt"))
9393

94-
if not model_files:
95-
print("No model files found for WOSAC evaluation")
96-
return
97-
98-
latest_cpt = max(model_files, key=os.path.getctime)
99-
10094
# Prepare evaluation command
10195
eval_config = config.get("eval", {})
10296
cmd = [
@@ -105,12 +99,10 @@ def run_wosac_eval_in_subprocess(config, logger, global_step):
10599
"pufferlib.pufferl",
106100
"eval",
107101
config["env"],
108-
"--load-model-path",
109-
latest_cpt,
110102
"--eval.wosac-realism-eval",
111103
"True",
112-
"--eval.wosac-num-agents",
113-
str(eval_config.get("wosac_num_agents", 256)),
104+
"--eval.wosac-num-maps",
105+
str(eval_config.get("wosac_num_maps", 256)),
114106
"--eval.wosac-init-mode",
115107
str(eval_config.get("wosac_init_mode", "create_all_valid")),
116108
"--eval.wosac-control-mode",
@@ -127,6 +119,12 @@ def run_wosac_eval_in_subprocess(config, logger, global_step):
127119
str(eval_config.get("wosac_aggregate_results", True)),
128120
]
129121

122+
if not model_files:
123+
print("No model files found for WOSAC evaluation. Running WOSAC with random policy.")
124+
elif len(model_files) > 0:
125+
latest_cpt = max(model_files, key=os.path.getctime)
126+
cmd.extend(["--load-model-path", latest_cpt])
127+
130128
# Run WOSAC evaluation in subprocess
131129
result = subprocess.run(cmd, capture_output=True, text=True, timeout=600, cwd=os.getcwd())
132130

0 commit comments

Comments
 (0)