Skip to content

Commit

Permalink
Add assessment API and AQuA engine
Browse files Browse the repository at this point in the history
  • Loading branch information
ddaspit committed May 16, 2024
1 parent 85d87f5 commit 7e95188
Show file tree
Hide file tree
Showing 133 changed files with 7,136 additions and 272 deletions.
35 changes: 34 additions & 1 deletion Serval.sln
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serval.DataFiles.Tests", "t
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SIL.DataAccess.Tests", "tests\SIL.DataAccess.Tests\SIL.DataAccess.Tests.csproj", "{71151518-8774-44D0-8E69-D77FA447BEFA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serval.Shared.Tests", "tests\Serval.Shared.Tests\Serval.Shared.Tests.csproj", "{0E220C65-AA88-450E-AFB2-844E49060B3F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serval.Shared.Tests", "tests\Serval.Shared.Tests\Serval.Shared.Tests.csproj", "{0E220C65-AA88-450E-AFB2-844E49060B3F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serval.Assessment", "src\Serval.Assessment\Serval.Assessment.csproj", "{9BD2B817-300F-4E8B-83AD-450B11C82093}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serval.Aqua.Shared", "src\Aqua\src\Serval.Aqua.Shared\Serval.Aqua.Shared.csproj", "{A04C0C7B-BACA-4BE3-8E5A-02AF53BC0E6A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Aqua", "Aqua", "{16B0A3F6-32CC-4465-8FFE-348AD3763A5C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4113CEC0-D7D4-4F23-866F-A7A70A285343}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serval.Aqua.EngineServer", "src\Aqua\src\Serval.Aqua.EngineServer\Serval.Aqua.EngineServer.csproj", "{E83674D8-4A8C-4357-9543-8639BFF171CA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serval.Aqua.JobServer", "src\Aqua\src\Serval.Aqua.JobServer\Serval.Aqua.JobServer.csproj", "{D5CA4451-B638-475F-8843-38352B6D84D1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -126,6 +138,22 @@ Global
{0E220C65-AA88-450E-AFB2-844E49060B3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E220C65-AA88-450E-AFB2-844E49060B3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E220C65-AA88-450E-AFB2-844E49060B3F}.Release|Any CPU.Build.0 = Release|Any CPU
{9BD2B817-300F-4E8B-83AD-450B11C82093}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BD2B817-300F-4E8B-83AD-450B11C82093}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BD2B817-300F-4E8B-83AD-450B11C82093}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BD2B817-300F-4E8B-83AD-450B11C82093}.Release|Any CPU.Build.0 = Release|Any CPU
{A04C0C7B-BACA-4BE3-8E5A-02AF53BC0E6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A04C0C7B-BACA-4BE3-8E5A-02AF53BC0E6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A04C0C7B-BACA-4BE3-8E5A-02AF53BC0E6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A04C0C7B-BACA-4BE3-8E5A-02AF53BC0E6A}.Release|Any CPU.Build.0 = Release|Any CPU
{E83674D8-4A8C-4357-9543-8639BFF171CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E83674D8-4A8C-4357-9543-8639BFF171CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E83674D8-4A8C-4357-9543-8639BFF171CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E83674D8-4A8C-4357-9543-8639BFF171CA}.Release|Any CPU.Build.0 = Release|Any CPU
{D5CA4451-B638-475F-8843-38352B6D84D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5CA4451-B638-475F-8843-38352B6D84D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5CA4451-B638-475F-8843-38352B6D84D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5CA4451-B638-475F-8843-38352B6D84D1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -147,6 +175,11 @@ Global
{63E4D71B-11BE-4D68-A876-5B1B5F0A4C88} = {66246A1C-8D45-40FB-A660-C58577122CA7}
{71151518-8774-44D0-8E69-D77FA447BEFA} = {66246A1C-8D45-40FB-A660-C58577122CA7}
{0E220C65-AA88-450E-AFB2-844E49060B3F} = {66246A1C-8D45-40FB-A660-C58577122CA7}
{9BD2B817-300F-4E8B-83AD-450B11C82093} = {31B4F5EB-E148-4A51-84B5-B90BB8F38AD3}
{A04C0C7B-BACA-4BE3-8E5A-02AF53BC0E6A} = {4113CEC0-D7D4-4F23-866F-A7A70A285343}
{4113CEC0-D7D4-4F23-866F-A7A70A285343} = {16B0A3F6-32CC-4465-8FFE-348AD3763A5C}
{E83674D8-4A8C-4357-9543-8639BFF171CA} = {4113CEC0-D7D4-4F23-866F-A7A70A285343}
{D5CA4451-B638-475F-8843-38352B6D84D1} = {4113CEC0-D7D4-4F23-866F-A7A70A285343}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9F18C25E-E140-43C3-B177-D562E1628370}
Expand Down
22 changes: 6 additions & 16 deletions samples/EchoTranslationEngine/TranslationEngineServiceV1.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
namespace EchoTranslationEngine;

public class TranslationEngineServiceV1(BackgroundTaskQueue taskQueue, HealthCheckService healthCheckService)
: TranslationEngineApi.TranslationEngineApiBase
public class TranslationEngineServiceV1(BackgroundTaskQueue taskQueue) : TranslationEngineApi.TranslationEngineApiBase
{
private static readonly Empty Empty = new();
private readonly BackgroundTaskQueue _taskQueue = taskQueue;

private readonly HealthCheckService _healthCheckService = healthCheckService;

public override Task<CreateResponse> Create(CreateRequest request, ServerCallContext context)
{
if (request.SourceLanguage != request.TargetLanguage)
Expand Down Expand Up @@ -79,7 +76,7 @@ public override async Task<Empty> StartBuild(StartBuildRequest request, ServerCa
try
{
using (
AsyncClientStreamingCall<InsertPretranslationRequest, Empty> call =
AsyncClientStreamingCall<InsertPretranslationsRequest, Empty> call =
client.InsertPretranslations(cancellationToken: cancellationToken)
)
{
Expand Down Expand Up @@ -124,7 +121,7 @@ public override async Task<Empty> StartBuild(StartBuildRequest request, ServerCa
if (sourceLine.Length > 0 && targetLine.Length == 0)
{
await call.RequestStream.WriteAsync(
new InsertPretranslationRequest
new InsertPretranslationsRequest
{
EngineId = request.EngineId,
CorpusId = corpus.Id,
Expand Down Expand Up @@ -157,7 +154,7 @@ public override async Task<Empty> StartBuild(StartBuildRequest request, ServerCa
if (sourceLine.Length > 0 && targetLine.Length == 0)
{
await call.RequestStream.WriteAsync(
new InsertPretranslationRequest
new InsertPretranslationsRequest
{
EngineId = request.EngineId,
CorpusId = corpus.Id,
Expand All @@ -182,7 +179,7 @@ public override async Task<Empty> StartBuild(StartBuildRequest request, ServerCa
if (sourceLine.Length > 0)
{
await call.RequestStream.WriteAsync(
new InsertPretranslationRequest
new InsertPretranslationsRequest
{
EngineId = request.EngineId,
CorpusId = corpus.Id,
Expand All @@ -203,7 +200,7 @@ public override async Task<Empty> StartBuild(StartBuildRequest request, ServerCa
if (sourceLine.Length > 0)
{
await call.RequestStream.WriteAsync(
new InsertPretranslationRequest
new InsertPretranslationsRequest
{
EngineId = request.EngineId,
CorpusId = corpus.Id,
Expand Down Expand Up @@ -319,11 +316,4 @@ ServerCallContext context
new GetLanguageInfoResponse { InternalCode = request.Language + "_echo", IsNative = false, }
);
}

public override async Task<HealthCheckResponse> HealthCheck(Empty request, ServerCallContext context)
{
HealthReport healthReport = await _healthCheckService.CheckHealthAsync();
HealthCheckResponse healthCheckResponse = WriteGrpcHealthCheckResponse.Generate(healthReport);
return healthCheckResponse;
}
}
40 changes: 40 additions & 0 deletions src/Aqua/src/Serval.Aqua.EngineServer/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Hangfire;
using OpenTelemetry.Trace;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder
.Services.AddAqua(builder.Configuration)
.AddMongoDataAccess()
.AddMongoHangfireJobClient()
.AddServalAssessmentEngineService()
.AddAquaService()
.AddAquaMonitorService();

if (builder.Environment.IsDevelopment())
{
builder
.Services.AddOpenTelemetry()
.WithTracing(builder =>
{
builder
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddGrpcClientInstrumentation()
.AddSource("MongoDB.Driver.Core.Extensions.DiagnosticSources")
.AddConsoleExporter();
});
}

WebApplication app = builder.Build();

// Configure the HTTP request pipeline.

app.UseHttpsRedirection();

app.MapServalAssessmentEngineService();
app.MapHangfireDashboard();

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"Serval.Aqua.EngineServer": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:9100"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>eec61cfb-a756-4bef-9167-323dcade8101</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.8.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.8.0-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Serval.Aqua.Shared\Serval.Aqua.Shared.csproj" />
</ItemGroup>

</Project>
14 changes: 14 additions & 0 deletions src/Aqua/src/Serval.Aqua.EngineServer/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"ConnectionStrings": {
"Hangfire": "mongodb://localhost:27017/aqua_jobs",
"Mongo": "mongodb://localhost:27017/aqua",
"Serval": "https://localhost:8444"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"System.Net.Http.HttpClient.Default": "Warning"
}
}
}
15 changes: 15 additions & 0 deletions src/Aqua/src/Serval.Aqua.EngineServer/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ConnectionStrings": {
"Aqua": "https://tmv9bz5v4q.us-east-1.awsapprunner.com/latest/"
},
"Aqua": {
"JobPollingEnabled": true
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
34 changes: 34 additions & 0 deletions src/Aqua/src/Serval.Aqua.JobServer/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Hangfire;
using OpenTelemetry.Trace;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder
.Services.AddAqua(builder.Configuration)
.AddMongoDataAccess()
.AddMongoHangfireJobClient()
.AddServalPlatformService()
.AddAquaService();

builder.Services.AddHangfireServer();

if (builder.Environment.IsDevelopment())
{
builder
.Services.AddOpenTelemetry()
.WithTracing(builder =>
{
builder
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddGrpcClientInstrumentation()
.AddSource("MongoDB.Driver.Core.Extensions.DiagnosticSources")
.AddConsoleExporter();
});
}

WebApplication app = builder.Build();

app.Run();
13 changes: 13 additions & 0 deletions src/Aqua/src/Serval.Aqua.JobServer/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"Serval.Aqua.JobServer": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:9101"
}
}
}
22 changes: 22 additions & 0 deletions src/Aqua/src/Serval.Aqua.JobServer/Serval.Aqua.JobServer.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>fc417e67-a798-4ef1-8700-b2f02c044ea7</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.8.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.8.0-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Serval.Aqua.Shared\Serval.Aqua.Shared.csproj" />
</ItemGroup>

</Project>
14 changes: 14 additions & 0 deletions src/Aqua/src/Serval.Aqua.JobServer/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"ConnectionStrings": {
"Hangfire": "mongodb://localhost:27017/aqua_jobs",
"Mongo": "mongodb://localhost:27017/aqua",
"Serval": "https://localhost:8444"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"System.Net.Http.HttpClient.Default": "Warning"
}
}
}
12 changes: 12 additions & 0 deletions src/Aqua/src/Serval.Aqua.JobServer/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ConnectionStrings": {
"Aqua": "https://tmv9bz5v4q.us-east-1.awsapprunner.com/latest/"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
7 changes: 7 additions & 0 deletions src/Aqua/src/Serval.Aqua.Shared/Configuration/AquaBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Extensions.DependencyInjection;

internal class AquaBuilder(IServiceCollection services, IConfiguration? configuration) : IAquaBuilder
{
public IServiceCollection Services { get; } = services;
public IConfiguration? Configuration { get; } = configuration;
}
11 changes: 11 additions & 0 deletions src/Aqua/src/Serval.Aqua.Shared/Configuration/AquaOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Serval.Aqua.Shared.Configuration;

public class AquaOptions
{
public const string Key = "Aqua";

public string Username { get; set; } = "";
public string Password { get; set; } = "";
public bool JobPollingEnabled { get; set; } = false;
public TimeSpan JobPollingTimeout { get; set; } = TimeSpan.FromSeconds(10);
}
7 changes: 7 additions & 0 deletions src/Aqua/src/Serval.Aqua.Shared/Configuration/IAquaBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Extensions.DependencyInjection;

public interface IAquaBuilder
{
IServiceCollection Services { get; }
IConfiguration? Configuration { get; }
}
Loading

0 comments on commit 7e95188

Please sign in to comment.