From f3f5f4274bf5a52333fddf584bcab63bb70f736e Mon Sep 17 00:00:00 2001 From: Hannes Date: Fri, 6 Dec 2024 05:26:37 +0100 Subject: [PATCH 1/2] Small fix for creating the "lstm" Folder --- .../predictor/lstm/common/ReadAndSaveModels.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/common/ReadAndSaveModels.java b/io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/common/ReadAndSaveModels.java index 68e71d8ede..3ce8c2a0c2 100644 --- a/io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/common/ReadAndSaveModels.java +++ b/io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/common/ReadAndSaveModels.java @@ -44,8 +44,20 @@ public class ReadAndSaveModels { */ public static void save(HyperParameters hyperParameters) { String modelName = hyperParameters.getModelName(); - String filePath = Paths.get(MODEL_DIRECTORY, MODEL_FOLDER, modelName)// + String directoryPath = Paths.get(MODEL_DIRECTORY, MODEL_FOLDER) // .toString(); + String filePath = Paths.get(directoryPath, modelName) // + .toString(); + + // Ensure the directory exists + File directory = new File(directoryPath); + if (!directory.exists()) { + boolean dirCreated = directory.mkdirs(); + if (!dirCreated) { + System.err.println("Failed to create directory: " + directoryPath); + return; + } + } Gson gson = new GsonBuilder()// .registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeAdapter())// From 2504de3e862047fec1fba578380964dc3957d1de Mon Sep 17 00:00:00 2001 From: Hannes Date: Fri, 6 Dec 2024 05:27:25 +0100 Subject: [PATCH 2/2] Update ReadAndSaveModels.java --- .../openems/edge/predictor/lstm/common/ReadAndSaveModels.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/common/ReadAndSaveModels.java b/io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/common/ReadAndSaveModels.java index 3ce8c2a0c2..5c441a1132 100644 --- a/io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/common/ReadAndSaveModels.java +++ b/io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/common/ReadAndSaveModels.java @@ -46,7 +46,7 @@ public static void save(HyperParameters hyperParameters) { String modelName = hyperParameters.getModelName(); String directoryPath = Paths.get(MODEL_DIRECTORY, MODEL_FOLDER) // .toString(); - String filePath = Paths.get(directoryPath, modelName) // + String filePath = Paths.get(directoryPath, modelName)// .toString(); // Ensure the directory exists