Skip to content

Commit

Permalink
Start to work on group testing
Browse files Browse the repository at this point in the history
  • Loading branch information
GeigerJ2 committed Jan 28, 2025
1 parent b98c61a commit 2dfe2ca
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/aiida/tools/dumping/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@

logger = AIIDA_LOGGER.getChild('tools.dumping')

DEFAULT_PROCESSES_TO_DUMP = [orm.CalculationNode, orm.WorkflowNode]
# DEFAULT_DATA_TO_DUMP = [orm.StructureData, orm.Code, orm.Computer, orm.BandsData, orm.UpfData]
# DEFAULT_COLLECTIONS_TO_DUMP ??
DEFAULT_ENTITIES_TO_DUMP = DEFAULT_PROCESSES_TO_DUMP # + DEFAULT_DATA_TO_DUMP


class GroupDumper:
def __init__(
self,
Expand Down Expand Up @@ -114,10 +108,6 @@ def _get_processes(self):
self.calculations = calculations
self.workflows = workflows

def dump(self):
self.output_path.mkdir(exist_ok=True, parents=True)
self._dump_processes()

def _dump_processes(self):
self._get_processes()

Expand Down Expand Up @@ -178,3 +168,7 @@ def _dump_workflows(self):
dumped_workflows[workflow.uuid] = workflow_dump_path

self.dump_logger.update_workflows(dumped_workflows)

def dump(self):
self.output_path.mkdir(exist_ok=True, parents=True)
self._dump_processes()
Empty file added tests/tools/dumping/__init__.py
Empty file.
75 changes: 75 additions & 0 deletions tests/tools/dumping/test_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
###########################################################################
# 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 #
###########################################################################
"""Tests for the dumping of group data to disk."""

# TODO: Test that de-duplication also works for calculations

import pytest
from pathlib import Path
from aiida import orm


@pytest.mark.usefixtures('aiida_profile_clean')
@pytest.fixture(scope='session', autouse=True)
def setup_profile_groups(generate_calculation_node_add, generate_workchain_multiply_add):
# Create nodes for profile storage
int_node = orm.Int(1).store()
_ = generate_calculation_node_add()
_ = generate_workchain_multiply_add()
cj_node = generate_calculation_node_add()
wc_node = generate_workchain_multiply_add()

# Create the various groups
add_group = orm.Group.collection.get_or_create(label='add')[0]
multiply_add_group = orm.Group.collection.get_or_create(label='multiply-add')[0]
cj_dupl_group = orm.Group.collection.get_or_create(label='cj-dupl')[0]
wc_dupl_group = orm.Group.collection.get_or_create(label='wc-dupl')[0]
no_process_group = orm.Group.collection.get_or_create(label='add')[0]

# Populate groups
add_group.add_nodes([cj_node])
multiply_add_group.add_nodes([wc_node])
cj_dupl_group.add_nodes([cj_node])
wc_dupl_group.add_nodes([wc_node])
no_process_group.add_nodes([int_node])

# Not sure if this is actually needed?
return {
'add_group': add_group,
'multiply_add_group': multiply_add_group,
'cj_dupl_group': cj_dupl_group,
'wc_dupl_group': wc_dupl_group,
'no_process_group': no_process_group,
}


class TestGroupDumper:

def test_should_dump_processes(self):
print(orm.QueryBuilder().append(orm.Group).all(flat=True))
assert False
# pass

def test_get_nodes(self):
pass

def test_get_processes(self):
pass

def test_dump_processes(self):
pass

def test_dump_calculations(self):
pass

def test_dump_workflows(self):
pass

def test_dump(self):
pass
9 changes: 9 additions & 0 deletions tests/tools/dumping/test_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
###########################################################################
# 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 #
###########################################################################
"""Tests for the dumping of profile data to disk."""

0 comments on commit 2dfe2ca

Please sign in to comment.