Skip to content

Commit

Permalink
Last fixes for E2E testing
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Oct 11, 2024
1 parent 43fd395 commit 027e9ec
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
31 changes: 23 additions & 8 deletions src/Serval/src/Serval.Translation/Services/EngineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -777,14 +777,29 @@ pretranslateFilter is not null
Files = { source.Files.Select(Map) }
};

if (trainOnChapters is not null)
corpus.TrainOnChapters.Add(trainOnChapters);
if (trainingFilter?.TextIds is not null)
corpus.TrainOnTextIds.Add(trainingFilter.TextIds);
if (pretranslateChapters is not null)
corpus.PretranslateChapters.Add(pretranslateChapters);
if (pretranslateFilter?.TextIds is not null)
corpus.PretranslateTextIds.Add(pretranslateFilter.TextIds);
if (trainingFilter is null)
{
corpus.TrainOnAll = true;
}
else
{
if (trainOnChapters is not null)
corpus.TrainOnChapters.Add(trainOnChapters);
if (trainingFilter?.TextIds is not null)
corpus.TrainOnTextIds.Add(trainingFilter.TextIds);
}

if (pretranslateFilter is null)
{
corpus.PretranslateAll = true;
}
else
{
if (pretranslateChapters is not null)
corpus.PretranslateChapters.Add(pretranslateChapters);
if (pretranslateFilter?.TextIds is not null)
corpus.PretranslateTextIds.Add(pretranslateFilter.TextIds);
}

return corpus;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Serval/test/Serval.E2ETests/ServalApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ public async Task NmtQueueMultiple()
engineIds[i] = await _helperClient.CreateNewEngineAsync("Nmt", "es", "en", $"NMT1_{i}");
string engineId = engineIds[i];
string[] books = ["MAT.txt", "1JN.txt", "2JN.txt"];
await _helperClient.AddTextCorpusToEngineAsync(engineId, books, "es", "en", false);
await _helperClient.AddTextCorpusToEngineAsync(engineId, ["3JN.txt"], "es", "en", true);
await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, books, "es", "en", false);
await _helperClient.AddParallelTextCorpusToEngineAsync(engineId, ["3JN.txt"], "es", "en", true);
await _helperClient.StartBuildAsync(engineId);
//Ensure that tasks are enqueued roughly in order
await Task.Delay(1_000);
Expand Down Expand Up @@ -247,7 +247,7 @@ public async Task CircuitousRouteGetWordGraphAsync()
Assert.That(ex.StatusCode, Is.EqualTo(409));

//Add corpus
string cId = await _helperClient.AddTextCorpusToEngineAsync(
string cId = await _helperClient.AddParallelTextCorpusToEngineAsync(
smtEngineId,
["2JN.txt", "3JN.txt"],
"es",
Expand All @@ -259,10 +259,10 @@ public async Task CircuitousRouteGetWordGraphAsync()
await _helperClient.BuildEngineAsync(smtEngineId);

//Remove added corpus (shouldn't affect translation)
await _helperClient.TranslationEnginesClient.DeleteCorpusAsync(smtEngineId, cId, deleteFiles: false);
await _helperClient.TranslationEnginesClient.DeleteParallelCorpusAsync(smtEngineId, cId);

// Add corpus
await _helperClient.AddTextCorpusToEngineAsync(
await _helperClient.AddParallelTextCorpusToEngineAsync(
smtEngineId,
["1JN.txt", "2JN.txt", "3JN.txt"],
"es",
Expand Down
2 changes: 1 addition & 1 deletion src/Serval/test/Serval.E2ETests/ServalClientHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ bool pretranslate
if (pretranslate)
{
TranslationBuildConfig.Pretranslate!.Add(
new PretranslateCorpusConfig { CorpusId = parallelCorpus.Id, TextIds = filesToAdd.ToList() }
new PretranslateCorpusConfig { ParallelCorpusId = parallelCorpus.Id, TextIds = filesToAdd.ToList() }
);
}

Expand Down

0 comments on commit 027e9ec

Please sign in to comment.