From 307e82c8b10b21bd94310ae6b7bcaa68586b5d84 Mon Sep 17 00:00:00 2001 From: Demis Bellot Date: Tue, 20 Aug 2024 09:49:06 +0800 Subject: [PATCH] Replace executor with jobs.EnqueueCommand --- MyApp.ServiceInterface/AdminServices.cs | 6 +++--- MyApp.ServiceInterface/AiServerServices.cs | 7 ++----- MyApp.ServiceInterface/QuestionServices.cs | 1 - MyApp.Tests/Top1KQuestionTasks.cs | 18 ++++++++++++++++++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/MyApp.ServiceInterface/AdminServices.cs b/MyApp.ServiceInterface/AdminServices.cs index 43d2cb4..0826b1f 100644 --- a/MyApp.ServiceInterface/AdminServices.cs +++ b/MyApp.ServiceInterface/AdminServices.cs @@ -55,11 +55,11 @@ public async Task Any(Sync request) public async Task Any(GenerateMeta request) { - var regenerateMeta = executor.Command(); - await executor.ExecuteAsync(regenerateMeta, new RegenerateMeta { + var regenerateMeta = (QuestionAndAnswers?) await jobs.RunCommandAsync(new RegenerateMeta { ForPost = request.Id }); - return regenerateMeta.Result; + + return regenerateMeta; } public async Task Any(AdminResetCommonPassword request) diff --git a/MyApp.ServiceInterface/AiServerServices.cs b/MyApp.ServiceInterface/AiServerServices.cs index 2ab87e4..e7e5316 100644 --- a/MyApp.ServiceInterface/AiServerServices.cs +++ b/MyApp.ServiceInterface/AiServerServices.cs @@ -28,7 +28,6 @@ public async Task Any(CreateAnswersForModels request) if (request.PostIds.IsEmpty()) throw new ArgumentNullException(nameof(request.PostIds)); - var command = executor.Command(); var to = new CreateAnswersForModelsResponse(); foreach (var postId in request.PostIds) @@ -39,7 +38,7 @@ public async Task Any(CreateAnswersForModels request) to.Errors[postId] = "Missing QuestionFile"; continue; } - await command.ExecuteAsync(new CreateAnswerTasks + jobs.EnqueueCommand(new CreateAnswerTasks { Post = post, ModelUsers = request.Models, @@ -51,8 +50,6 @@ await command.ExecuteAsync(new CreateAnswerTasks public async Task Any(CreateRankingTasks request) { - var command = executor.Command(); - var to = new CreateRankingTasksResponse(); var uniqueUserNames = request.AnswerIds.Select(x => x.RightPart('-')).ToSet(); @@ -71,7 +68,7 @@ public async Task Any(CreateRankingTasks request) to.Errors[id] = "Unknown User"; continue; } - await command.ExecuteAsync(new CreateRankAnswerTask + jobs.EnqueueCommand(new CreateRankAnswerTask { UserId = userId, AnswerId = id, diff --git a/MyApp.ServiceInterface/QuestionServices.cs b/MyApp.ServiceInterface/QuestionServices.cs index 511e1fa..1330ba3 100644 --- a/MyApp.ServiceInterface/QuestionServices.cs +++ b/MyApp.ServiceInterface/QuestionServices.cs @@ -536,7 +536,6 @@ public async Task Any(ImportQuestion request) var command = executor.Command(); await executor.ExecuteAsync(command, request); var result = command.Result; - // var result = await jobs.RunCommandAsync(request) as AskQuestion; return new ImportQuestionResponse { Result = result diff --git a/MyApp.Tests/Top1KQuestionTasks.cs b/MyApp.Tests/Top1KQuestionTasks.cs index e7ef013..9708fff 100644 --- a/MyApp.Tests/Top1KQuestionTasks.cs +++ b/MyApp.Tests/Top1KQuestionTasks.cs @@ -213,6 +213,24 @@ public async Task Recreate_answers_for_Top1K_questions_for_DeepSeekCoderV2() apiCreate.Response!.Errors.PrintDump(); apiCreate.Response!.Results.PrintDump();; } + + [Test] + public async Task Recreate_answers_for_Top1K_questions_for_Llama_3_1() + { + var client = await TestUtils.CreateAuthenticatedProdClientAsync(); + // var client = await TestUtils.CreateAuthenticatedDevClientAsync(); + var apiCreate = await client.ApiAsync(new CreateAnswersForModels + { + Models = ["llama3.1-8b"], + PostIds = [9], + // PostIds = Migration1005.Top1KIds, + }); + + apiCreate.Error.PrintDump(); + apiCreate.ThrowIfError(); + apiCreate.Response!.Errors.PrintDump(); + apiCreate.Response!.Results.PrintDump();; + } [Test] public async Task Find_answers_that_have_not_been_individually_graded()