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 group extras to archive #4521

Merged
merged 3 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion aiida/tools/importexport/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ def get_all_fields_info():
},
'type_string': {},
'uuid': {},
'label': {}
'label': {},
'extras': {
'convert_type': 'jsonb'
}
}
all_fields_info[LOG_ENTITY_NAME] = {
'uuid': {},
Expand Down
6 changes: 6 additions & 0 deletions aiida/tools/importexport/dbimport/backends/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ 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:
Copy link
Member Author

Choose a reason for hiding this comment

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

this should eventually be removed, but it requires (a) changes to the export code and (b) a migration

# 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: 6 additions & 0 deletions aiida/tools/importexport/dbimport/backends/sqla.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ 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: 4 additions & 2 deletions aiida/tools/importexport/dbimport/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ def deserialize_attributes(attributes_data, conversion_data):
import datetime
import pytz

if conversion_data == 'jsonb':
# we do not make any changes
return attributes_data

if isinstance(attributes_data, dict):
ret_data = {}
for key, value in attributes_data.items():
Expand Down Expand Up @@ -218,8 +222,6 @@ def deserialize_attributes(attributes_data, conversion_data):

def deserialize_field(key, value, fields_info, import_unique_ids_mappings, foreign_ids_reverse_mappings):
"""Deserialize field using deserialize attributes"""
if key in ('attributes', 'extras'):
return (key, value)
try:
field_info = fields_info[key]
except KeyError:
Expand Down