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

Automate export file migration for verdi import #2820

Merged

Conversation

CasperWA
Copy link
Contributor

@CasperWA CasperWA commented May 1, 2019

Fixes #2739.

Invoke verdi export migrate in verdi import, if it turns out the export file archive cannot be imported due to an IncompatibleArchiveVersionError.

The default is to automatically migrate it (via a temporary file).

Introduce the --non-interactive flag for verdi import.
This will avoid printing confirm messages.

Add hidden --manual-migration flag to turn off automatic migration.
This is hidden, because it should only be used for tests, in order to switch the default to not do automatic migration. This should also make sure that an error code != 0 is still present when automatic migration is not performed on old export files.

@coveralls
Copy link

coveralls commented May 1, 2019

Coverage Status

Coverage decreased (-0.1%) to 72.693% when pulling caa7efc on CasperWA:fix_2739_auto_migrate_verdi_import into b39a9be on aiidateam:develop.

Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

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

Very cool, thanks a lot @CasperWA !

Just a few comments - you know me ;-)

aiida/backends/tests/cmdline/commands/test_import.py Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_import.py Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_import.py Show resolved Hide resolved
aiida/cmdline/commands/cmd_import.py Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_import.py Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_import.py Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_import.py Outdated Show resolved Hide resolved
@CasperWA CasperWA force-pushed the fix_2739_auto_migrate_verdi_import branch from 773ebf5 to c4ea7fb Compare May 2, 2019 10:12
@CasperWA CasperWA requested a review from ltalirz May 2, 2019 10:13
@CasperWA CasperWA force-pushed the fix_2739_auto_migrate_verdi_import branch 2 times, most recently from c1e19c5 to 930e767 Compare May 8, 2019 10:12
Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

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

thanks @CasperWA , code duplication already went down a lot!

I think there is a bit more to reduce in cmd_import but this does not need to be done in this PR

For reference, I would suggest:

  • archives should simply be processed one by one (there is no need to create and validate the full list of archives before you even start. e.g. rm file1 file2 file3 also will start removing files and only stop when it encounters a file that isn't there)
  • when you look at an archive you figure out whether it's a url or not. if url, validate URL and call function to download. you replace url by path to downloaded file and the following code runs inside a sandbox folder
  • from now on all code is shared...

Fixes aiidateam#2739.

Invoke `verdi export migrate` in `verdi import`
if it turns out the export file archive cannot be imported
due to an IncompatibleArchiveVersionError.

The default is to automatically migrate it (via a temporary file).

Introduce the `--non-interactive` flag for `verdi import`.

Add tests for new functionality.

Make sure `--non-interactive` does not print confirm messages.
Make sure old export files are automatically migrated, both local files and from URLs.

Introduce the `--migration`/`--no-migration` choice to force migration, if needed
or avoid automatic migration.
This makes sure that an error code != 0 is still present,
when automatic migration is not performed on old export files.

Following behaviour is expected and implemented:

| `migration` | `non_interactive` | Result CLI | Result script |
| ------------- | ---------------------- | ------------- | ---------------- |
| `True`* | `False`* | Query user, migrate | Migrate |
| `True`* | `True` | No query, migrate | Migrate |
| `False` | `False`* | No query, no migrate | No migrate |
| `False` | `True` | No query, no migrate | No migrate |

*Default.

Separate code into two utility functions that help to import and migrate.
@CasperWA CasperWA force-pushed the fix_2739_auto_migrate_verdi_import branch from 930e767 to caa7efc Compare May 10, 2019 09:40
@CasperWA CasperWA mentioned this pull request May 10, 2019
3 tasks
@CasperWA CasperWA requested a review from ltalirz May 10, 2019 09:45
Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

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

Thanks a lot @CasperWA !

@ltalirz ltalirz merged commit 2370f74 into aiidateam:develop May 10, 2019
@CasperWA CasperWA deleted the fix_2739_auto_migrate_verdi_import branch May 10, 2019 15:41
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.

verdi import should automatically migrate export files
4 participants