Skip to content
Snippets Groups Projects
Commit d6dbde91 authored by Florian Schröder's avatar Florian Schröder
Browse files

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.
parent b6a9867a
No related branches found
No related tags found
1 merge request!43Resolve "Record relevant env events in a file"
Pipeline #45415 passed
......@@ -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
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment