From a69e82b98f61079b32fbb8c71bf44846aeea512e Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 12 Oct 2023 16:18:34 -0400 Subject: [PATCH] Fixes from review --- .../EchoTranslationEngine/TranslationEngineServiceV1.cs | 4 ++-- src/Serval.Client/Client.g.cs | 5 +++-- src/Serval.Grpc/Protos/serval/translation/v1/engine.proto | 8 ++++---- src/Serval.Translation/Contracts/QueueDto.cs | 2 +- src/Serval.Translation/Models/Queue.cs | 2 +- src/Serval.Translation/Services/EngineService.cs | 6 +++--- tests/Serval.E2ETests/ServalApiTests.cs | 2 +- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/samples/EchoTranslationEngine/TranslationEngineServiceV1.cs b/samples/EchoTranslationEngine/TranslationEngineServiceV1.cs index f792133c..756f86e0 100644 --- a/samples/EchoTranslationEngine/TranslationEngineServiceV1.cs +++ b/samples/EchoTranslationEngine/TranslationEngineServiceV1.cs @@ -294,8 +294,8 @@ public override Task GetWordGraph(GetWordGraphRequest requ ); } - public override Task GetQueueDepth(GetQueueDepthRequest request, ServerCallContext context) + public override Task GetQueueSize(GetQueueSizeRequest request, ServerCallContext context) { - return Task.FromResult(new GetQueueDepthResponse { Depth = 0 }); + return Task.FromResult(new GetQueueSizeResponse { Size = 0 }); } } diff --git a/src/Serval.Client/Client.g.cs b/src/Serval.Client/Client.g.cs index ec2ef46b..05c8ec06 100644 --- a/src/Serval.Client/Client.g.cs +++ b/src/Serval.Client/Client.g.cs @@ -4122,8 +4122,9 @@ public partial class Queue [Newtonsoft.Json.JsonProperty("size", Required = Newtonsoft.Json.Required.Always)] public int Size { get; set; } = default!; - [Newtonsoft.Json.JsonProperty("engineType", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string? EngineType { get; set; } = default!; + [Newtonsoft.Json.JsonProperty("engineType", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string EngineType { get; set; } = default!; } diff --git a/src/Serval.Grpc/Protos/serval/translation/v1/engine.proto b/src/Serval.Grpc/Protos/serval/translation/v1/engine.proto index 10977260..f98478ca 100644 --- a/src/Serval.Grpc/Protos/serval/translation/v1/engine.proto +++ b/src/Serval.Grpc/Protos/serval/translation/v1/engine.proto @@ -12,7 +12,7 @@ service TranslationEngineApi { rpc TrainSegmentPair(TrainSegmentPairRequest) returns (google.protobuf.Empty); rpc StartBuild(StartBuildRequest) returns (google.protobuf.Empty); rpc CancelBuild(CancelBuildRequest) returns (google.protobuf.Empty); - rpc GetQueueDepth(GetQueueDepthRequest) returns (GetQueueDepthResponse); + rpc GetQueueSize(GetQueueSizeRequest) returns (GetQueueSizeResponse); } message CreateRequest { @@ -70,12 +70,12 @@ message CancelBuildRequest { string engine_id = 2; } -message GetQueueDepthRequest { +message GetQueueSizeRequest { string engine_type = 1; } -message GetQueueDepthResponse { - int32 depth = 1; +message GetQueueSizeResponse { + int32 size = 1; } message AlignedWordPair { diff --git a/src/Serval.Translation/Contracts/QueueDto.cs b/src/Serval.Translation/Contracts/QueueDto.cs index 00fcffec..0e19d34a 100644 --- a/src/Serval.Translation/Contracts/QueueDto.cs +++ b/src/Serval.Translation/Contracts/QueueDto.cs @@ -3,5 +3,5 @@ namespace Serval.Translation.Contracts; public class QueueDto { public int Size { get; set; } = default; - public string? EngineType {get; set;} + public string EngineType { get; set; } = default!; } diff --git a/src/Serval.Translation/Models/Queue.cs b/src/Serval.Translation/Models/Queue.cs index a4fd3782..74b62688 100644 --- a/src/Serval.Translation/Models/Queue.cs +++ b/src/Serval.Translation/Models/Queue.cs @@ -3,5 +3,5 @@ namespace Serval.Translation.Models; public class Queue { public int Size { get; set; } = default; - public string? EngineType {get; set;} + public string EngineType { get; set; } = default!; } diff --git a/src/Serval.Translation/Services/EngineService.cs b/src/Serval.Translation/Services/EngineService.cs index e8c36af5..be39dbed 100644 --- a/src/Serval.Translation/Services/EngineService.cs +++ b/src/Serval.Translation/Services/EngineService.cs @@ -301,11 +301,11 @@ public Task DeleteAllCorpusFilesAsync(string dataFileId, CancellationToken cance public async Task GetQueueAsync(string engineType, CancellationToken cancellationToken = default) { var client = _grpcClientFactory.CreateClient(engineType); - GetQueueDepthResponse response = await client.GetQueueDepthAsync( - new GetQueueDepthRequest { EngineType = engineType }, + GetQueueSizeResponse response = await client.GetQueueSizeAsync( + new GetQueueSizeRequest { EngineType = engineType }, cancellationToken: cancellationToken ); - return new Queue { Size = response.Depth, EngineType = engineType }; + return new Queue { Size = response.Size, EngineType = engineType }; } private Models.TranslationResult Map(V1.TranslationResult source) diff --git a/tests/Serval.E2ETests/ServalApiTests.cs b/tests/Serval.E2ETests/ServalApiTests.cs index dea584fa..06b1f1c1 100644 --- a/tests/Serval.E2ETests/ServalApiTests.cs +++ b/tests/Serval.E2ETests/ServalApiTests.cs @@ -157,7 +157,7 @@ public async Task NmtQueueMultiple() await Task.Delay(500); } //Wait for at least some tasks to be queued - await Task.Delay(10_000); + await Task.Delay(20_000); string builds = ""; for (int i = 0; i < NUM_ENGINES; i++) {