-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add endpoint to return pretanslations as USFM #292
Conversation
What is the reason for these targeted changes? |
So, you are using https://github.com/RicoSuter/NSwag/blob/master/src/NSwag.CodeGeneration.CSharp/Templates/Client.Class.ProcessResponse.liquid. Why did you include it here? What changes are in here? |
Was this because of the Nswag client generation? Won't this be fixed through RicoSuter/NSwag#4704? Should we make a new issue to track removing this warning? |
This is unneeded. |
Nice refactoring! |
Is this trying to address #288? BadRequestObjectResult will just return a 400. That should be ok (enough). |
Should this using also be stuffed into globals? |
This is duplicated code - should (likely) be replaced with |
There is some fun and crazy logic here. Is this different versions of Paratext? Is there some link or explanation that can be put here to help with breadcrumbs in the future when someone wants to know why these algorithms are in place? |
How is this different or distinct from the Machine ZipParatextProjectSettingsParser.cs? You appear to be using the IZipContainer and IFileSystem in Serval (as well as the more recent version of C#) which are not available in Machine. Is there anything else I am missing? |
So, 422's got coalesced into 400's? |
So, we don't care if the engine and corpus source languages don't match? It may be an unnecessary restriction. |
Potential update: "If the USFM book exists in the target corpus, then the pretranslated text will be inserted into the target book and returned. If the USFM book does not exist in the target corpus, then the pretranslated text will be inserted into the source book and returned." |
Potential update: The USFM book specified does not exist in the source or target corpus. |
Nice catch. |
This is to handle the aborted race condition (if I am correct) so that it will appear to the outside world that the aborted engine is already gone. Still, I don't see you throwing anything on the CancelBuildAsync in Machine that would catch this code... |
Put in globals. |
Previously, johnml1135 (John Lambert) wrote…
Further: "If the USFM book exists in the target corpus, then the pretranslated text will be inserted into any empty segments in the the target book and returned. If the USFM book does not exist in the target corpus, then the pretranslated text will be inserted into the source book and returned." |
As per the other comment, when will this exist in real life? |
Why was the [Test] annotation removed? |
You may do this other places, but we should test stripping all text out and also inserting into a target USFM where only some are added. |
Shouldn't these be put in the globals? |
So, without ClearEngines, then there will be a glob of engines built up on the k8s services. Are you addressing this another way? Is there another concern you are trying to address? |
Previously, johnml1135 (John Lambert) wrote…
I see - the disposal methods. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 62 files reviewed, 22 unresolved discussions (waiting on @johnml1135)
src/Serval.ApiServer/nswag.json
line 26 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
What is the reason for these targeted changes?
The new version of NSwag made these changes. I'm assuming that added/removed some properties.
src/Serval.ApiServer/Templates/Client.Class.ProcessResponse.liquid
line 1 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
So, you are using https://github.com/RicoSuter/NSwag/blob/master/src/NSwag.CodeGeneration.CSharp/Templates/Client.Class.ProcessResponse.liquid. Why did you include it here? What changes are in here?
I added a check for "text/plain" content type. NSwag was not generating the correct code for this case.
src/Serval.Client/Serval.Client.csproj
line 8 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
Was this because of the Nswag client generation? Won't this be fixed through RicoSuter/NSwag#4704? Should we make a new issue to track removing this warning?
Yes, the issue you mentioned is tracking this problem. We can make an issue.
src/Serval.Shared/Controllers/BadRequestExceptionFilter.cs
line 7 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
Is this trying to address #288? BadRequestObjectResult will just return a 400. That should be ok (enough).
No, this isn't. This was just a refactoring to simplify the controller code.
src/Serval.Shared/Services/ScriptureDataFileService.cs
line 40 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
There is some fun and crazy logic here. Is this different versions of Paratext? Is there some link or explanation that can be put here to help with breadcrumbs in the future when someone wants to know why these algorithms are in place?
This is based on how Paratext interprets the naming settings internally. Unfortunately, there isn't really any documentation on it anywhere.
src/Serval.Shared/Services/ZipParatextProjectSettingsParser.cs
line 3 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
How is this different or distinct from the Machine ZipParatextProjectSettingsParser.cs? You appear to be using the IZipContainer and IFileSystem in Serval (as well as the more recent version of C#) which are not available in Machine. Is there anything else I am missing?
You are correct. This is the Serval version of the ZipParatextProjectSettingsParser
, which uses IFileSystem
instead of the file system APIs directly.
src/Serval.Translation/Controllers/TranslationEnginesController.cs
line 354 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
So, we don't care if the engine and corpus source languages don't match? It may be an unnecessary restriction.
Yes, that is correct. Serval was specifically designed to allow for the case where you can include a training corpus that doesn't match the source and target language of the engine. This is to support including related language data in the training corpus.
src/Serval.Translation/Services/EngineService.cs
line 259 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
This is to handle the aborted race condition (if I am correct) so that it will appear to the outside world that the aborted engine is already gone. Still, I don't see you throwing anything on the CancelBuildAsync in Machine that would catch this code...
We should add an issue to Machine to check for this.
tests/Serval.ApiServer.IntegrationTests/TranslationEngineTests.cs
line 1210 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
You may do this other places, but we should test stripping all text out and also inserting into a target USFM where only some are added.
I have tests for this in Machine.
tests/Serval.ApiServer.IntegrationTests/TranslationEngineTests.cs
line 1261 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
Why was the [Test] annotation removed?
I missed this when I was resolving conflicts.
tests/Serval.E2ETests/ServalApiTests.cs
line 104 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
I see - the disposal methods.
Yes, that is correct. Although now that I think about it a bit more, it probably makes sense to add this call to the SetUp
method as well just in case a test crashed and never cleaned up the engines.
ZipParatextProjectSettingsParser.cs is not tested for actual stylesheets and custom.sty - and there are a number of other caes that are not covered as per the coverage reports. |
Previously, ddaspit (Damien Daspit) wrote…
|
Previously, ddaspit (Damien Daspit) wrote…
Is there at least an open source repo that you are pulling from to do this? Such as "duplicating logic found here..." |
Previously, ddaspit (Damien Daspit) wrote…
|
Previously, ddaspit (Damien Daspit) wrote…
That "should" be ok... |
Previously, ddaspit (Damien Daspit) wrote…
That sounds like a good path forward. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 62 of 62 files at r1, all commit messages.
Reviewable status: all files reviewed, 14 unresolved discussions (waiting on @ddaspit)
src/Serval.Shared/Controllers/ForbiddenExceptionFilter.cs
line 10 at r1 (raw file):
{ context.Result = new ForbidResult(); context.ExceptionHandled = true;
I see - for the refactoring. I like it.
ed75d04
to
1c38f0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved some of the Paratext project settings code over to the Machine library.
Reviewable status: 48 of 63 files reviewed, 13 unresolved discussions (waiting on @johnml1135)
src/Serval.DataFiles/Consumers/GetDataFileConsumer.cs
line 1 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
This is unneeded.
Done.
src/Serval.Shared/Controllers/ErrorResultFilter.cs
line 1 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
Should this using also be stuffed into globals?
Done.
src/Serval.Shared/Services/ScriptureDataFileService.cs
line 12 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
This is duplicated code - should (likely) be replaced with
ParseProjectSettings(container)
.
Done.
src/Serval.Shared/Services/ScriptureDataFileService.cs
line 40 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
Is there at least an open source repo that you are pulling from to do this? Such as "duplicating logic found here..."
No, Paratext is not open source. I think I might move this code to Machine.
src/Serval.Translation/Controllers/TranslationEnginesController.cs
line 107 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
So, 422's got coalesced into 400's?
I couldn't find a case where the 422 would occur.
src/Serval.Translation/Controllers/TranslationEnginesController.cs
line 613 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
Further: "If the USFM book exists in the target corpus, then the pretranslated text will be inserted into any empty segments in the the target book and returned. If the USFM book does not exist in the target corpus, then the pretranslated text will be inserted into the source book and returned."
Done.
src/Serval.Translation/Controllers/TranslationEnginesController.cs
line 620 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
Potential update: The USFM book specified does not exist in the source or target corpus.
Done.
src/Serval.Translation/Services/PretranslationService.cs
line 1 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
Put in globals.
That causes naming collisions in other files.
tests/Serval.ApiServer.IntegrationTests/TranslationEngineTests.cs
line 1145 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
As per the other comment, when will this exist in real life?
As I said elsewhere, we need to add a check in Machine.
tests/Serval.ApiServer.IntegrationTests/TranslationEngineTests.cs
line 1261 at r1 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
I missed this when I was resolving conflicts.
Done
tests/Serval.DataFiles.Tests/Services/DataFileServiceTests.cs
line 2 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
Shouldn't these be put in the globals?
Done.
tests/Serval.E2ETests/ServalApiTests.cs
line 104 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
That sounds like a good path forward.
Done
Previously, ddaspit (Damien Daspit) wrote…
Hmm. one more edit... "will be inserted into an empty template created from the source USFM book and returned." What do you think? |
Previously, ddaspit (Damien Daspit) wrote…
Good enough. |
The only thing about this is that we are refreshing the token before every single test - I would think that we would want to just get the token and ENV variables once and then clear the engines before/after every test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 15 of 15 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ddaspit)
1c38f0a
to
5fa3e5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @johnml1135)
src/Serval.Translation/Controllers/TranslationEnginesController.cs
line 613 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
Hmm. one more edit... "will be inserted into an empty template created from the source USFM book and returned." What do you think?
Done.
tests/Serval.E2ETests/ServalClientHelper.cs
line 49 at r2 (raw file):
Previously, johnml1135 (John Lambert) wrote…
The only thing about this is that we are refreshing the token before every single test - I would think that we would want to just get the token and ENV variables once and then clear the engines before/after every test.
We were already getting the auth token before every test. The client helper was created in the setup method and the setup method is run before every test.
Previously, ddaspit (Damien Daspit) wrote…
Ok - if it works, it works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ddaspit)
9c01e06
to
1c0a147
Compare
- add Scripture data file service - cleanup translation controllers - cleanup tests - update test dependencies - customize NSwag client template to support "text/plain" response
1c0a147
to
db45232
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 4 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ddaspit)
This change is