From b7b8b685483f115aec568fd5fcb4cca2a2e1fd24 Mon Sep 17 00:00:00 2001 From: "Eli C. Lowry" <83078660+Enkidu93@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:16:34 -0400 Subject: [PATCH] Make IsNative always true for echo; rethrow on invalid argument rpc exception when src and trg language are not the same for echo (#444) --- .../TranslationEngineServiceV1.cs | 2 +- .../src/Serval.Translation/Services/EngineService.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Echo/src/EchoTranslationEngine/TranslationEngineServiceV1.cs b/src/Echo/src/EchoTranslationEngine/TranslationEngineServiceV1.cs index cfc851a0..4db7af78 100644 --- a/src/Echo/src/EchoTranslationEngine/TranslationEngineServiceV1.cs +++ b/src/Echo/src/EchoTranslationEngine/TranslationEngineServiceV1.cs @@ -316,7 +316,7 @@ ServerCallContext context ) { return Task.FromResult( - new GetLanguageInfoResponse { InternalCode = request.Language + "_echo", IsNative = false, } + new GetLanguageInfoResponse { InternalCode = request.Language + "_echo", IsNative = true, } ); } diff --git a/src/Serval/src/Serval.Translation/Services/EngineService.cs b/src/Serval/src/Serval.Translation/Services/EngineService.cs index bfba27e4..e4c258b9 100644 --- a/src/Serval/src/Serval.Translation/Services/EngineService.cs +++ b/src/Serval/src/Serval.Translation/Services/EngineService.cs @@ -149,6 +149,18 @@ public override async Task CreateAsync(Engine engine, CancellationToken IsModelPersisted = createResponse.IsModelPersisted }; } + catch (RpcException rpcex) + { + await Entities.DeleteAsync(engine, CancellationToken.None); + if (rpcex.StatusCode == StatusCode.InvalidArgument) + { + throw new InvalidOperationException( + $"Unable to create engine {engine.Id} because of an invalid argument: {rpcex.Status.Detail}", + rpcex + ); + } + throw; + } catch { await Entities.DeleteAsync(engine, CancellationToken.None);