Skip to content

Commit

Permalink
Replace executor with jobs.EnqueueCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Aug 20, 2024
1 parent 44cc15f commit 307e82c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
6 changes: 3 additions & 3 deletions MyApp.ServiceInterface/AdminServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public async Task<object> Any(Sync request)

public async Task<object?> Any(GenerateMeta request)
{
var regenerateMeta = executor.Command<RegenerateMetaCommand>();
await executor.ExecuteAsync(regenerateMeta, new RegenerateMeta {
var regenerateMeta = (QuestionAndAnswers?) await jobs.RunCommandAsync<RegenerateMetaCommand>(new RegenerateMeta {
ForPost = request.Id
});
return regenerateMeta.Result;

return regenerateMeta;
}

public async Task<object> Any(AdminResetCommonPassword request)
Expand Down
7 changes: 2 additions & 5 deletions MyApp.ServiceInterface/AiServerServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public async Task<object> Any(CreateAnswersForModels request)
if (request.PostIds.IsEmpty())
throw new ArgumentNullException(nameof(request.PostIds));

var command = executor.Command<CreateAnswerTasksCommand>();
var to = new CreateAnswersForModelsResponse();

foreach (var postId in request.PostIds)
Expand All @@ -39,7 +38,7 @@ public async Task<object> Any(CreateAnswersForModels request)
to.Errors[postId] = "Missing QuestionFile";
continue;
}
await command.ExecuteAsync(new CreateAnswerTasks
jobs.EnqueueCommand<CreateAnswerTasksCommand>(new CreateAnswerTasks
{
Post = post,
ModelUsers = request.Models,
Expand All @@ -51,8 +50,6 @@ await command.ExecuteAsync(new CreateAnswerTasks

public async Task<object> Any(CreateRankingTasks request)
{
var command = executor.Command<CreateRankAnswerTaskCommand>();

var to = new CreateRankingTasksResponse();

var uniqueUserNames = request.AnswerIds.Select(x => x.RightPart('-')).ToSet();
Expand All @@ -71,7 +68,7 @@ public async Task<object> Any(CreateRankingTasks request)
to.Errors[id] = "Unknown User";
continue;
}
await command.ExecuteAsync(new CreateRankAnswerTask
jobs.EnqueueCommand<CreateRankAnswerTaskCommand>(new CreateRankAnswerTask
{
UserId = userId,
AnswerId = id,
Expand Down
1 change: 0 additions & 1 deletion MyApp.ServiceInterface/QuestionServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ public async Task<object> Any(ImportQuestion request)
var command = executor.Command<ImportQuestionCommand>();
await executor.ExecuteAsync(command, request);
var result = command.Result;
// var result = await jobs.RunCommandAsync<ImportQuestionCommand>(request) as AskQuestion;
return new ImportQuestionResponse
{
Result = result
Expand Down
18 changes: 18 additions & 0 deletions MyApp.Tests/Top1KQuestionTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 307e82c

Please sign in to comment.