Skip to content

Commit 2dfe2ca

Browse files
committed
Start to work on group testing
1 parent b98c61a commit 2dfe2ca

File tree

4 files changed

+88
-10
lines changed

4 files changed

+88
-10
lines changed

src/aiida/tools/dumping/group.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222

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

25-
DEFAULT_PROCESSES_TO_DUMP = [orm.CalculationNode, orm.WorkflowNode]
26-
# DEFAULT_DATA_TO_DUMP = [orm.StructureData, orm.Code, orm.Computer, orm.BandsData, orm.UpfData]
27-
# DEFAULT_COLLECTIONS_TO_DUMP ??
28-
DEFAULT_ENTITIES_TO_DUMP = DEFAULT_PROCESSES_TO_DUMP # + DEFAULT_DATA_TO_DUMP
29-
30-
3125
class GroupDumper:
3226
def __init__(
3327
self,
@@ -114,10 +108,6 @@ def _get_processes(self):
114108
self.calculations = calculations
115109
self.workflows = workflows
116110

117-
def dump(self):
118-
self.output_path.mkdir(exist_ok=True, parents=True)
119-
self._dump_processes()
120-
121111
def _dump_processes(self):
122112
self._get_processes()
123113

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

180170
self.dump_logger.update_workflows(dumped_workflows)
171+
172+
def dump(self):
173+
self.output_path.mkdir(exist_ok=True, parents=True)
174+
self._dump_processes()

tests/tools/dumping/__init__.py

Whitespace-only changes.

tests/tools/dumping/test_group.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
###########################################################################
2+
# Copyright (c), The AiiDA team. All rights reserved. #
3+
# This file is part of the AiiDA code. #
4+
# #
5+
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core #
6+
# For further information on the license, see the LICENSE.txt file #
7+
# For further information please visit http://www.aiida.net #
8+
###########################################################################
9+
"""Tests for the dumping of group data to disk."""
10+
11+
# TODO: Test that de-duplication also works for calculations
12+
13+
import pytest
14+
from pathlib import Path
15+
from aiida import orm
16+
17+
18+
@pytest.mark.usefixtures('aiida_profile_clean')
19+
@pytest.fixture(scope='session', autouse=True)
20+
def setup_profile_groups(generate_calculation_node_add, generate_workchain_multiply_add):
21+
# Create nodes for profile storage
22+
int_node = orm.Int(1).store()
23+
_ = generate_calculation_node_add()
24+
_ = generate_workchain_multiply_add()
25+
cj_node = generate_calculation_node_add()
26+
wc_node = generate_workchain_multiply_add()
27+
28+
# Create the various groups
29+
add_group = orm.Group.collection.get_or_create(label='add')[0]
30+
multiply_add_group = orm.Group.collection.get_or_create(label='multiply-add')[0]
31+
cj_dupl_group = orm.Group.collection.get_or_create(label='cj-dupl')[0]
32+
wc_dupl_group = orm.Group.collection.get_or_create(label='wc-dupl')[0]
33+
no_process_group = orm.Group.collection.get_or_create(label='add')[0]
34+
35+
# Populate groups
36+
add_group.add_nodes([cj_node])
37+
multiply_add_group.add_nodes([wc_node])
38+
cj_dupl_group.add_nodes([cj_node])
39+
wc_dupl_group.add_nodes([wc_node])
40+
no_process_group.add_nodes([int_node])
41+
42+
# Not sure if this is actually needed?
43+
return {
44+
'add_group': add_group,
45+
'multiply_add_group': multiply_add_group,
46+
'cj_dupl_group': cj_dupl_group,
47+
'wc_dupl_group': wc_dupl_group,
48+
'no_process_group': no_process_group,
49+
}
50+
51+
52+
class TestGroupDumper:
53+
54+
def test_should_dump_processes(self):
55+
print(orm.QueryBuilder().append(orm.Group).all(flat=True))
56+
assert False
57+
# pass
58+
59+
def test_get_nodes(self):
60+
pass
61+
62+
def test_get_processes(self):
63+
pass
64+
65+
def test_dump_processes(self):
66+
pass
67+
68+
def test_dump_calculations(self):
69+
pass
70+
71+
def test_dump_workflows(self):
72+
pass
73+
74+
def test_dump(self):
75+
pass

tests/tools/dumping/test_profile.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
###########################################################################
2+
# Copyright (c), The AiiDA team. All rights reserved. #
3+
# This file is part of the AiiDA code. #
4+
# #
5+
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core #
6+
# For further information on the license, see the LICENSE.txt file #
7+
# For further information please visit http://www.aiida.net #
8+
###########################################################################
9+
"""Tests for the dumping of profile data to disk."""

0 commit comments

Comments
 (0)