diff --git a/src/Machine/src/Serval.Machine.Shared/Services/ClearMLService.cs b/src/Machine/src/Serval.Machine.Shared/Services/ClearMLService.cs index 2b2b6718..66e1b350 100644 --- a/src/Machine/src/Serval.Machine.Shared/Services/ClearMLService.cs +++ b/src/Machine/src/Serval.Machine.Shared/Services/ClearMLService.cs @@ -161,7 +161,7 @@ public async Task> GetTasksForQueueAsync( var body = new JsonObject { ["queue"] = queueId }; JsonObject? result = await CallAsync("queues", "get_by_id", body, cancellationToken); var tasks = (JsonArray?)result?["data"]?["queue"]?["entries"]; - IEnumerable taskIds = tasks?.Select(t => (string)t?["id"]!) ?? new List(); + IEnumerable taskIds = tasks?.Select(t => (string)t?["task"]!) ?? new List(); return await GetTasksByIdAsync(taskIds, cancellationToken); } diff --git a/src/Serval/test/Serval.E2ETests/ServalApiTests.cs b/src/Serval/test/Serval.E2ETests/ServalApiTests.cs index d4899775..9053e8b9 100644 --- a/src/Serval/test/Serval.E2ETests/ServalApiTests.cs +++ b/src/Serval/test/Serval.E2ETests/ServalApiTests.cs @@ -143,14 +143,26 @@ public async Task NmtQueueMultiple() const int NUM_ENGINES = 10; const int NUM_WORKERS = 8; string[] engineIds = new string[NUM_ENGINES]; + string[] books = ["MAT.txt", "1JN.txt", "2JN.txt"]; + TranslationParallelCorpusConfig train_corpus = await _helperClient.MakeParallelTextCorpus( + books, + "es", + "en", + false + ); + TranslationParallelCorpusConfig pretranslate_corpus = await _helperClient.MakeParallelTextCorpus( + ["3JN.txt"], + "es", + "en", + true + ); for (int i = 0; i < NUM_ENGINES; i++) { _helperClient.InitTranslationBuildConfig(); engineIds[i] = await _helperClient.CreateNewEngineAsync("Nmt", "es", "en", $"NMT1_{i}"); string engineId = engineIds[i]; - string[] books = ["MAT.txt", "1JN.txt", "2JN.txt"]; - await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, books, "es", "en", false); - await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, ["3JN.txt"], "es", "en", true); + await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, train_corpus, false); + await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, pretranslate_corpus, true); await _helperClient.StartBuildAsync(engineId); //Ensure that tasks are enqueued roughly in order await Task.Delay(1_000); @@ -213,8 +225,20 @@ public async Task NmtLargeBatchAndDownload() TranslationEngine engine = await _helperClient.TranslationEnginesClient.GetAsync(engineId); Assert.That(engine.IsModelPersisted, Is.True); string[] books = ["bible_LARGEFILE.txt"]; - await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, books, "es", "en", false); - string cId = await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, ["3JN.txt"], "es", "en", true); + TranslationParallelCorpusConfig train_corpus = await _helperClient.MakeParallelTextCorpus( + books, + "es", + "en", + false + ); + TranslationParallelCorpusConfig pretranslate_corpus = await _helperClient.MakeParallelTextCorpus( + ["3JN.txt"], + "es", + "en", + true + ); + await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, train_corpus, false); + string cId = await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, pretranslate_corpus, true); await _helperClient.BuildEngineAsync(engineId); await Task.Delay(1000); IList lTrans = await _helperClient.TranslationEnginesClient.GetAllPretranslationsAsync( @@ -259,13 +283,8 @@ public async Task CircuitousRouteGetWordGraphAsync() Assert.That(ex.StatusCode, Is.EqualTo(409)); //Add corpus - string cId = await _helperClient.AddParallelTextCorpusToEngineAsync( - smtEngineId, - ["2JN.txt", "3JN.txt"], - "es", - "en", - false - ); + var corpus1 = await _helperClient.MakeParallelTextCorpus(["2JN.txt", "3JN.txt"], "es", "en", false); + string cId = await _helperClient.AddParallelTextCorpusToEngineAsync(smtEngineId, corpus1, false); //Build the new engine await _helperClient.BuildEngineAsync(smtEngineId); @@ -274,13 +293,8 @@ public async Task CircuitousRouteGetWordGraphAsync() await _helperClient.TranslationEnginesClient.DeleteParallelCorpusAsync(smtEngineId, cId); // Add corpus - await _helperClient.AddParallelTextCorpusToEngineAsync( - smtEngineId, - ["1JN.txt", "2JN.txt", "3JN.txt"], - "es", - "en", - false - ); + var corpus2 = await _helperClient.MakeParallelTextCorpus(["1JN.txt", "2JN.txt", "3JN.txt"], "es", "en", false); + await _helperClient.AddParallelTextCorpusToEngineAsync(smtEngineId, corpus2, false); //Build the new engine await _helperClient.BuildEngineAsync(smtEngineId); diff --git a/src/Serval/test/Serval.E2ETests/ServalClientHelper.cs b/src/Serval/test/Serval.E2ETests/ServalClientHelper.cs index d64fb15a..e9a2ff15 100644 --- a/src/Serval/test/Serval.E2ETests/ServalClientHelper.cs +++ b/src/Serval/test/Serval.E2ETests/ServalClientHelper.cs @@ -231,8 +231,7 @@ bool pretranslate return response.Id; } - public async Task AddParallelTextCorpusToEngineAsync( - string engineId, + public async Task MakeParallelTextCorpus( string[] filesToAdd, string sourceLanguage, string targetLanguage, @@ -290,12 +289,21 @@ bool pretranslate TranslationParallelCorpusConfig parallelCorpusConfig = new() { SourceCorpusIds = { sourceCorpus.Id }, TargetCorpusIds = { targetCorpus.Id } }; + return parallelCorpusConfig; + } + + public async Task AddParallelTextCorpusToEngineAsync( + string engineId, + TranslationParallelCorpusConfig parallelCorpusConfig, + bool pretranslate + ) + { var parallelCorpus = await TranslationEnginesClient.AddParallelCorpusAsync(engineId, parallelCorpusConfig); if (pretranslate) { TranslationBuildConfig.Pretranslate!.Add( - new PretranslateCorpusConfig { ParallelCorpusId = parallelCorpus.Id, TextIds = filesToAdd.ToList() } + new PretranslateCorpusConfig { ParallelCorpusId = parallelCorpus.Id } ); }