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

Deduplicate code for tests of archive migration code #3924

Merged
merged 1 commit into from
Apr 14, 2020

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Apr 11, 2020

Fixes #3923

Each archive migration was being tested on a archives included in this
repo in tools/fixtures/export/migrate and the test was always the
same. Simply take an archive, migrate it to the next version with the
appropriate method and check that both metadata and data dictionaries of
the migrated data match that of the reference archive. This same test
was implemented for each migration method, but has now been centralized
in a single test using pytest to parametrize the versions.

The testing on external archives from aiida-export-migration-testing
has also been streamlined a bit, by defining a new base class called
ArchiveMigrationTest that provides some utility methods.

@sphuber sphuber requested a review from CasperWA April 11, 2020 20:07
@codecov
Copy link

codecov bot commented Apr 11, 2020

Codecov Report

Merging #3924 into develop will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3924      +/-   ##
===========================================
- Coverage    78.21%   78.21%   -0.01%     
===========================================
  Files          460      460              
  Lines        34035    34036       +1     
===========================================
  Hits         26620    26620              
- Misses        7415     7416       +1     
Flag Coverage Δ
#django 70.24% <100.00%> (-0.01%) ⬇️
#sqlalchemy 71.10% <100.00%> (+<0.01%) ⬆️
Impacted Files Coverage Δ
aiida/tools/importexport/migration/v03_to_v04.py 90.95% <100.00%> (+0.04%) ⬆️
aiida/transports/plugins/local.py 80.20% <0.00%> (-0.26%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 39d8ea0...dd3d0e9. Read the comment docs.

@sphuber sphuber force-pushed the fix/3923/archive-migration-tests branch from 4cc5289 to 0662057 Compare April 13, 2020 21:59
Copy link
Contributor

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Seems like an update that should've been done some time ago... :)

Concerning my comments, I am aware of the more weird things happening from v0.3 to v0.4, which is due to a migration (TrajectoryData) needing the folder and the node files, and not just the metadata and data JSON files. If it is not possible to use the new migrate method from ArchiveMigrationTest, then that's fine, but should maybe be commented upon, if it isn't already somewhere in there.
Also, the test function name can still be updated to match the rest :)

But all in all, no major changes to be done here that I can find - as long as all tests pass and the coverage does not change significantly.

@sphuber
Copy link
Contributor Author

sphuber commented Apr 14, 2020

@CasperWA I addressed your comments

Copy link
Contributor

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

I found a single pylint disable comment that can be removed, and to round it off, I think there may be an a too much in your first commit message.
After these very minor updates I will approve this as is.

@@ -432,7 +432,7 @@ def add_extras(data):
data.update({'node_extras': node_extras, 'node_extras_conversion': node_extras_conversion})


def migrate_v3_to_v4(metadata, data, folder, *args): # pylint: disable=unused-argument
def migrate_v3_to_v4(metadata, data, *args): # pylint: disable=unused-argument
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def migrate_v3_to_v4(metadata, data, *args): # pylint: disable=unused-argument
def migrate_v3_to_v4(metadata, data, *args):

Each archive migration was being tested on a archives included in this
repo in `tools/fixtures/export/migrate` and the test was always the
same. Simply take an archive, migrate it to the next version with the
appropriate method and check that both metadata and data dictionaries of
the migrated data match that of the reference archive. This same test
was implemented for each migration method, but has now been centralized
in a single test using pytest to parametrize the versions.

The testing on external archives from `aiida-export-migration-testing`
has also been streamlined a bit, by defining a new base class called
`ArchiveMigrationTest` that provides some utility methods.
@sphuber sphuber force-pushed the fix/3923/archive-migration-tests branch from e03d572 to dd3d0e9 Compare April 14, 2020 09:11
@sphuber
Copy link
Contributor Author

sphuber commented Apr 14, 2020

Thanks for the changes!

Thanks for the review 👍

I found a single pylint disable comment that can be removed,

Done

and to round it off I think there may be an a too much in your first commit message.

I might be blind to double a's as a result of my name, because I could not spot it.
If you could be more specific I can fix it when I merge

@CasperWA
Copy link
Contributor

and to round it off I think there may be an a too much in your first commit message.

I might be blind to double a's as a result of my name, because I could not spot it.
If you could be more specific I can fix it when I merge

So very true. And so very tragic... 😆

Anyway, there is something funky with your first commit in the first sentence, around (...) tested on a archives included in this repo in (...) specifically the a archives-part.

@sphuber sphuber merged commit 9a75173 into aiidateam:develop Apr 14, 2020
@sphuber sphuber deleted the fix/3923/archive-migration-tests branch April 14, 2020 09:32
@sphuber
Copy link
Contributor Author

sphuber commented Apr 14, 2020

Thanks @CasperWA I will rebase PR #3912 now which should then also be ready

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.

Remove code duplication in export archive migration tests
2 participants