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

Add the -v/--version option to verdi export migrate #3910

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Apr 8, 2020

Fixes #3909

The default behavior remains the same and if not specified the export
archive will be migrated to the latest version. However, with the flag
any other version can be chosen, as long as it constitutes a forward
migration as backward migrations are not supported.

@sphuber sphuber requested a review from CasperWA April 8, 2020 08:49
@sphuber sphuber force-pushed the feature/3909/verdi-export-migrate-version branch from 11c971e to 57145b2 Compare April 8, 2020 09:05
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 @sphuber.

Good to see that all cmdline stuff is pulled out of the importexport module!

This seems to be a nice little "fix" for stopping underway in the migration as well.

There are some other migration tests that seem to fail, but other than that I only found a small "typo" and otherwise approve this change.

See specific migration functions for detailed descriptions.

:param metadata: the content of an export archive metadata.json file
:param data: the content of an export archive data.json file
:param folder: SandboxFolder in which the archive has been unpacked (workdir)
:param version: the version to migrate to, by default is the current export version
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
:param version: the version to migrate to, by default is the current export version
:param version: the version to migrate to, by default the current export version

or it is.

@sphuber sphuber force-pushed the feature/3909/verdi-export-migrate-version branch from 57145b2 to e49231e Compare April 8, 2020 10:06
@CasperWA
Copy link
Contributor

CasperWA commented Apr 8, 2020

Since you're adding functionality to migrate_recursively could you also make a test for the new feature, directly testing the function?

Furthermore, the failing test (that I see you have now fixed) was originally a request by @ltalirz that upon failure the exit code should be non-zero. Can you confirm that this is still the case? (Since we're raising in all cases, I guess this is still the case, but just to be sure.) There should probably already be another test for this?

@sphuber
Copy link
Contributor Author

sphuber commented Apr 8, 2020

Since you're adding functionality to migrate_recursively could you also make a test for the new feature, directly testing the function?

Good point, will add it

Furthermore, the failing test (that I see you have now fixed) was originally a request by @ltalirz that upon failure the exit code should be non-zero. Can you confirm that this is still the case? (Since we're raising in all cases, I guess this is still the case, but just to be sure.) There should probably already be another test for this?

The behavior is still the same, I simply made the utility function raise instead of echo'ing directly. The CLI now catches this exception and turns it into a critical echo. We should not include echo functionality in non-CLI code.

@codecov
Copy link

codecov bot commented Apr 8, 2020

Codecov Report

Merging #3910 into develop will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3910   +/-   ##
========================================
  Coverage    78.00%   78.01%           
========================================
  Files          457      457           
  Lines        33708    33714    +6     
========================================
+ Hits         26294    26301    +7     
+ Misses        7414     7413    -1     
Flag Coverage Δ
#django 70.01% <100.00%> (+<0.01%) ⬆️
#sqlalchemy 70.85% <100.00%> (+<0.01%) ⬆️
Impacted Files Coverage Δ
aiida/cmdline/commands/cmd_export.py 92.50% <100.00%> (+0.39%) ⬆️
aiida/transports/plugins/local.py 80.46% <0.00%> (+0.25%) ⬆️

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 676a83e...08f38d0. Read the comment docs.

@sphuber sphuber force-pushed the feature/3909/verdi-export-migrate-version branch from e49231e to 2a3a28f Compare April 8, 2020 10:30
@CasperWA
Copy link
Contributor

CasperWA commented Apr 8, 2020

Furthermore, the failing test (that I see you have now fixed) was originally a request by @ltalirz that upon failure the exit code should be non-zero. Can you confirm that this is still the case? (Since we're raising in all cases, I guess this is still the case, but just to be sure.) There should probably already be another test for this?

The behavior is still the same, I simply made the utility function raise instead of echo'ing directly. The CLI now catches this exception and turns it into a critical echo. We should not include echo functionality in non-CLI code.

I completely agree, as per my original review comment.
I just wanted to mention it (and tag @ltalirz) and make doubly sure it still satisfies his specific use case :)

@sphuber sphuber requested a review from CasperWA April 8, 2020 11:51
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 additional test.

Since I anyway found a wrong comment in the test you updated (in fact, you may remove the comment completely), I also added another suggested change - just because :)

Just ping me after the change and I'll approve.

tests/tools/importexport/migration/test_migration.py Outdated Show resolved Hide resolved
tests/tools/importexport/migration/test_migration.py Outdated Show resolved Hide resolved
@ltalirz
Copy link
Member

ltalirz commented Apr 8, 2020

I'm sure raising an exception/echo_critical will result in a nonzero exit code, so no complaints from my side.

The default behavior remains the same and if not specified the export
archive will be migrated to the latest version. However, with the flag
any other version can be chosen, as long as it constitutes a forward
migration as backward migrations are not supported.
@sphuber sphuber force-pushed the feature/3909/verdi-export-migrate-version branch from 2a3a28f to 08f38d0 Compare April 8, 2020 12:20
@sphuber
Copy link
Contributor Author

sphuber commented Apr 8, 2020

@CasperWA done and done

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 @sphuber ! Merge away 🚀

@sphuber sphuber merged commit 38c4684 into aiidateam:develop Apr 8, 2020
@sphuber sphuber deleted the feature/3909/verdi-export-migrate-version branch April 8, 2020 12:37
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 --version option to verdi export migrate
3 participants