diff --git a/docker-compose.yml b/docker-compose.yml index 8592c6e7..6e568f99 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -182,4 +182,4 @@ services: '/bin/sh', '-c', 'mongod --quiet --replSet myRS --bind_ip 0.0.0.0 & sleep 2s; mongosh --host localhost:27017 --eval '' config = { "_id" : "myRS", "members" : [{"_id" : 0,"host" : "mongo:27017"}] }; rs.initiate(config, { force: true }); '' ; sleep infinity' - ] + ] \ No newline at end of file diff --git a/src/Serval/src/Serval.Client/Client.g.cs b/src/Serval/src/Serval.Client/Client.g.cs index 7cfa2548..b10b41c7 100644 --- a/src/Serval/src/Serval.Client/Client.g.cs +++ b/src/Serval/src/Serval.Client/Client.g.cs @@ -9838,6 +9838,9 @@ public partial class TranslationBuild [Newtonsoft.Json.JsonProperty("options", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public object? Options { get; set; } = default!; + [Newtonsoft.Json.JsonProperty("deploymentVersion", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string? DeploymentVersion { get; set; } = default!; + } [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] diff --git a/src/Serval/src/Serval.Translation/Contracts/TranslationBuildDto.cs b/src/Serval/src/Serval.Translation/Contracts/TranslationBuildDto.cs index 741ff4ba..eb009161 100644 --- a/src/Serval/src/Serval.Translation/Contracts/TranslationBuildDto.cs +++ b/src/Serval/src/Serval.Translation/Contracts/TranslationBuildDto.cs @@ -27,4 +27,5 @@ public record TranslationBuildDto /// } /// public object? Options { get; init; } + public string? DeploymentVersion { get; init; } } diff --git a/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs b/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs index 8fb394ae..aeb87b96 100644 --- a/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs +++ b/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs @@ -9,6 +9,7 @@ public class TranslationEnginesController( IBuildService buildService, IPretranslationService pretranslationService, IOptionsMonitor apiOptions, + IConfiguration configuration, IUrlService urlService, ILogger logger ) : ServalControllerBase(authService) @@ -22,6 +23,7 @@ ILogger logger private readonly IOptionsMonitor _apiOptions = apiOptions; private readonly IUrlService _urlService = urlService; private readonly ILogger _logger = logger; + private readonly IConfiguration _configuration = configuration; /// /// Get all translation engines @@ -1046,9 +1048,12 @@ public async Task> StartBuildAsync( CancellationToken cancellationToken ) { + string deploymentVersion = _configuration.GetValue("deploymentVersion") ?? "Unknown"; + Engine engine = await _engineService.GetAsync(id, cancellationToken); await AuthorizeAsync(engine); - Build build = Map(engine, buildConfig); + Build build = Map(engine, buildConfig, deploymentVersion); + await _engineService.StartBuildAsync(build, cancellationToken); TranslationBuildDto dto = Map(build); @@ -1311,7 +1316,7 @@ private Engine Map(TranslationEngineConfigDto source) }; } - private static Build Map(Engine engine, TranslationBuildConfigDto source) + private static Build Map(Engine engine, TranslationBuildConfigDto source, string deploymentVersion) { return new Build { @@ -1319,7 +1324,8 @@ private static Build Map(Engine engine, TranslationBuildConfigDto source) Name = source.Name, Pretranslate = Map(engine, source.Pretranslate), TrainOn = Map(engine, source.TrainOn), - Options = Map(source.Options) + Options = Map(source.Options), + DeploymentVersion = deploymentVersion }; } @@ -1534,7 +1540,8 @@ private TranslationBuildDto Map(Build source) QueueDepth = source.QueueDepth, State = source.State, DateFinished = source.DateFinished, - Options = source.Options + Options = source.Options, + DeploymentVersion = source.DeploymentVersion }; } diff --git a/src/Serval/src/Serval.Translation/Models/Build.cs b/src/Serval/src/Serval.Translation/Models/Build.cs index 2c67ba79..57162048 100644 --- a/src/Serval/src/Serval.Translation/Models/Build.cs +++ b/src/Serval/src/Serval.Translation/Models/Build.cs @@ -15,4 +15,5 @@ public record Build : IEntity public JobState State { get; init; } = JobState.Pending; public DateTime? DateFinished { get; init; } public IReadOnlyDictionary? Options { get; init; } + public string? DeploymentVersion { get; init; } } diff --git a/src/Serval/test/Serval.ApiServer.IntegrationTests/TranslationEngineTests.cs b/src/Serval/test/Serval.ApiServer.IntegrationTests/TranslationEngineTests.cs index d5bb79f3..1726353f 100644 --- a/src/Serval/test/Serval.ApiServer.IntegrationTests/TranslationEngineTests.cs +++ b/src/Serval/test/Serval.ApiServer.IntegrationTests/TranslationEngineTests.cs @@ -1407,6 +1407,9 @@ public async Task StartBuildForEngineByIdAsync(IEnumerable scope, int ex build = await client.GetCurrentBuildAsync(engineId); Assert.That(build, Is.Not.Null); + + Assert.That(build.DeploymentVersion, Is.Not.Null); + break; case 400: case 403: