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

SF-3193 Fix additional training data option not visible #2994

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

RaymondLuong3
Copy link
Collaborator

@RaymondLuong3 RaymondLuong3 commented Feb 5, 2025

After the draft generation steps component was converted to not subclass the subscription disposable class, the subscribe method needed to be explicitly called in order for the logic to enable additional training data to be run. I have also added a test which will catch future regressions showing the additional training data option.


This change is Reviewable

@RaymondLuong3 RaymondLuong3 added critical path PRs that are on our critical path and need attention to keep things moving. Priority 2nd. will require testing PR should not be merged until testers confirm testing is complete labels Feb 5, 2025
Copy link

codecov bot commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.38%. Comparing base (0bf447a) to head (c3ac2d4).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...neration-steps/draft-generation-steps.component.ts 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2994      +/-   ##
==========================================
+ Coverage   82.33%   82.38%   +0.04%     
==========================================
  Files         543      543              
  Lines       31663    31663              
  Branches     5147     5125      -22     
==========================================
+ Hits        26069    26084      +15     
+ Misses       4840     4823      -17     
- Partials      754      756       +2     

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

Copy link
Collaborator

@Nateowami Nateowami left a 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 2 files reviewed, 1 unresolved discussion (waiting on @RaymondLuong3)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 229 at r1 (raw file):

        filterNullish(),
        map(async projectDoc => {
          this.projectChanged = true;

Why can't we use a utility like distinctUntilChanged

Copy link
Collaborator Author

@RaymondLuong3 RaymondLuong3 left a 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 2 files reviewed, 1 unresolved discussion (waiting on @Nateowami)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 229 at r1 (raw file):

Previously, Nateowami wrote…

Why can't we use a utility like distinctUntilChanged

I'm not sure how that would help in this situation. The trainingDataQuery will emit based on any updates to the query. We just have to be sure that we don't reset the initial training data files unless the user changes projects. (This might never happen since the user would have to paste a URL into the browser.)

@marksvc marksvc self-assigned this Feb 6, 2025
Copy link
Collaborator

@siltomato siltomato left a 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 2 files reviewed, 2 unresolved discussions (waiting on @marksvc, @Nateowami, and @RaymondLuong3)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 228 at r1 (raw file):

        takeUntilDestroyed(this.destroyRef),
        filterNullish(),
        map(async projectDoc => {

Would switchMap be more appropriate here?

Copy link
Collaborator

@siltomato siltomato left a 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 2 files reviewed, 3 unresolved discussions (waiting on @marksvc, @Nateowami, and @RaymondLuong3)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 253 at r1 (raw file):

        if (this.projectChanged) {
          // Set the selection based on previous builds
          this.projectChanged = false;

This took me a minute to understand. Maybe renaming the flag to something like isTrainingDataInitialized or isProjectTrainingDataInitialized (and inverting it) would read better?

if (!this.isTrainingDataInitialized) {
    this.isTrainingDataInitialized = true;

    // Set the selection based on previous builds
    this.setInitialTrainingDataFiles(this.availableTrainingFiles.map(d => d.dataId));
}

Code quote:

this.projectChanged = false;

Copy link
Collaborator

@marksvc marksvc 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 @Nateowami, @RaymondLuong3, and @siltomato)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 253 at r1 (raw file):

Previously, siltomato wrote…

This took me a minute to understand. Maybe renaming the flag to something like isTrainingDataInitialized or isProjectTrainingDataInitialized (and inverting it) would read better?

if (!this.isTrainingDataInitialized) {
    this.isTrainingDataInitialized = true;

    // Set the selection based on previous builds
    this.setInitialTrainingDataFiles(this.availableTrainingFiles.map(d => d.dataId));
}

Yeah, perhaps
isProjectTrainingDataInitialized or
isInitialTrainingDataSetForProject.


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 245 at r1 (raw file):

        })
      )
      .subscribe(() => {

❓ I don't understand why it's okay now but wasn't before, since we are still using .subscribe( and takeUndilDestroyed(this.destroyRef). Was the this.trainingDataSub...subscribe( not calling something that was needed/adequate but the this.activatedProjectprojectDoc$...map(...().subscribe( is calling what is needed/adequate??


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 247 at r1 (raw file):

      .subscribe(() => {
        this.availableTrainingFiles = [];
        if (this.activatedProject.projectDoc?.data?.translateConfig.draftConfig.additionalTrainingData) {

❓ Why the change to use this.activatedProject? Is there a reason we want to be sure we are operating on the activatedProject rather than the next projectDoc coming down the line from this.activatedProject.projectDoc$? It seems like there could in principle be a mismatch between the local projectDoc and the this.activatedProject.projectDoc.

@RaymondLuong3 RaymondLuong3 force-pushed the fix/sf-3193-fix-additional-data branch from 3398d37 to b63086b Compare February 6, 2025 19:57
Copy link
Collaborator Author

@RaymondLuong3 RaymondLuong3 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 2 files reviewed, 3 unresolved discussions (waiting on @marksvc and @siltomato)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 228 at r1 (raw file):

Previously, siltomato wrote…

Would switchMap be more appropriate here?

Thanks, that should be the right way to go


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 245 at r1 (raw file):

Previously, marksvc wrote…

❓ I don't understand why it's okay now but wasn't before, since we are still using .subscribe( and takeUndilDestroyed(this.destroyRef). Was the this.trainingDataSub...subscribe( not calling something that was needed/adequate but the this.activatedProjectprojectDoc$...map(...().subscribe( is calling what is needed/adequate??

The issue was that before there were two different observables, and the subscription to the merge(this.trainingDataQuery.localChanges$, ...) was active, but the observable for the projectDoc$ was not subscribed to. Since it was not subscribed, all the logic is never run. So in this change, I updated it to only be 1 observable to be subscribed to.


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 247 at r1 (raw file):

Previously, marksvc wrote…

❓ Why the change to use this.activatedProject? Is there a reason we want to be sure we are operating on the activatedProject rather than the next projectDoc coming down the line from this.activatedProject.projectDoc$? It seems like there could in principle be a mismatch between the local projectDoc and the this.activatedProject.projectDoc.

There will not be a mismatch since we can have confidence that the projectId and the projectDoc will be for the same project. The main reasoning for the change is because we are doing a switchMap transformation of the observable, and preserving the projectDoc just for the id was not necessary


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 253 at r1 (raw file):

Previously, marksvc wrote…

Yeah, perhaps
isProjectTrainingDataInitialized or
isInitialTrainingDataSetForProject.

Done.

Copy link
Collaborator

@siltomato siltomato 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 r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @marksvc)

Copy link
Collaborator

@siltomato siltomato 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 2 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @marksvc)

@RaymondLuong3 RaymondLuong3 added ready to test and removed will require testing PR should not be merged until testers confirm testing is complete labels Feb 6, 2025
Copy link
Collaborator

@marksvc marksvc 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 r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @RaymondLuong3)


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 245 at r1 (raw file):

Previously, RaymondLuong3 (Raymond Luong) wrote…

The issue was that before there were two different observables, and the subscription to the merge(this.trainingDataQuery.localChanges$, ...) was active, but the observable for the projectDoc$ was not subscribed to. Since it was not subscribed, all the logic is never run. So in this change, I updated it to only be 1 observable to be subscribed to.

Wow. Thank you.


src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-generation-steps/draft-generation-steps.component.ts line 247 at r1 (raw file):

Previously, RaymondLuong3 (Raymond Luong) wrote…

There will not be a mismatch since we can have confidence that the projectId and the projectDoc will be for the same project. The main reasoning for the change is because we are doing a switchMap transformation of the observable, and preserving the projectDoc just for the id was not necessary

Right, there is no local projectDoc. Thank you.

@Nateowami Nateowami force-pushed the fix/sf-3193-fix-additional-data branch from b63086b to c3ac2d4 Compare February 7, 2025 15:58
@RaymondLuong3 RaymondLuong3 merged commit ebe4997 into master Feb 7, 2025
17 checks passed
@RaymondLuong3 RaymondLuong3 deleted the fix/sf-3193-fix-additional-data branch February 7, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical path PRs that are on our critical path and need attention to keep things moving. Priority 2nd. ready to test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants