Skip to content

Commit

Permalink
Address review by @sphuber
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperWA committed Oct 10, 2019
1 parent c72d3f7 commit 70fc619
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions aiida/tools/importexport/dbexport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def export_tree(

all_fields_info, unique_identifiers = get_all_fields_info()

original_entities = defaultdict(list)
entities_starting_set = defaultdict(list)

# The set that contains the nodes ids of the nodes that should be exported
given_data_entry_ids = set()
Expand All @@ -196,27 +196,27 @@ def export_tree(
# Now a load the backend-independent name into entry_entity_name, e.g. Node!
# entry_entity_name = schema_to_entity_names(entry_class_string)
if issubclass(entry.__class__, orm.Group):
entities_starting_set[GROUP_ENTITY_NAME].append(entry.uuid)
given_group_entry_ids.add(entry.id)
given_groups.add(entry)
elif issubclass(entry.__class__, orm.Node):
original_entities[NODE_ENTITY_NAME].append(entry.uuid)
entities_starting_set[NODE_ENTITY_NAME].append(entry.uuid)
if issubclass(entry.__class__, orm.Data):
given_data_entry_ids.add(entry.pk)
elif issubclass(entry.__class__, orm.ProcessNode):
given_calculation_entry_ids.add(entry.pk)
elif issubclass(entry.__class__, orm.Computer):
original_entities[COMPUTER_ENTITY_NAME].append(entry.uuid)
entities_starting_set[COMPUTER_ENTITY_NAME].append(entry.uuid)
given_computer_entry_ids.add(entry.pk)
else:
raise exceptions.ArchiveExportError(
'I was given {} ({}), which is not a Node, Computer, or Group instance'.format(entry, type(entry))
)

original_entities[GROUP_ENTITY_NAME] = [_.uuid for _ in given_groups]

# Add all the nodes contained within the specified groups
for group in given_groups:
for entry in group.nodes:
entities_starting_set[NODE_ENTITY_NAME].append(entry.uuid)
if issubclass(entry.__class__, orm.Data):
given_data_entry_ids.add(entry.pk)
elif issubclass(entry.__class__, orm.ProcessNode):
Expand All @@ -229,7 +229,7 @@ def export_tree(
if not silent:
print('RETRIEVING LINKED NODES AND STORING LINKS...')

to_be_exported, links_uuid, link_follow_rules = retrieve_linked_nodes(
to_be_exported, links_uuid, graph_traversal_rules = retrieve_linked_nodes(
given_calculation_entry_ids, given_data_entry_ids, **kwargs
)

Expand Down Expand Up @@ -446,21 +446,14 @@ def export_tree(
# Add proper signature to unique identifiers & all_fields_info
# Ignore if a key doesn't exist in any of the two dictionaries

license_info = {'allowed_licenses': allowed_licenses, 'forbidden_licenses': forbidden_licenses}
for name, value in license_info.items():
if value and not isinstance(value, list):
# The value is a function (can either be a function, a list or None)
license_info[name] = 'Function {} was used to check for {}'.format(value, name.replace('_', ' '))

metadata = {
'aiida_version': get_version(),
'export_version': EXPORT_VERSION,
'all_fields_info': all_fields_info,
'unique_identifiers': unique_identifiers,
'export_parameters': {
'link_follow_rules': link_follow_rules,
'original_entities': original_entities,
'license_info': license_info,
'graph_traversal_rules': graph_traversal_rules,
'entities_starting_set': entities_starting_set,
'include_comments': include_comments,
'include_logs': include_logs
}
Expand Down

0 comments on commit 70fc619

Please sign in to comment.