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

Migrations: Implement adapter method that copies values between two fields in all documents in a collection #2262

Conversation

eecavanna
Copy link
Collaborator

In this branch, I implemented an adapter method named copy_value_from_field_to_field_in_each_document, which migrator authors can use to copy all values in one field of a document into another field of that same document (creating the latter field if it doesn't already exist), for every document in a given collection.

Previously, migrator authors could do this by iterating over documents in Python. This new adapter method delegates the iteration to MongoDB.

Fixes #2259

Copy link

PR Preview Action v1.4.8
🚀 Deployed preview to https://microbiomedata.github.io/nmdc-schema/pr-preview/pr-2262/
on branch gh-pages at 2024-11-12 22:26 UTC

@kheal
Copy link
Contributor

kheal commented Nov 12, 2024

@eecavanna Did you want to add implementing this method in to https://github.com/microbiomedata/nmdc-schema/blob/main/nmdc_schema/migrators/partials/migrator_from_11_0_3_to_11_1_0/migrator_from_11_0_3_to_11_1_0_part_2.py ? If so, I think doing that in this PR makes sense.

Disregard - I see that this only makes a new field and that you'll need your second adaptor method to delete the contents of the original before implementing.

Copy link
Contributor

@kheal kheal left a comment

Choose a reason for hiding this comment

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

This all looks good from my perspective, though I am not able to give the most thorough of review since these methods are a bit new to me. All the documentation and doctests make sense to me and match the descriptions.

@eecavanna
Copy link
Collaborator Author

Thanks for reviewing this! That level of review is helpful for me (e.g. in case I made a mistake somewhere while implementing this in haste). Rather than merge this in, I'd prefer to merge the third PR I opened this afternoon, since it includes these changes. That PR is: #2265

@eecavanna
Copy link
Collaborator Author

On second thought, I implemented that third PR in a way where this can be merged in independently. I'll go ahead and merge this in.

@eecavanna eecavanna merged commit 60fc9b0 into main Nov 12, 2024
3 checks passed
@eecavanna eecavanna deleted the 2259-migrations-implement-adapter-method-copy_value_from_field_to_field_in_each_document branch November 12, 2024 23:37
@eecavanna eecavanna mentioned this pull request Nov 12, 2024
6 tasks
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.

Migrations: Implement adapter method copy_value_from_field_to_field_in_each_document
2 participants