From 0cfd14502a9968b6577f6ad030e34049daa8167d Mon Sep 17 00:00:00 2001 From: "Eli C. Lowry" <83078660+Enkidu93@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:10:54 -0500 Subject: [PATCH] Don't fault build when there's no data (#571) * Use OperationCanceledException * Change exception in test --- .../src/Serval.Machine.Shared/Services/PreprocessBuildJob.cs | 2 +- .../Services/PreprocessBuildJobTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Machine/src/Serval.Machine.Shared/Services/PreprocessBuildJob.cs b/src/Machine/src/Serval.Machine.Shared/Services/PreprocessBuildJob.cs index 2d2e06f7..f85d35c1 100644 --- a/src/Machine/src/Serval.Machine.Shared/Services/PreprocessBuildJob.cs +++ b/src/Machine/src/Serval.Machine.Shared/Services/PreprocessBuildJob.cs @@ -63,7 +63,7 @@ CancellationToken cancellationToken if (trainCount == 0 && (!sourceTagInBaseModel || !targetTagInBaseModel)) { - throw new InvalidOperationException( + throw new OperationCanceledException( $"At least one language code in build {buildId} is unknown to the base model, and the data specified for training was empty. Build canceled." ); } diff --git a/src/Machine/test/Serval.Machine.Shared.Tests/Services/PreprocessBuildJobTests.cs b/src/Machine/test/Serval.Machine.Shared.Tests/Services/PreprocessBuildJobTests.cs index 470817cc..f318524f 100644 --- a/src/Machine/test/Serval.Machine.Shared.Tests/Services/PreprocessBuildJobTests.cs +++ b/src/Machine/test/Serval.Machine.Shared.Tests/Services/PreprocessBuildJobTests.cs @@ -238,7 +238,7 @@ public void RunAsync_UnknownLanguageTagsNoData() using TestEnvironment env = new(); ParallelCorpus corpus1 = TestEnvironment.TextFileCorpus(sourceLanguage: "xxx", targetLanguage: "zzz"); - Assert.ThrowsAsync(async () => + Assert.ThrowsAsync(async () => { await env.RunBuildJobAsync(corpus1, engineId: "engine2"); });