-
Notifications
You must be signed in to change notification settings - Fork 8
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
Extract transformation functions into migration-specific classes #1155
Extract transformation functions into migration-specific classes #1155
Conversation
I don't plan to update the |
Now that we have discussed the changes, I will update the |
…ture-that-specifies-a-migration-collections-to-be-migrated-source-schema-and-destination-schema
I tried setting up a local |
I added the "help wanted" tag because I want help with testing this branch: either (a) setting up a test environment on my local machine or (b) someone else doing the testing. |
# logger.info(f"Starting {tdk}-specific migrations") | ||
# for current_study in tdv: | ||
# migrator.migrate_uc_gold_study_identifiers_7_8_0_to_8_0_0(current_study) | ||
end_dict[tdk] = migrator.apply_changes_recursively_by_key(tdv, set(migrateable_slots)) |
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.
apply_changes_recursively_by_key
looks at a root element and recurses through the object and coerces CURIEs so that they all have a prefix (the salvage prefix).
Acceptance criteria (at least):
|
The example/tutorial "migration" class is named: |
Hi @turbomam, I am done making changes to this branch and am ready for it to be reviewed and, if appropriate, merged into
Here's a link to a diff that shows all of those changes (except the merge of |
In bullet point 4.2 of the description, I wrote:
Here's roughly what I have in mind for that (this would be in the ##- Instead of this hard-coded, migration-specific line...
##- migrator = Migrator_from_7_8_0_to_8_0_0()
##- We could do this...
initial_version = "<comes from CLI options>"
target_version = "<comes from CLI options>"
# Select a migrator class based upon the specified initial and target schema versions.
migrator_registry = [
{"class": Migrator_from_7_7_2_to_7_8_0, "from": "7.7.2", "to": "7.8.0"},
{"class": Migrator_from_7_8_0_to_8_0_0, "from": "7.8.0", "to": "8.0.0"},
]
migrator = None # assume no compatible migrator class exists
for item in migrator_registry: # look for a compatible migrator class
if item["from"] == initial_version and item["to"] == target_version:
migrator = item["class"]() # instantiate the compatible migrator class
break
if migrator is None:
raise NotImplementedError("No migrator has been implemented for that version jump.") I don't plan to include that in this branch because I don't want to complicate the branch (it would involve updating at least one command in a |
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.
thanks!
@turbomam , I just realized Docs: https://docs.python.org/3/library/typing.html#typing.TypeAlias |
I went ahead and removed the type aliases. I'm OK with this being merged in. |
Summary of changes
MigratorBase
class, which is a migration-agnostic base class from which migration-specific child classes will inherit thingsv7.7.2
tov7.8.0
migrationv7.8.0
tov8.0.0
migrationMigrator_from_A_B_C_to_X_Y_Z
click
handler function to "follow the agenda" (i.e. invoke the specified transformation functions) of whatever migration-specific child class the function instantiatesMigrator_from_7_8_0_to_8_0_0
child class