Skip to content

Commit

Permalink
Merge branch 'links_doc' of github.com:szoupanos/aiida_core into link…
Browse files Browse the repository at this point in the history
…s_doc
  • Loading branch information
szoupanos committed Feb 22, 2018
2 parents 618d086 + 936b1c0 commit 4b47cc5
Show file tree
Hide file tree
Showing 201 changed files with 8,668 additions and 5,105 deletions.
1 change: 1 addition & 0 deletions .travis-data/computer-setup-input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ localhost
True
ssh
torque
#!/bin/bash
/scratch/{username}/aiida_run
mpirun -np {tot_num_mpiprocs}
1
Expand Down
9 changes: 9 additions & 0 deletions .travis-data/set_daemon_times.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
###########################################################################
# 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 #
###########################################################################
"""
For AiiDA 0.10.0, we set the times of the daemon
to 5 seconds.
Expand Down
120 changes: 80 additions & 40 deletions .travis-data/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

def print_daemon_log():
home = os.environ['HOME']
print "Output of 'cat {}/.aiida/daemon/log/aiida_daemon.log':".format(home)
print "Output of 'cat {}/.aiida/daemon/log/celery.log':".format(home)
try:
print subprocess.check_output(
["cat", "{}/.aiida/daemon/log/aiida_daemon.log".format(home)],
["cat", "{}/.aiida/daemon/log/celery.log".format(home)],
stderr=subprocess.STDOUT,
)
except subprocess.CalledProcessError as e:
Expand Down Expand Up @@ -98,6 +98,65 @@ def validate_workchains(expected_results):

return valid

def validate_cached(cached_calcs):
"""
Check that the calculations with created with caching are indeed cached.
"""
return all(
'_aiida_cached_from' in calc.extras() and
calc.get_hash() == calc.get_extra('_aiida_hash')
for calc in cached_calcs
)

def create_calculation(code, counter, inputval, use_cache=False):
parameters = ParameterData(dict={'value': inputval})
template = ParameterData(dict={
## The following line adds a significant sleep time.
## I set it to 1 second to speed up tests
## I keep it to a non-zero value because I want
## To test the case when AiiDA finds some calcs
## in a queued state
#'cmdline_params': ["{}".format(counter % 3)], # Sleep time
'cmdline_params': ["1"],
'input_file_template': "{value}", # File just contains the value to double
'input_file_name': 'value_to_double.txt',
'output_file_name': 'output.txt',
'retrieve_temporary_files': ['triple_value.tmp']
})
calc = code.new_calc()
calc.set_max_wallclock_seconds(5 * 60) # 5 min
calc.set_resources({"num_machines": 1})
calc.set_withmpi(False)
calc.set_parser_name('simpleplugins.templatereplacer.test.doubler')

calc.use_parameters(parameters)
calc.use_template(template)
calc.store_all(use_cache=use_cache)
expected_result = {
'value': 2 * inputval,
'retrieved_temporary_files': {
'triple_value.tmp': str(inputval * 3)
}
}
print "[{}] created calculation {}, pk={}".format(
counter, calc.uuid, calc.dbnode.pk)
return calc, expected_result

def submit_calculation(code, counter, inputval):
calc, expected_result = create_calculation(
code=code, counter=counter, inputval=inputval
)
calc.submit()
print "[{}] calculation submitted.".format(counter)
return calc, expected_result

def create_cache_calc(code, counter, inputval):
calc, expected_result = create_calculation(
code=code, counter=counter, inputval=inputval, use_cache=True
)
print "[{}] created cached calculation.".format(counter)
return calc, expected_result

def main():

# Submitting the Calculations
Expand All @@ -106,39 +165,10 @@ def main():
expected_results_calculations = {}
for counter in range(1, number_calculations + 1):
inputval = counter
parameters = ParameterData(dict={'value': inputval})
template = ParameterData(dict={
## The following line adds a significant sleep time.
## I set it to 1 second to speed up tests
## I keep it to a non-zero value because I want
## To test the case when AiiDA finds some calcs
## in a queued state
#'cmdline_params': ["{}".format(counter % 3)], # Sleep time
'cmdline_params': ["1"],
'input_file_template': "{value}", # File just contains the value to double
'input_file_name': 'value_to_double.txt',
'output_file_name': 'output.txt',
'retrieve_temporary_files': ['triple_value.tmp']
})
calc = code.new_calc()
calc.set_max_wallclock_seconds(5 * 60) # 5 min
calc.set_resources({"num_machines": 1})
calc.set_withmpi(False)
calc.set_parser_name('simpleplugins.templatereplacer.test.doubler')

calc.use_parameters(parameters)
calc.use_template(template)
calc.store_all()
print "[{}] created calculation {}, pk={}".format(
counter, calc.uuid, calc.dbnode.pk)
expected_results_calculations[calc.pk] = {
'value': inputval * 2,
'retrieved_temporary_files': {
'triple_value.tmp': str(inputval * 3)
}
}
calc.submit()
print "[{}] calculation submitted.".format(counter)
calc, expected_result = submit_calculation(
code=code, counter=counter, inputval=inputval
)
expected_results_calculations[calc.pk] = expected_result

# Submitting the Workchains
print "Submitting {} workchains to the daemon".format(number_workchains)
Expand All @@ -158,7 +188,7 @@ def main():
exited_with_timeout = True
while time.time() - start_time < timeout_secs:
time.sleep(15) # Wait a few seconds

# Print some debug info, both for debugging reasons and to avoid
# that the test machine is shut down because there is no output

Expand All @@ -168,7 +198,7 @@ def main():
print "Output of 'verdi calculation list -a':"
try:
print subprocess.check_output(
["verdi", "calculation", "list", "-a"],
["verdi", "calculation", "list", "-a"],
stderr=subprocess.STDOUT,
)
except subprocess.CalledProcessError as e:
Expand All @@ -177,7 +207,7 @@ def main():
print "Output of 'verdi work list':"
try:
print subprocess.check_output(
['verdi', 'work', 'list'],
['verdi', 'work', 'list'],
stderr=subprocess.STDOUT,
)
except subprocess.CalledProcessError as e:
Expand All @@ -186,7 +216,7 @@ def main():
print "Output of 'verdi daemon status':"
try:
print subprocess.check_output(
["verdi", "daemon", "status"],
["verdi", "daemon", "status"],
stderr=subprocess.STDOUT,
)
except subprocess.CalledProcessError as e:
Expand All @@ -204,8 +234,18 @@ def main():
timeout_secs)
sys.exit(2)
else:
# create cached calculations -- these should be FINISHED immediately
cached_calcs = []
for counter in range(1, number_calculations + 1):
inputval = counter
calc, expected_result = create_cache_calc(
code=code, counter=counter, inputval=inputval
)
cached_calcs.append(calc)
expected_results_calculations[calc.pk] = expected_result
if (validate_calculations(expected_results_calculations)
and validate_workchains(expected_results_workchains)):
and validate_workchains(expected_results_workchains)
and validate_cached(cached_calcs)):
print_daemon_log()
print ""
print "OK, all calculations have the expected parsed result"
Expand Down
9 changes: 9 additions & 0 deletions .travis-data/test_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# -*- coding: utf-8 -*-
###########################################################################
# 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 #
###########################################################################
"""Unittests for plugin test fixture manager"""
import os
import unittest
Expand Down
35 changes: 29 additions & 6 deletions .travis-data/test_plugin_testcase.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# -*- coding: utf-8 -*-
###########################################################################
# 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 #
###########################################################################
"""
Test the plugin test case
Expand All @@ -21,24 +30,32 @@ def determine_backend():


class PluginTestcaseTestCase(PluginTestCase):
"""Test the PluginTestcase from utils.fixtures"""
"""
Test the PluginTestcase from utils.fixtures
"""
BACKEND = determine_backend()

def setUp(self):
from aiida.orm import DataFactory
from aiida.orm import Computer
self.temp_dir = tempfile.mkdtemp()
self.data = self.get_data()
self.data_pk = self.data.pk
self.computer = self.get_computer(temp_dir=self.temp_dir)

def get_data(self):
@staticmethod
def get_data():
"""
Return some ParameterData
"""
from aiida.orm import DataFactory
data = DataFactory('parameter')(dict={'data': 'test'})
data.store()
return data

def get_computer(self, temp_dir):
@staticmethod
def get_computer(temp_dir):
"""
Create and store a new computer, and return it
"""
from aiida.orm import Computer
computer = Computer(
name='localhost',
Expand All @@ -52,14 +69,20 @@ def get_computer(self, temp_dir):
return computer

def test_data_loaded(self):
"""
Check that the data is indeed in the DB when calling load_node
"""
from aiida.orm import Computer
from aiida.orm import load_node
self.assertTrue(is_dbenv_loaded())
self.assertEqual(load_node(self.data_pk).uuid, self.data.uuid)
self.assertEqual(Computer.get('localhost').uuid, self.computer.uuid)


def test_tear_down(self):
"""
Check that after tearing down, the previously stored nodes
are not there anymore. Then remove the temporary folder.
"""
from aiida.orm import load_node
super(PluginTestcaseTestCase, self).tearDown()
with self.assertRaises(Exception):
Expand Down
2 changes: 1 addition & 1 deletion .travis-data/test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ case "$TEST_TYPE" in
verdi -p $TEST_AIIDA_BACKEND run ${TRAVIS_BUILD_DIR}/.travis-data/test_daemon.py
;;
pre-commit)
pre-commit run --all-files || git status --short && git diff
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
;;
esac
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ install:
# Upgrade pip setuptools and wheel to be able to run the next command
- pip install -U pip wheel setuptools
# Install AiiDA with some optional dependencies
- pip install .[REST,docs,atomic_tools,testing,dev_precommit]
- 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

env:
## Build matrix to test both backends, and the docs
## I still let it create the test backend for django
## I still let it create the test backend for django
## also when building the docs
## because otherwise the code would complain. Also, I need latex.
- TEST_TYPE="pre-commit"
Expand Down
2 changes: 1 addition & 1 deletion AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ And the following people for general improvements to the code, fixing bugs,
corrections and improvements to the documentation and useful suggestions:

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

---

Expand Down
Loading

0 comments on commit 4b47cc5

Please sign in to comment.