From 8f0a714fcac2083f81027839b86d6a451cf539b1 Mon Sep 17 00:00:00 2001 From: ereali-aneo Date: Tue, 16 Jul 2024 17:26:03 +0200 Subject: [PATCH] refactor: use ProcessData structure in a more logic way --- src/TaskReRunner/Program.cs | 58 +++++++++++++++---------- src/TaskReRunner/Storage/ProcessData.cs | 4 +- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/TaskReRunner/Program.cs b/src/TaskReRunner/Program.cs index 7fa7a59..4be76fb 100644 --- a/src/TaskReRunner/Program.cs +++ b/src/TaskReRunner/Program.cs @@ -141,33 +141,33 @@ public static void Run(string path, // Register the parameters needed for processing : // communication token, payload and session IDs, configuration settings, data dependencies, folder location, expected output keys, task ID, and task options. - var toProcess = new DumpFormat - { - PayloadId = payloadId, - SessionId = sessionId, - Configuration = configuration, - DataDependencies = - { - dd1, - }, - ExpectedOutputKeys = - { - eok1, - //eok2, // Uncomment to test multiple expected output keys (results) - }, - TaskId = taskId, - TaskOptions = taskOptions, - RawData = rawData, - }; + var DumpData = new DumpFormat + { + PayloadId = payloadId, + SessionId = sessionId, + Configuration = configuration, + DataDependencies = + { + dd1, + }, + ExpectedOutputKeys = + { + eok1, + //eok2, // Uncomment to test multiple expected output keys (results) + }, + TaskId = taskId, + TaskOptions = taskOptions, + RawData = rawData, + }; - logger_.LogInformation("Created Data in {path}: {toProcess}", + logger_.LogInformation("Created Data in {path}: {DumpData}", path, - toProcess); + DumpData); /* * Create a JSON file with all Data */ - var JSONresult = JsonConvert.SerializeObject(toProcess); + var JSONresult = JsonConvert.SerializeObject(DumpData); using (var tw = new StreamWriter(path, false)) @@ -209,6 +209,18 @@ public static void Run(string path, using var server = new Server("/tmp/agent.sock", storage, loggerConfiguration_); + var toProcess = new ProcessData + { + CommunicationToken = token, + PayloadId = input.PayloadId, + SessionId = input.SessionId, + Configuration = input.Configuration, + DataDependencies = input.DataDependencies, + DataFolder = dataFolder, + ExpectedOutputKeys = input.ExpectedOutputKeys, + TaskId = input.TaskId, + TaskOptions = input.TaskOptions, + }; // Call the Process method on the gRPC client `client` of type Worker.WorkerClient client.Process(new ProcessRequest @@ -230,8 +242,8 @@ public static void Run(string path, TaskOptions = input.TaskOptions, }); // Print information given to data - logger_.LogInformation("Task Data: {input}", - input); + logger_.LogInformation("Task Data: {toProcess}", + toProcess); } // Print everything in agent storage diff --git a/src/TaskReRunner/Storage/ProcessData.cs b/src/TaskReRunner/Storage/ProcessData.cs index 2da3d7c..b7f49f4 100644 --- a/src/TaskReRunner/Storage/ProcessData.cs +++ b/src/TaskReRunner/Storage/ProcessData.cs @@ -51,12 +51,12 @@ public record ProcessData /// /// Gets the list of data dependencies required for the process. /// - public ICollection DataDependencies { get; } = new List(); + public ICollection DataDependencies { get; set; } = new List(); /// /// Gets the list of expected output keys. /// - public ICollection ExpectedOutputKeys { get; } = new List(); + public ICollection ExpectedOutputKeys { get; set; } = new List(); /// /// Gets or init the communication token required for the process.