dataverse icon indicating copy to clipboard operation
dataverse copied to clipboard

IQSS/10814 Improve dataset version differencing

Open qqmyers opened this issue 1 year ago • 1 comments

What this PR does / why we need it: The change in this PR makes differencing during the UpdateDatasetVersionCommand for a dataset with 10K files go from taking ~ 8 seconds to <4 seconds (cold start) or even 17 ms (when the info in the versions has been read before). Presumably it improves the Version table on the dataset as well though I haven't tested that at scale.

The PR also includes some cleanup of the terms comparison - basically folding the possible null TermsOfUseAndAccess on the original or new version cases into one case by creating an empty TermsOfUseAndAccess for whichever one is missing, and adding a method to reduce repeated code.

Which issue(s) this PR closes:

Closes #10814

Special notes for your reviewer: The test currently tests against the original algorithm and against a hardcoded expected value in the test. There's no real reason to test against the original algorithm except to validate that the hardcoded expected values in the test are correct, so I've marked the test code doing the check against the original as @Deprecated.

The current tests don't do anything to test scaling (they basically try adding one file in each category (changed metadata, changed variable-level metadata, added file, deleted file, replaced file) and see if they differences are calculated as expected/as before. If someone wants to add a loop with ~1K files, we could probably start seeing the difference.

Suggestions on how to test this: QA should probably both confirm that the differencing appears to work for the Unit test cases (add a version or two and change metadata, add a file, delete a file, replace a file between versions) and make sure the difference makes sense. Checking the changed variable-level metadata probably requires testing with a tab file and perhaps editing with the DataCurator (Borealis tool for editing variable metadata) or editing in the db.

Scalability can be estimated by finding/creating a published dataset with several K files and checking the time to load the version table. (Maybe there's an API call?) I think all we need is to verify this is much faster/ worth the effort. (I added logging statements to print the start/stop times before/after the new/old algorithms and then ran the code on a dataset with 10K files. I've left a timing statement for the new algorithm in for fine logging, but the original code doesn't have any.)

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

Is there a release notes update needed for this change?: included - not sure it is needed, but perhaps as part of a general improved scalability note for multiple PRs.

Additional documentation:

qqmyers avatar Aug 29 '24 20:08 qqmyers

Coverage Status

coverage: 22.31% (+0.5%) from 21.856% when pulling 89892a4862b780d47a90699c729c798726a2c507 on GlobalDataverseCommunityConsortium:IQSS/10814-Improve_dataset_version_differencing into b28812b42bb2babd6d4c2328fad791fc41d9183e on IQSS:develop.

coveralls avatar Aug 29 '24 21:08 coveralls

Testing passed, merging PR

Testing of 10818.docx

ofahimIQSS avatar Nov 19 '24 16:11 ofahimIQSS