Skip to content

Commit

Permalink
Fixes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
Enkidu93 committed Oct 12, 2023
1 parent f8f7c3b commit a69e82b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions samples/EchoTranslationEngine/TranslationEngineServiceV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ public override Task<GetWordGraphResponse> GetWordGraph(GetWordGraphRequest requ
);
}

public override Task<GetQueueDepthResponse> GetQueueDepth(GetQueueDepthRequest request, ServerCallContext context)
public override Task<GetQueueSizeResponse> GetQueueSize(GetQueueSizeRequest request, ServerCallContext context)
{
return Task.FromResult(new GetQueueDepthResponse { Depth = 0 });
return Task.FromResult(new GetQueueSizeResponse { Size = 0 });
}
}
5 changes: 3 additions & 2 deletions src/Serval.Client/Client.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;

}

Expand Down
8 changes: 4 additions & 4 deletions src/Serval.Grpc/Protos/serval/translation/v1/engine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/Serval.Translation/Contracts/QueueDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
}
2 changes: 1 addition & 1 deletion src/Serval.Translation/Models/Queue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
}
6 changes: 3 additions & 3 deletions src/Serval.Translation/Services/EngineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,11 @@ public Task DeleteAllCorpusFilesAsync(string dataFileId, CancellationToken cance
public async Task<Queue> GetQueueAsync(string engineType, CancellationToken cancellationToken = default)
{
var client = _grpcClientFactory.CreateClient<TranslationEngineApi.TranslationEngineApiClient>(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)
Expand Down
2 changes: 1 addition & 1 deletion tests/Serval.E2ETests/ServalApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down

0 comments on commit a69e82b

Please sign in to comment.