-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Make Sense.PartOfSpeech an object instead of a string #1350
Conversation
Also getting some errors in FwLiteProjectSync.Tests.SyncTests.PartsOfSpeechSyncInEntries such as "One or more errors occurred. (The instance of entity type 'PartOfSpeech' cannot be tracked because another instance with the key value '{Id: a8e41fd3-e343-4c7c-aa05-01ea3dd5cfb5}' is already being tracked." Don't have time to track those down right now, but recording the errors here so that I remember to track them down later. |
C# Unit Tests104 tests 104 ✅ 5s ⏱️ Results for commit 1e14f4c. ♻️ This comment has been updated with latest results. |
One place this is happening is in BulkCreateEntries during ImportProject: if more than one sense had the same part of speech (very likely), then the code is currently trying to create those as separate DB entries rather than as references to the same one. I need to change how the DB handles PartOfSpeech to be a relation (looked up by PartOfSpeechId) here. |
@hahn-kev - I've gotten most of this working, but I could use some help with some of the remaining test failures. I know there's code somewhere that's creating duplicate parts of speech in the database instead of simply making references, but I'm not sure exactly where it is. There's about one level of abstraction more than I'm managing to fit in my head right now, and I suspect that extra level of abstraction is where I would need to look to fix this issue. |
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.
this looks like a good start, this still some things to do. I've fixed a few things by changing the CreateSenseChange
to only use the PartOfSpeech Id, and I've fixed some tests which were failing by always querying out the PartOfSpeech object in the relevant places.
@hahn-kev - Addressed your review comments so far. I still plan to make one more change (see #1350 (comment) for details) tomorrow to make GetPartOfSpeech make a single query instead of two, but I'm otherwise done with your suggested changes so far and ready to start working on frontend code. |
UI unit Tests12 tests 12 ✅ 0s ⏱️ Results for commit 1e14f4c. ♻️ This comment has been updated with latest results. |
dd04723
to
dc31a2f
Compare
Rebased on top of current develop since some recent PRs were touching viewer-related code and I want to solve merge conflicts before they have a chance to happen. |
I now have the frontend working at first glance with the test Sena-3 project; screenshots in PR description above. I'm sure there are bugs that I'll reveal once I start trying to sync projects, but the Sena-3 test data has now been converted to use objects and all the parts of speech that Sena-3 references have been put into the data that entry-data.ts exports. Now I'll start actually using this with other test projects, to identify any further bugs. Then once I can't find any more obvious bugs, I'll mark the PR ready for review. |
@hahn-kev - How do I update DataModelSnapshotTests.VerifyDbModel.verified.txt so that the LcmCrdt.Tests.DataModelSnapshotTests.VerifyDbModel test will pass? My change to the type of Sense.PartOfSpeech is obviously what's causing this test failure here. Besides that test, all backend tests passing except for one:
I might need some help figuring that one out too; it's not clear to me why This is getting very close to being ready. |
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.
Hum, I just realized an issue. Sense now has 2 properties which can specify the PartOfSpeech Id, either the PartOfSpeechId property or the PartOfSpeech object Id property. This means the API consumer could specify different Ids in each property, either when creating or updating the PoS. I believe our frontend only changes the PosId on the sense, not the object so when we send the Sense to be updated it also has this conflict. I think the most sensible thing would be to validate that the Ids match on both and if they don't then we throw a validation error. We could make an exception and say that if the PoS object is null and the PoSId on the sense is not then we use the value on the Sense, this would work best with our existing frontend as we would just need to set the object to null before we send it to the api. This won't represent a problem for FW Sync as both properties will always be the same.
For the verification test you copy/rename DataModelSnapshotTests.VerifyDbModel.received.txt to DataModelSnapshotTests.VerifyDbModel.verified.txt overwriting the existing one. You can read about verify here if you want. As for the test, it's ending up null because we don't touch the PartOfSpeech property at all in the DiffUpdate. I wouldn't worry too much about it as that's a fair bit of code that needs to be cleaned up since we refactored our update code with the whole before after convention. You can just configure that test to ignore the PartOfSpeech property like similar to the other properties it's excluding. |
Yep, now that #1344 is approved I'm planning to rebase this PR on top of the validation and then add some validation to make sure that PartOfSpeech.Id == PartOfSpeechId (and handle null / Guid.Empty sensibly). Glad to see we're on the same page as far as the design. |
These tests run a Send/Receive as part of the test and are too slow to be considered unit tests.
…her PartOfSpeechId or PartOfSpeech are defined
Also adjust test to expect an exception for missing parts of speech.
Auto-generated types for frontend have picked up the change of Sense.PartOfSpeech from a string to an object, so now it's time to change the frontend code accordingly.
More UI changes will ripple out from here
Having the complete list ensures that the Sena-3 test project's grammar picker, and the display of the parts of speech, will work.
Unit tests expects a specific exception type, so we must be consistent
The SenseDiffToUpdate method specifically excludes the PartOfSpeech object now, so the test shouldn't expect PartOfSpeech updated.
dd0c5a9
to
93bc1b5
Compare
00335e4
to
4890857
Compare
# Conflicts: # backend/FwLite/LcmCrdt.Tests/DataModelSnapshotTests.VerifyDbModel.verified.txt
@rmunn I've pushed a fix for the test that was failing (the sync tests operate on the same data, so one test failure can effect others). The test in question was using a part of speech before it was created which was causing the problem. I also fixed some issues in the CreateSenseChange as it would add references to Parts of speech and Semantic domains even if they were deleted, that's fixed now too. |
@hahn-kev - Thanks to your fixes, this seems to be working now: all tests are passing, both in GHA and locally on my machine, and I've addressed all the review comments you left earlier. Any other changes needed before this is ready to merge? |
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.
looks good, take a look at the one change I did to avoid a concurrency issue
Fixes #1232.
Backend and frontend changes appear to be working; here's the frontend viewer showing the Sena-3 test data:
And here's the sense display, showing that all the parts of speech are being looked up properly:
There's almost certainly more work to be done, but this seems to be a good start.