Skip to content

Commit 4b47cc5

Browse files
committed
Merge branch 'links_doc' of github.com:szoupanos/aiida_core into links_doc
2 parents 618d086 + 936b1c0 commit 4b47cc5

File tree

201 files changed

+8668
-5105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+8668
-5105
lines changed

.travis-data/computer-setup-input.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ localhost
44
True
55
ssh
66
torque
7+
#!/bin/bash
78
/scratch/{username}/aiida_run
89
mpirun -np {tot_num_mpiprocs}
910
1

.travis-data/set_daemon_times.py

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
###########################################################################
4+
# Copyright (c), The AiiDA team. All rights reserved. #
5+
# This file is part of the AiiDA code. #
6+
# #
7+
# The code is hosted on GitHub at https://github.com/aiidateam/aiida_core #
8+
# For further information on the license, see the LICENSE.txt file #
9+
# For further information please visit http://www.aiida.net #
10+
###########################################################################
211
"""
312
For AiiDA 0.10.0, we set the times of the daemon
413
to 5 seconds.

.travis-data/test_daemon.py

+80-40
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
def print_daemon_log():
2828
home = os.environ['HOME']
29-
print "Output of 'cat {}/.aiida/daemon/log/aiida_daemon.log':".format(home)
29+
print "Output of 'cat {}/.aiida/daemon/log/celery.log':".format(home)
3030
try:
3131
print subprocess.check_output(
32-
["cat", "{}/.aiida/daemon/log/aiida_daemon.log".format(home)],
32+
["cat", "{}/.aiida/daemon/log/celery.log".format(home)],
3333
stderr=subprocess.STDOUT,
3434
)
3535
except subprocess.CalledProcessError as e:
@@ -98,6 +98,65 @@ def validate_workchains(expected_results):
9898

9999
return valid
100100

101+
def validate_cached(cached_calcs):
102+
"""
103+
Check that the calculations with created with caching are indeed cached.
104+
"""
105+
return all(
106+
'_aiida_cached_from' in calc.extras() and
107+
calc.get_hash() == calc.get_extra('_aiida_hash')
108+
for calc in cached_calcs
109+
)
110+
111+
def create_calculation(code, counter, inputval, use_cache=False):
112+
parameters = ParameterData(dict={'value': inputval})
113+
template = ParameterData(dict={
114+
## The following line adds a significant sleep time.
115+
## I set it to 1 second to speed up tests
116+
## I keep it to a non-zero value because I want
117+
## To test the case when AiiDA finds some calcs
118+
## in a queued state
119+
#'cmdline_params': ["{}".format(counter % 3)], # Sleep time
120+
'cmdline_params': ["1"],
121+
'input_file_template': "{value}", # File just contains the value to double
122+
'input_file_name': 'value_to_double.txt',
123+
'output_file_name': 'output.txt',
124+
'retrieve_temporary_files': ['triple_value.tmp']
125+
})
126+
calc = code.new_calc()
127+
calc.set_max_wallclock_seconds(5 * 60) # 5 min
128+
calc.set_resources({"num_machines": 1})
129+
calc.set_withmpi(False)
130+
calc.set_parser_name('simpleplugins.templatereplacer.test.doubler')
131+
132+
calc.use_parameters(parameters)
133+
calc.use_template(template)
134+
calc.store_all(use_cache=use_cache)
135+
expected_result = {
136+
'value': 2 * inputval,
137+
'retrieved_temporary_files': {
138+
'triple_value.tmp': str(inputval * 3)
139+
}
140+
}
141+
print "[{}] created calculation {}, pk={}".format(
142+
counter, calc.uuid, calc.dbnode.pk)
143+
return calc, expected_result
144+
145+
def submit_calculation(code, counter, inputval):
146+
calc, expected_result = create_calculation(
147+
code=code, counter=counter, inputval=inputval
148+
)
149+
calc.submit()
150+
print "[{}] calculation submitted.".format(counter)
151+
return calc, expected_result
152+
153+
def create_cache_calc(code, counter, inputval):
154+
calc, expected_result = create_calculation(
155+
code=code, counter=counter, inputval=inputval, use_cache=True
156+
)
157+
print "[{}] created cached calculation.".format(counter)
158+
return calc, expected_result
159+
101160
def main():
102161

103162
# Submitting the Calculations
@@ -106,39 +165,10 @@ def main():
106165
expected_results_calculations = {}
107166
for counter in range(1, number_calculations + 1):
108167
inputval = counter
109-
parameters = ParameterData(dict={'value': inputval})
110-
template = ParameterData(dict={
111-
## The following line adds a significant sleep time.
112-
## I set it to 1 second to speed up tests
113-
## I keep it to a non-zero value because I want
114-
## To test the case when AiiDA finds some calcs
115-
## in a queued state
116-
#'cmdline_params': ["{}".format(counter % 3)], # Sleep time
117-
'cmdline_params': ["1"],
118-
'input_file_template': "{value}", # File just contains the value to double
119-
'input_file_name': 'value_to_double.txt',
120-
'output_file_name': 'output.txt',
121-
'retrieve_temporary_files': ['triple_value.tmp']
122-
})
123-
calc = code.new_calc()
124-
calc.set_max_wallclock_seconds(5 * 60) # 5 min
125-
calc.set_resources({"num_machines": 1})
126-
calc.set_withmpi(False)
127-
calc.set_parser_name('simpleplugins.templatereplacer.test.doubler')
128-
129-
calc.use_parameters(parameters)
130-
calc.use_template(template)
131-
calc.store_all()
132-
print "[{}] created calculation {}, pk={}".format(
133-
counter, calc.uuid, calc.dbnode.pk)
134-
expected_results_calculations[calc.pk] = {
135-
'value': inputval * 2,
136-
'retrieved_temporary_files': {
137-
'triple_value.tmp': str(inputval * 3)
138-
}
139-
}
140-
calc.submit()
141-
print "[{}] calculation submitted.".format(counter)
168+
calc, expected_result = submit_calculation(
169+
code=code, counter=counter, inputval=inputval
170+
)
171+
expected_results_calculations[calc.pk] = expected_result
142172

143173
# Submitting the Workchains
144174
print "Submitting {} workchains to the daemon".format(number_workchains)
@@ -158,7 +188,7 @@ def main():
158188
exited_with_timeout = True
159189
while time.time() - start_time < timeout_secs:
160190
time.sleep(15) # Wait a few seconds
161-
191+
162192
# Print some debug info, both for debugging reasons and to avoid
163193
# that the test machine is shut down because there is no output
164194

@@ -168,7 +198,7 @@ def main():
168198
print "Output of 'verdi calculation list -a':"
169199
try:
170200
print subprocess.check_output(
171-
["verdi", "calculation", "list", "-a"],
201+
["verdi", "calculation", "list", "-a"],
172202
stderr=subprocess.STDOUT,
173203
)
174204
except subprocess.CalledProcessError as e:
@@ -177,7 +207,7 @@ def main():
177207
print "Output of 'verdi work list':"
178208
try:
179209
print subprocess.check_output(
180-
['verdi', 'work', 'list'],
210+
['verdi', 'work', 'list'],
181211
stderr=subprocess.STDOUT,
182212
)
183213
except subprocess.CalledProcessError as e:
@@ -186,7 +216,7 @@ def main():
186216
print "Output of 'verdi daemon status':"
187217
try:
188218
print subprocess.check_output(
189-
["verdi", "daemon", "status"],
219+
["verdi", "daemon", "status"],
190220
stderr=subprocess.STDOUT,
191221
)
192222
except subprocess.CalledProcessError as e:
@@ -204,8 +234,18 @@ def main():
204234
timeout_secs)
205235
sys.exit(2)
206236
else:
237+
# create cached calculations -- these should be FINISHED immediately
238+
cached_calcs = []
239+
for counter in range(1, number_calculations + 1):
240+
inputval = counter
241+
calc, expected_result = create_cache_calc(
242+
code=code, counter=counter, inputval=inputval
243+
)
244+
cached_calcs.append(calc)
245+
expected_results_calculations[calc.pk] = expected_result
207246
if (validate_calculations(expected_results_calculations)
208-
and validate_workchains(expected_results_workchains)):
247+
and validate_workchains(expected_results_workchains)
248+
and validate_cached(cached_calcs)):
209249
print_daemon_log()
210250
print ""
211251
print "OK, all calculations have the expected parsed result"

.travis-data/test_fixtures.py

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
###########################################################################
3+
# Copyright (c), The AiiDA team. All rights reserved. #
4+
# This file is part of the AiiDA code. #
5+
# #
6+
# The code is hosted on GitHub at https://github.com/aiidateam/aiida_core #
7+
# For further information on the license, see the LICENSE.txt file #
8+
# For further information please visit http://www.aiida.net #
9+
###########################################################################
110
"""Unittests for plugin test fixture manager"""
211
import os
312
import unittest

.travis-data/test_plugin_testcase.py

+29-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
###########################################################################
3+
# Copyright (c), The AiiDA team. All rights reserved. #
4+
# This file is part of the AiiDA code. #
5+
# #
6+
# The code is hosted on GitHub at https://github.com/aiidateam/aiida_core #
7+
# For further information on the license, see the LICENSE.txt file #
8+
# For further information please visit http://www.aiida.net #
9+
###########################################################################
110
"""
211
Test the plugin test case
312
@@ -21,24 +30,32 @@ def determine_backend():
2130

2231

2332
class PluginTestcaseTestCase(PluginTestCase):
24-
"""Test the PluginTestcase from utils.fixtures"""
33+
"""
34+
Test the PluginTestcase from utils.fixtures
35+
"""
2536
BACKEND = determine_backend()
2637

2738
def setUp(self):
28-
from aiida.orm import DataFactory
29-
from aiida.orm import Computer
3039
self.temp_dir = tempfile.mkdtemp()
3140
self.data = self.get_data()
3241
self.data_pk = self.data.pk
3342
self.computer = self.get_computer(temp_dir=self.temp_dir)
3443

35-
def get_data(self):
44+
@staticmethod
45+
def get_data():
46+
"""
47+
Return some ParameterData
48+
"""
3649
from aiida.orm import DataFactory
3750
data = DataFactory('parameter')(dict={'data': 'test'})
3851
data.store()
3952
return data
4053

41-
def get_computer(self, temp_dir):
54+
@staticmethod
55+
def get_computer(temp_dir):
56+
"""
57+
Create and store a new computer, and return it
58+
"""
4259
from aiida.orm import Computer
4360
computer = Computer(
4461
name='localhost',
@@ -52,14 +69,20 @@ def get_computer(self, temp_dir):
5269
return computer
5370

5471
def test_data_loaded(self):
72+
"""
73+
Check that the data is indeed in the DB when calling load_node
74+
"""
5575
from aiida.orm import Computer
5676
from aiida.orm import load_node
5777
self.assertTrue(is_dbenv_loaded())
5878
self.assertEqual(load_node(self.data_pk).uuid, self.data.uuid)
5979
self.assertEqual(Computer.get('localhost').uuid, self.computer.uuid)
6080

61-
6281
def test_tear_down(self):
82+
"""
83+
Check that after tearing down, the previously stored nodes
84+
are not there anymore. Then remove the temporary folder.
85+
"""
6386
from aiida.orm import load_node
6487
super(PluginTestcaseTestCase, self).tearDown()
6588
with self.assertRaises(Exception):

.travis-data/test_script.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ case "$TEST_TYPE" in
2424
verdi -p $TEST_AIIDA_BACKEND run ${TRAVIS_BUILD_DIR}/.travis-data/test_daemon.py
2525
;;
2626
pre-commit)
27-
pre-commit run --all-files || git status --short && git diff
27+
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
2828
;;
2929
esac

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ install:
4242
# Upgrade pip setuptools and wheel to be able to run the next command
4343
- pip install -U pip wheel setuptools
4444
# Install AiiDA with some optional dependencies
45-
- pip install .[REST,docs,atomic_tools,testing,dev_precommit]
45+
- if [ "$TEST_TYPE" == "docs" ]; then pip install . && pip install -r docs/requirements_for_rtd.txt; else pip install .[rest,docs,atomic_tools,testing,dev_precommit]; fi
4646

4747
env:
4848
## Build matrix to test both backends, and the docs
49-
## I still let it create the test backend for django
49+
## I still let it create the test backend for django
5050
## also when building the docs
5151
## because otherwise the code would complain. Also, I need latex.
5252
- TEST_TYPE="pre-commit"

AUTHORS.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ And the following people for general improvements to the code, fixing bugs,
5050
corrections and improvements to the documentation and useful suggestions:
5151

5252
Ivano E. Castelli, Ian Lee, Gianluca Prandini, Jianxing Huang, Antimo Marrazzo,
53-
Nicola Varini, Mario Zic, Vladimir Dikan, Michael Atambo
53+
Nicola Varini, Mario Zic, Vladimir Dikan, Michael Atambo, Ole Schütt, Marco Borelli
5454

5555
---
5656

0 commit comments

Comments
 (0)