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

Provide solution to correct metadata corruption due to improper migration for "Organization" -> "Affiliation" change #283

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

candleindark
Copy link
Member

This PR closes #276.

Note: This PR is based on #279. To get the proper commit in the PR, merge with the master branch after #279 is merged.

This commit improves `migrate()` by removing bugs, making it
more readable, adding argument validations, etc. However,
it doesn't change the migration of metadata instances this
function currently intend to implement, per my best guess.
The following are descriptions of the more prominent
improvements:

1. Correct the type annotation of `to_version` (Bug fix)
2. Validate that the provided metadata instance and the
   target version specifies valid DANDI schema versions
3. Ensure the optional validation of the provided instance
   against its specified schema is done before any migration
   operation, to achieve greater consistency.
4. Return the instance unchanged when DANDI schema version
   of the given instance is equal to the target version instead
   (Bug fix).
5. Consistently use the tuple representations of DANDI schema
   versions to route the execution flow of migration operations
   to ensure all cases of the relation between the schema version
   of the instance and target version are covered.
6. Condition the migration to "0.6.0" and beyond on the target
   version being at least "0.6.0". (Bug fix)
7. Copy input instance for migration only immediately before
   migration operations
7. Rename local variables to improve readability
8. Handle the situation in which the input metadata instance not
   having the "assetsSummary" field

Co-authored-by: Yaroslav Halchenko <[email protected]>
Co-authored-by: John T. Wodder II <[email protected]>
Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 95.52239% with 3 lines in your changes missing coverage. Please review.

Project coverage is 92.52%. Comparing base (6fd04fb) to head (8f28e83).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
dandischema/metadata.py 92.68% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (6fd04fb) and HEAD (8f28e83). Click for more details.

HEAD has 504 uploads less than BASE
Flag BASE (6fd04fb) HEAD (8f28e83)
unittests 528 24
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #283      +/-   ##
==========================================
- Coverage   97.54%   92.52%   -5.03%     
==========================================
  Files          16       16              
  Lines        1753     1793      +40     
==========================================
- Hits         1710     1659      -51     
- Misses         43      134      +91     
Flag Coverage Δ
unittests 92.52% <95.52%> (-5.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

…stance

Test for the helper func is included in this
commit as well
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.

Add proper migration for "Organization" -> "Affiliation" change
1 participant