From d6dbde9151f492ab2526dc3d88447fe142d80fa1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20Schr=C3=B6der?=
 <fschroeder@techfak.uni-bielefeld.de>
Date: Sun, 4 Feb 2024 00:44:43 +0100
Subject: [PATCH] Update log path naming in Overcooked simulator

The log path naming in the Overcooked simulator has been updated from a static format to a dynamic one. This change enables individual log naming for each type of event previously considered as 'actions', 'random_env_events', and 'env_configs'. The inclusion of a specific log_record_name in the path helps improve log management and tracking.
---
 overcooked_simulator/game_content/environment_config.yaml | 6 +++---
 overcooked_simulator/recording.py                         | 8 +++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/overcooked_simulator/game_content/environment_config.yaml b/overcooked_simulator/game_content/environment_config.yaml
index 671900ea..83a5ad83 100644
--- a/overcooked_simulator/game_content/environment_config.yaml
+++ b/overcooked_simulator/game_content/environment_config.yaml
@@ -100,14 +100,14 @@ extra_setup_functions:
       hooks: [ pre_perform_action ]
       log_class: !!python/name:overcooked_simulator.recording.LogRecorder ''
       log_class_kwargs:
-        log_path: USER_LOG_DIR/ENV_NAME/actions.jsonl
+        log_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl
   random_env_events:
     func: !!python/name:overcooked_simulator.recording.class_recording_with_hooks ''
     kwargs:
       hooks: [ order_duration_sample, plate_out_of_kitchen_time ]
       log_class: !!python/name:overcooked_simulator.recording.LogRecorder ''
       log_class_kwargs:
-        log_path: USER_LOG_DIR/ENV_NAME/random_env_events.jsonl
+        log_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl
         add_hook_ref: true
   env_configs:
     func: !!python/name:overcooked_simulator.recording.class_recording_with_hooks ''
@@ -115,6 +115,6 @@ extra_setup_functions:
       hooks: [ env_initialized, item_info_config ]
       log_class: !!python/name:overcooked_simulator.recording.LogRecorder ''
       log_class_kwargs:
-        log_path: USER_LOG_DIR/ENV_NAME/env_configs.jsonl
+        log_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl
         add_hook_ref: true
 
diff --git a/overcooked_simulator/recording.py b/overcooked_simulator/recording.py
index 4343cfa6..9af7e0fb 100644
--- a/overcooked_simulator/recording.py
+++ b/overcooked_simulator/recording.py
@@ -31,11 +31,13 @@ class LogRecorder:
         self,
         name: str,
         env: Environment,
-        log_path: str,
+        log_path: str = "USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl",
         add_hook_ref: bool = False,
     ):
         self.add_hook_ref = add_hook_ref
-        log_path = log_path.replace("ENV_NAME", env.env_name)
+        log_path = log_path.replace("ENV_NAME", env.env_name).replace(
+            "LOG_RECORD_NAME", name
+        )
         if log_path.startswith("USER_LOG_DIR/"):
             log_path = (
                 Path(platformdirs.user_log_dir("overcooked_simulator"))
@@ -46,7 +48,7 @@ class LogRecorder:
         else:
             log_path = Path(log_path)
         self.log_path = log_path
-
+        log.info(f"Recorder record for {name} in {log_path}")
         os.makedirs(log_path.parent, exist_ok=True)
 
     def __call__(self, hook_ref: str, env: Environment, **kwargs):
-- 
GitLab