Skip to content

Commit

Permalink
Update archive version: 0.9 -> 0.10 (#4561)
Browse files Browse the repository at this point in the history
Fixes a bug whereby archives created with the latest code
fail to import in the last v1.4.2 release (if they contain group extras).
This update imposes that these new archives are no longer compatible with v1.4.2
  • Loading branch information
chrisjsewell authored Nov 13, 2020
1 parent def9a03 commit 810dc56
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 13 deletions.
2 changes: 2 additions & 0 deletions aiida/tools/importexport/archive/migrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .v06_to_v07 import migrate_v6_to_v7
from .v07_to_v08 import migrate_v7_to_v8
from .v08_to_v09 import migrate_v8_to_v9
from .v09_to_v10 import migrate_v9_to_v10

# version from -> version to, function which acts on the cache folder
_vtype = Dict[str, Tuple[str, Callable[[CacheFolder], None]]]
Expand All @@ -33,4 +34,5 @@
'0.6': ('0.7', migrate_v6_to_v7),
'0.7': ('0.8', migrate_v7_to_v8),
'0.8': ('0.9', migrate_v8_to_v9),
'0.9': ('0.10', migrate_v9_to_v10)
}
31 changes: 31 additions & 0 deletions aiida/tools/importexport/archive/migrations/v09_to_v10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- 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.9 to v0.10, used by `verdi export migrate` command."""
# pylint: disable=invalid-name
from aiida.tools.importexport.archive.common import CacheFolder

from .utils import verify_metadata_version, update_metadata


def migrate_v9_to_v10(folder: CacheFolder):
"""Migration of archive files from v0.9 to v0.10."""
old_version = '0.9'
new_version = '0.10'

_, metadata = folder.load_json('metadata.json')

verify_metadata_version(metadata, old_version)
update_metadata(metadata, new_version)

metadata['all_fields_info']['Node']['attributes'] = {'convert_type': 'jsonb'}
metadata['all_fields_info']['Node']['extras'] = {'convert_type': 'jsonb'}
metadata['all_fields_info']['Group']['extras'] = {'convert_type': 'jsonb'}

folder.write_json('metadata.json', metadata)
2 changes: 1 addition & 1 deletion aiida/tools/importexport/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
__all__ = ('EXPORT_VERSION',)

# Current export version
EXPORT_VERSION = '0.9'
EXPORT_VERSION = '0.10'


class ExportFileFormat(str, Enum):
Expand Down
6 changes: 0 additions & 6 deletions aiida/tools/importexport/dbimport/backends/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,6 @@ def _store_entity_data(
fields_info = reader.metadata.all_fields_info.get(entity_name, {})
unique_identifier = reader.metadata.unique_identifiers.get(entity_name, None)

if entity_name == NODE_ENTITY_NAME:
# in the current export process these fields are not present,
# because they are retrieved by a separate query
fields_info.setdefault('attributes', {'convert_type': 'jsonb'})
fields_info.setdefault('extras', {'convert_type': 'jsonb'})

pbar_base_str = f'{entity_name}s - '

# EXISTING ENTRIES
Expand Down
6 changes: 0 additions & 6 deletions aiida/tools/importexport/dbimport/backends/sqla.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,6 @@ def _store_entity_data(
fields_info = reader.metadata.all_fields_info.get(entity_name, {})
unique_identifier = reader.metadata.unique_identifiers.get(entity_name, None)

if entity_name == NODE_ENTITY_NAME:
# in the current export process these fields are not present,
# because they are retrieved by a separate query
fields_info.setdefault('attributes', {'convert_type': 'jsonb'})
fields_info.setdefault('extras', {'convert_type': 'jsonb'})

pbar_base_str = f'{entity_name}s - '

# EXISTING ENTRIES
Expand Down
Binary file modified tests/static/calcjob/arithmetic.add.aiida
Binary file not shown.
Binary file modified tests/static/calcjob/arithmetic.add_old.aiida
Binary file not shown.
Binary file modified tests/static/export/compare/django.aiida
Binary file not shown.
Binary file modified tests/static/export/compare/sqlalchemy.aiida
Binary file not shown.
Binary file not shown.

0 comments on commit 810dc56

Please sign in to comment.