From 4e4e17945d1229d5d04493fb9af6d8cb7c206630 Mon Sep 17 00:00:00 2001 From: ll7 Date: Wed, 25 Sep 2024 15:04:56 +0200 Subject: [PATCH] test: Create directory if it doesn't exist in test_can_load_model_snapshot() --- tests/sb3_test.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/sb3_test.py b/tests/sb3_test.py index 054c529..9df038f 100644 --- a/tests/sb3_test.py +++ b/tests/sb3_test.py @@ -7,10 +7,13 @@ from robot_sf.gym_env.robot_env import RobotEnv from robot_sf.feature_extractor import DynamicsExtractor - def test_can_load_model_snapshot(): MODEL_PATH = "./temp/ppo_model" MODEL_FILE = f"{MODEL_PATH}.zip" + + # Create the directory if it doesn't exist + os.makedirs(os.path.dirname(MODEL_PATH), exist_ok=True) + if os.path.exists(MODEL_FILE) and os.path.isfile(MODEL_FILE): os.remove(MODEL_FILE)