From 33eadb1669f357f1ed05da0b098c6b017c3e9766 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Tue, 28 May 2024 17:30:51 +0100 Subject: [PATCH] Add model.bin to file system --- src/project/project-actions.tsx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/project/project-actions.tsx b/src/project/project-actions.tsx index b762faeb6..4ee743e02 100644 --- a/src/project/project-actions.tsx +++ b/src/project/project-actions.tsx @@ -267,17 +267,24 @@ export class ProjectActions { const data = JSON.parse(json) as ActionData[]; this.setModelData(data); const actionNames = data.map((action) => action.name); - await this.fs.write( - "model.py", - modelModule(JSON.stringify(actionNames)), - VersionAction.INCREMENT - ); const model = await trainModel(data); const result = compileModel(model, {}); - const modelAsHexString = Array.from(result.machineCode, (i) => - i.toString(16).padStart(2, "0") - ).join(""); - console.log(modelAsHexString); + // TODO: Remove if not needed. + // const modelAsHexString = Array.from(result.machineCode, (i) => + // i.toString(16).padStart(2, "0") + // ).join(""); + Promise.all([ + await this.fs.write( + "model.py", + modelModule(JSON.stringify(actionNames)), + VersionAction.INCREMENT + ), + await this.fs.write( + "model.bin", + result.machineCode, + VersionAction.INCREMENT + ), + ]); } };