Skip to content
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

Convert to MongoDB callback API #184

Merged
merged 2 commits into from
Apr 17, 2024
Merged

Convert to MongoDB callback API #184

merged 2 commits into from
Apr 17, 2024

Conversation

johnml1135
Copy link
Collaborator

@johnml1135 johnml1135 commented Apr 12, 2024

sillsdev/serval#314

This should help fix the transaction issues the right way.


This change is Reviewable

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @Enkidu93 and @johnml1135)


src/SIL.Machine.AspNetCore/Services/NmtEngineService.cs line 59 at r1 (raw file):

                    IsModelPersisted = isModelPersisted ?? false // models are not persisted if not specified
                };
                await _engines.InsertAsync(translationEngine, cancellationToken);

You should use ct just to be safe.


src/SIL.Machine.AspNetCore/Services/SmtTransferEngineService.cs line 57 at r1 (raw file):

                    IsModelPersisted = isModelPersisted ?? true // models are persisted if not specified
                };
                await _engines.InsertAsync(translationEngine, cancellationToken);

You should use ct to be safe.


src/SIL.Machine.AspNetCore/Services/SmtTransferEngineService.cs line 83 at r1 (raw file):

                async (ct) =>
                {
                    await _engines.DeleteAsync(e => e.EngineId == engineId, cancellationToken);

You should use ct to be safe.


src/SIL.Machine.AspNetCore/Services/SmtTransferEngineService.cs line 157 at r1 (raw file):

            }

            SmtTransferEngineState state;

You should be able to set the state here, i.e. SmtTransferEngineState state = _stateService.Get(engineId);, and pass the state to the TrainSubroutineAsync call.


src/SIL.Machine.AspNetCore/Services/SmtTransferEngineService.cs line 175 at r1 (raw file):

                        return await TrainSubroutineAsync();
                    },
                    cancellationToken: cancellationToken

I don't think we should make this transaction cancelable, i.e. we should pass in CancellationToken.None. Once hybridEngine.TrainSegmentAsync has been called, we don't want to be able to cancel the request, since the SMT model has been updated on the disk.

@johnml1135
Copy link
Collaborator Author

src/SIL.Machine.AspNetCore/Services/SmtTransferEngineService.cs line 57 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

You should use ct to be safe.

Done

@johnml1135
Copy link
Collaborator Author

src/SIL.Machine.AspNetCore/Services/SmtTransferEngineService.cs line 83 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

You should use ct to be safe.

done

@johnml1135
Copy link
Collaborator Author

src/SIL.Machine.AspNetCore/Services/SmtTransferEngineService.cs line 157 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

You should be able to set the state here, i.e. SmtTransferEngineState state = _stateService.Get(engineId);, and pass the state to the TrainSubroutineAsync call.

It't a bit cleaner - ok.

@johnml1135
Copy link
Collaborator Author

src/SIL.Machine.AspNetCore/Services/SmtTransferEngineService.cs line 175 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

I don't think we should make this transaction cancelable, i.e. we should pass in CancellationToken.None. Once hybridEngine.TrainSegmentAsync has been called, we don't want to be able to cancel the request, since the SMT model has been updated on the disk.

Is that better?

@johnml1135
Copy link
Collaborator Author

src/SIL.Machine.AspNetCore/Services/NmtEngineService.cs line 59 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

You should use ct just to be safe.

ok

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Enkidu93 and @johnml1135)


src/SIL.Machine.AspNetCore/Services/SmtTransferEngineService.cs line 172 at r2 (raw file):

                        );
                        await TrainSubroutineAsync(state, ct);
                        return;

The return is unnecessary.

@johnml1135
Copy link
Collaborator Author

src/SIL.Machine.AspNetCore/Services/SmtTransferEngineService.cs line 172 at r2 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

The return is unnecessary.

You're right.

Copy link
Contributor

@ddaspit ddaspit left a 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Enkidu93)

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Enkidu93)

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 70.14925% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 67.10%. Comparing base (707d7dc) to head (71823cf).

Files Patch % Lines
...IL.Machine.AspNetCore/Services/NmtEngineService.cs 0.00% 20 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #184   +/-   ##
=======================================
  Coverage   67.09%   67.10%           
=======================================
  Files         441      441           
  Lines       34826    34849   +23     
  Branches     4669     4668    -1     
=======================================
+ Hits        23368    23386   +18     
- Misses      10365    10370    +5     
  Partials     1093     1093           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@ddaspit ddaspit left a 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 r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Enkidu93)

@johnml1135 johnml1135 merged commit 9870e24 into master Apr 17, 2024
4 checks passed
@ddaspit ddaspit deleted the with_transaction branch April 22, 2024 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants