-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Archive: add missing migration of transport entry points (#5604)
In the migration from version `0.11` to `0.12` the existing entry points from `aiida-core` were updated to include the `core.` prefix, however, the entry points of transports were forgotten. Since the incorrect migration was already released with `v2.0` of `aiida-core`, a separate migration has to be added to perform the transport entry point migrations.
- Loading branch information
1 parent
f157d27
commit 3e4c883
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
########################################################################### | ||
# Copyright (c), The AiiDA team. All rights reserved. # | ||
# This file is part of the AiiDA code. # | ||
# # | ||
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # | ||
# For further information on the license, see the LICENSE.txt file # | ||
# For further information please visit http://www.aiida.net # | ||
########################################################################### | ||
"""Migration from v0.12 to v0.13, used by ``verdi archive migrate`` command. | ||
This migration is necessary after the v0.11 to v0.12 migration did not add the core prefix | ||
to transport entry points. | ||
""" | ||
from ..utils import update_metadata, verify_metadata_version # pylint: disable=no-name-in-module | ||
|
||
MAPPING_TRANSPORTS = { | ||
'local': 'core.local', | ||
'ssh': 'core.ssh', | ||
} | ||
|
||
|
||
def migrate_v12_to_v13(metadata: dict, data: dict) -> None: | ||
"""Migration of export files from v0.12 to v0.13.""" | ||
# pylint: disable=too-many-branches | ||
old_version = '0.12' | ||
new_version = '0.13' | ||
|
||
verify_metadata_version(metadata, old_version) | ||
update_metadata(metadata, new_version) | ||
|
||
# Migrate transport entry point names | ||
for values in data.get('export_data', {}).get('Computer', {}).values(): | ||
|
||
if 'transport_type' in values: | ||
try: | ||
new_transport_type = MAPPING_TRANSPORTS[values['transport_type']] | ||
except KeyError: | ||
pass | ||
else: | ||
values['transport_type'] = new_transport_type |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
########################################################################### | ||
# Copyright (c), The AiiDA team. All rights reserved. # | ||
# This file is part of the AiiDA code. # | ||
# # | ||
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # | ||
# For further information on the license, see the LICENSE.txt file # | ||
# For further information please visit http://www.aiida.net # | ||
########################################################################### | ||
"""Test archive file migration from export version 0.12 to 0.13""" | ||
from aiida.storage.sqlite_zip.migrations.legacy.v12_to_v13 import migrate_v12_to_v13 | ||
|
||
|
||
def test_migrate_v12_to_v13(core_archive, migrate_from_func): | ||
"""Test the data migration of transport entry point strings | ||
e.g. from local to core.local. | ||
""" | ||
|
||
# Migrate v0.12 to v0.13 | ||
_, data = migrate_from_func('export_0.12_simple.aiida', '0.12', '0.13', migrate_v12_to_v13, core_archive) | ||
|
||
for values in data.get('export_data', {}).get('Computer', {}).values(): | ||
if 'transport_type' in values: | ||
assert values['transport_type'] in [ | ||
'core.local', | ||
'core.ssh', | ||
], (f"encountered illegal transport entry point string `{values['transport_type']}`") |