Skip to content

Commit

Permalink
More things are broken:
Browse files Browse the repository at this point in the history
* Closer to establishing a true Engine-Job-Results pipeline
  • Loading branch information
johnml1135 committed Oct 4, 2024
1 parent dd90aea commit b131cc4
Show file tree
Hide file tree
Showing 26 changed files with 643 additions and 410 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
namespace Serval.Machine.Shared.Services;

public class ServalPlatformService(
TranslationPlatformApi.TranslationPlatformApiClient client,
EnginePlatformApi.EnginePlatformApiClient client,
IMessageOutboxService outboxService
) : IPlatformService
{
private readonly TranslationPlatformApi.TranslationPlatformApiClient _client = client;
private readonly EnginePlatformApi.EnginePlatformApiClient _client = client;
private readonly IMessageOutboxService _outboxService = outboxService;

public async Task JobStartedAsync(string buildId, CancellationToken cancellationToken = default)
Expand Down
13 changes: 11 additions & 2 deletions src/Serval/src/Serval.Grpc/Protos/serval/engine/v1/platform.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ package serval.engine.v1;

import "google/protobuf/empty.proto";

service JobPlatformApi {
service EnginePlatformApi {
rpc UpdateJobStatus(UpdateJobStatusRequest) returns (google.protobuf.Empty);
rpc JobStarted(JobStartedRequest) returns (google.protobuf.Empty);
rpc JobCompleted(JobCompletedRequest) returns (google.protobuf.Empty);
rpc JobCanceled(JobCanceledRequest) returns (google.protobuf.Empty);
rpc JobFaulted(JobFaultedRequest) returns (google.protobuf.Empty);
rpc JobRestarting(JobRestartingRequest) returns (google.protobuf.Empty);
rpc InsertResults(stream InsertResultsRequest) returns (google.protobuf.Empty);
}

message UpdateJobStatusRequest {
Expand Down Expand Up @@ -41,4 +42,12 @@ message JobFaultedRequest {

message JobRestartingRequest {
string job_id = 1;
}
}

message InsertResultsRequest {
string engine_id = 1;
string corpus_id = 2;
string text_id = 3;
repeated string refs = 4;
string content_serialized = 5;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ package serval.translation.v1;

import "google/protobuf/empty.proto";

service TranslationPlatformApi {
service TranslationPlatformExtensionsApi {
rpc IncrementTranslationEngineCorpusSize(IncrementTranslationEngineCorpusSizeRequest) returns (google.protobuf.Empty);
rpc InsertPretranslations(stream InsertPretranslationsRequest) returns (google.protobuf.Empty);
}

message IncrementTranslationEngineCorpusSizeRequest {
string engine_id = 1;
int32 count = 2;
}

message InsertPretranslationsRequest {
string engine_id = 1;
string corpus_id = 2;
string text_id = 3;
repeated string refs = 4;
string translation = 5;
message TranslationEngineCompletedStatistics {
float confidence = 1;
int32 corpus_size = 2;
}

message TranslationResultContent {
string pretranslation = 1;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Serval.Shared.Contracts;

public record TranslationBuildStartedDto
public record BuildStartedDto
{
public required ResourceLinkDto Build { get; init; }
public required ResourceLinkDto Engine { get; init; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Serval.Shared.Contracts;

public record TranslationBuildFinishedDto
public record BuildFinishedDto
{
public required ResourceLinkDto Build { get; init; }
public required ResourceLinkDto Engine { get; init; }
Expand Down
23 changes: 23 additions & 0 deletions src/Serval/src/Serval.Shared/Contracts/EngineType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Serval.Shared.Contracts;

public enum EngineType
{
Translation,
Assessment,
WordAlignment
}

public class EngineTypeResolver
{
public static EngineType GetEngineType(string engineType)
{
return engineType switch
{
"SmtTransfer" => EngineType.Translation,
"Nmt" => EngineType.Translation,
"Assessment" => EngineType.Assessment,
"WordAlignment" => EngineType.WordAlignment,
_ => throw new ArgumentException($"Unknown engine type: {engineType}")
};
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
namespace Serval.Shared.Contracts;

public record TranslationBuildFinished
public record JobFinished
{
public required string BuildId { get; init; }
public required string JobId { get; init; }
public required string EngineId { get; init; }
public required string Owner { get; init; }
public required JobState BuildState { get; init; }
public required string Type { get; init; }
public required JobState JobState { get; init; }
public required string Message { get; init; }
public required DateTime DateFinished { get; init; }
}
10 changes: 10 additions & 0 deletions src/Serval/src/Serval.Shared/Contracts/JobFinishedDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Serval.Shared.Contracts;

public record JobFinishedDto
{
public required ResourceLinkDto Job { get; init; }
public required ResourceLinkDto Engine { get; init; }
public required JobState JobState { get; init; }
public required string Message { get; init; }
public required DateTime DateFinished { get; init; }
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace Serval.Shared.Contracts;

public record TranslationBuildStarted
public record JobStarted
{
public required string BuildId { get; init; }
public required string EngineId { get; init; }
public required string Owner { get; init; }
public required string Type { get; init; }
}
7 changes: 7 additions & 0 deletions src/Serval/src/Serval.Shared/Contracts/JobStartedDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Serval.Shared.Contracts;

public record JobStartedDto
{
public required ResourceLinkDto Job { get; init; }
public required ResourceLinkDto Engine { get; init; }
}
2 changes: 2 additions & 0 deletions src/Serval/src/Serval.Shared/Models/IEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ public interface IEngine : IOwnedEntity
{
public string? Name { get; init; }
public string Type { get; init; }
public bool IsJobRunning { get; init; }
public int JobRevision { get; init; }
}
1 change: 1 addition & 0 deletions src/Serval/src/Serval.Shared/Models/IJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public interface IJob : IEntity
{
public string? Name { get; init; }
public string EngineRef { get; init; }
public int? QueueDepth { get; init; }
public double? PercentCompleted { get; init; }
public string? Message { get; init; }
public JobState State { get; init; }
Expand Down
2 changes: 1 addition & 1 deletion src/Serval/src/Serval.Shared/Models/IResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public interface IResult : IEntity
{
public string? Name { get; init; }
public string EngineRef { get; init; }
public int JobRevision { get; init; }
}
Loading

0 comments on commit b131cc4

Please sign in to comment.