-
Notifications
You must be signed in to change notification settings - Fork 191
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
Automate export file migration for verdi import
#2820
Conversation
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.
Very cool, thanks a lot @CasperWA !
Just a few comments - you know me ;-)
773ebf5
to
c4ea7fb
Compare
c1e19c5
to
930e767
Compare
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 @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.
930e767
to
caa7efc
Compare
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 a lot @CasperWA !
Fixes #2739.
Invoke
verdi export migrate
inverdi import
, if it turns out the export file archive cannot be imported due to anIncompatibleArchiveVersionError
.The default is to automatically migrate it (via a temporary file).
Introduce the
--non-interactive
flag forverdi 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.