Skip to content

Commit

Permalink
Merge pull request #36 from lsmo-epfl/release_1.0.0b2
Browse files Browse the repository at this point in the history
Prepare release 1.0.0b2
  • Loading branch information
yakutovicha authored Apr 16, 2020
2 parents 3724a6b + d294d9a commit af5e894
Show file tree
Hide file tree
Showing 134 changed files with 78,401 additions and 95 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: ci

on: [push, pull_request]

jobs:

tests:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: [3.7]
backend: ['django']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
wget -O - "https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc" | sudo apt-key add -
echo 'deb https://dl.bintray.com/rabbitmq-erlang/debian bionic erlang' | sudo tee -a /etc/apt/sources.list.d/bintray.rabbitmq.list
echo 'deb https://dl.bintray.com/rabbitmq/debian bionic main' | sudo tee -a /etc/apt/sources.list.d/bintray.rabbitmq.list
sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
sudo apt install postgresql-10 rabbitmq-server graphviz
sudo systemctl status rabbitmq-server.service
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[testing]
reentry scan -r aiida
- name: Run test suite
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
PYTEST_ADDOPTS: "--cov-report xml --cov-append"
run: py.test tests

- name: Upload coverage report
if: github.repository == 'lsmo-epfl/aiida-lsmo'
uses: codecov/codecov-action@v1
with:
name: aiida-lsmo
file: ./coverage.xml
fail_ci_if_error: true

docs:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[docs]
reentry scan -r aiida
- name: Build docs
run: cd docs && make

pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[pre-commit,docs,testing]
reentry scan -r aiida
- name: Run pre-commit
run: |
pre-commit install
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
55 changes: 0 additions & 55 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include setup.json
include aiida_lsmo/calcfunctions/*.yaml
include aiida_lsmo/workchains/isotherm_data/*
include aiida_lsmo/workchains/cp2k_multistage_protocols/*.yaml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

AiiDA workflows designed by the LSMO group at EPFL.

The documentation can be found at https://aiida-lsmo.readthedocs.io/en/latest/
The documentation can be found at https://aiida-lsmo.readthedocs.io/en/latest/ .
2 changes: 1 addition & 1 deletion aiida_lsmo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
AiiDA workflows for the LSMO laboratory at EPFL
"""

__version__ = "1.0.0b1"
__version__ = "1.0.0b2"
23 changes: 17 additions & 6 deletions aiida_lsmo/utils/other_utilities.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Other utilities"""

import collections
import ase
from aiida.orm import Dict, CifData, StructureData
from aiida.engine import calcfunction

Expand All @@ -14,7 +16,6 @@ def dict_merge(dct, merge_dct):
:param merge_dct: dct merged into dct
:return: None
"""
import collections
for k in merge_dct.keys():
if (k in dct and isinstance(dct[k], dict) and isinstance(merge_dct[k], collections.Mapping)):
dict_merge(dct[k], merge_dct[k])
Expand All @@ -35,14 +36,25 @@ def aiida_dict_merge(to_dict, from_dict):
return Dict(dict=to_dict)


def ase_cells_are_similar(ase_a, ase_b, thr=2):
"""Return True if the cell of two ASE objects are similar up to "thr" decimals.
This avoids to give error if two Cells are different at a nth decimal number, tipically because of some truncation.
"""
comp_similar = []
for cell_a, cell_b in zip(ase_a.cell, ase_b.cell):
comp_similar.append(round(cell_a, thr) == round(cell_b, thr))
return all(comp_similar)


@calcfunction
def aiida_cif_merge(aiida_cif_a, aiida_cif_b):
"""Merge the coordinates of two CifData into a sigle one. Note: the two unit cells must be the same."""
import ase

ase_a = aiida_cif_a.get_ase()
ase_b = aiida_cif_b.get_ase()
if not (ase_a.cell == ase_b.cell).all():
raise ValueError('Attempting to merge two CifData with different unit cells.')
if not ase_cells_are_similar(ase_a, ase_b.cell):
raise ValueError('Attempting to merge two CifData (<{}> and <{}>) with different unit cells.'.format(
aiida_cif_a.pk, aiida_cif_b.pk))
ase_ab = ase.Atoms( #Maybe there is a more direct way...
symbols=list(ase_a.symbols) + list(ase_b.symbols),
cell=ase_a.cell,
Expand All @@ -57,10 +69,9 @@ def aiida_cif_merge(aiida_cif_a, aiida_cif_b):
@calcfunction
def aiida_structure_merge(aiida_structure_a, aiida_structure_b):
"""Merge the coordinates of two StructureData into a sigle one. Note: the two unit cells must be the same."""
import ase
ase_a = aiida_structure_a.get_ase()
ase_b = aiida_structure_b.get_ase()
if not (ase_a.cell == ase_b.cell).all():
if not ase_cells_are_similar(ase_a, ase_b.cell):
raise ValueError('Attempting to merge two StructureData with different unit cells.')
ase_ab = ase.Atoms( #Maybe there is a more direct way...
symbols=list(ase_a.symbols) + list(ase_b.symbols),
Expand Down
4 changes: 2 additions & 2 deletions aiida_lsmo/workchains/cp2k_binding_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def define(cls, spec):
valid_type=Str,
default=lambda: Str('standard'),
required=False,
help='The tag of the protocol to be read from {tag}.yaml unless protocol_yaml input is specified')
help='The tag of the protocol tag.yaml. NOTE: only the settings are read, stage is set to GEO_OPT.')
spec.input('protocol_yaml',
valid_type=SinglefileData,
required=False,
help='Specify a custom yaml file with the multistage settings (and ignore protocol_tag)')
help='Specify a custom yaml file. NOTE: only the settings are read, stage is set to GEO_OPT.')
spec.input('protocol_modify',
valid_type=Dict,
default=lambda: Dict(dict={}),
Expand Down
11 changes: 6 additions & 5 deletions aiida_lsmo/workchains/sim_annealing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Isotherm workchain"""

import os

import ruamel.yaml as yaml
import ase
from aiida.plugins import CalculationFactory, DataFactory, WorkflowFactory
from aiida.orm import Dict, Str
from aiida.engine import calcfunction
Expand Down Expand Up @@ -35,7 +36,6 @@
@calcfunction
def get_molecule_dict(molecule_name):
"""Get a Dict from the isotherm_molecules.yaml"""
import ruamel.yaml as yaml
thisdir = os.path.dirname(os.path.abspath(__file__))
yamlfile = os.path.join(thisdir, "isotherm_data", "isotherm_molecules.yaml")
with open(yamlfile, 'r') as stream:
Expand All @@ -58,7 +58,6 @@ def get_ff_parameters(molecule_dict, isotparam):

def load_yaml():
""" Load the ff_data.yaml as a dict."""
import ruamel.yaml as yaml
thisdir = os.path.dirname(os.path.abspath(__file__))
yamlfullpath = os.path.join(thisdir, '..', 'calcfunctions', 'ff_data.yaml')
with open(yamlfullpath, 'r') as stream:
Expand All @@ -68,8 +67,10 @@ def load_yaml():

@calcfunction
def get_molecule_from_restart_file(structure_cif, molecule_folderdata, input_dict, molecule_dict):
"""Get a CifData file having the cell of the structure and the geometry of the loaded molecule."""
import ase
"""Get a CifData file having the cell of the initial (unexpanded) structure and the geometry of the loaded molecule.
TODO: this is source of error if there are more than one molecule, and the cell has been expandes,
as you can not wrap them in the small cell.
"""

# Get number of guest molecules
if "number_of_molecules" in input_dict.get_dict():
Expand Down
10 changes: 4 additions & 6 deletions aiida_lsmo/workchains/zeopp_multistage_ddec.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ def define(cls, spec):
super().define(spec)

spec.input('structure', valid_type=CifData, help='input structure')
spec.input('zeopp.parameters',
valid_type=NetworkParameters,
default=lambda: NetworkParameters(dict=ZEOPP_PARAMETERS_DEFAULT),
required=False,
help='parameters for zeo++')
spec.expose_inputs(ZeoppCalculation, namespace='zeopp', exclude=['parameters', 'structure'])
spec.expose_inputs(ZeoppCalculation, namespace='zeopp', exclude=['structure'])
spec.inputs['zeopp']['parameters'].default = lambda: NetworkParameters(dict=ZEOPP_PARAMETERS_DEFAULT)
spec.inputs['zeopp']['parameters'].required = False

spec.expose_inputs(Cp2kMultistageDdecWorkChain, exclude=['structure'])

spec.outline(cls.run_zeopp_before, cls.run_multistageddec, cls.run_zeopp_after, cls.return_results)
Expand Down
47 changes: 46 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,56 @@
For pytest
initialise a test database and profile
"""
import os
import pytest
from tests import DATA_DIR

pytest_plugins = ['aiida.manage.tests.pytest_fixtures'] # pylint: disable=invalid-name
pytest_plugins = ['aiida.manage.tests.pytest_fixtures', 'aiida_testing.mock_code'] # pylint: disable=invalid-name


@pytest.fixture(scope='function', autouse=True)
def clear_database_auto(clear_database): # pylint: disable=unused-argument
"""Automatically clear database in between tests."""


@pytest.fixture(scope='function')
def cp2k_code(mock_code_factory):
"""Create mocked "cp2k" code."""
return mock_code_factory(
label='cp2k-7.1',
data_dir_abspath=DATA_DIR,
entry_point='cp2k',
# files *not* to copy into the data directory
ignore_files=('_aiidasubmit.sh'))


@pytest.fixture(scope='function')
def raspa_code(mock_code_factory):
"""Create mocked "raspa" code."""
return mock_code_factory(
label='raspa-e968334',
data_dir_abspath=DATA_DIR,
entry_point='raspa',
# files *not* to copy into the data directory
ignore_files=('_aiidasubmit.sh',))


@pytest.fixture(scope='function')
def zeopp_code(mock_code_factory):
"""Create mocked "zeo++" code."""
return mock_code_factory(
label='zeopp-0.3',
data_dir_abspath=DATA_DIR,
entry_point='zeopp.network',
# files *not* to copy into the data directory
ignore_files=('_aiidasubmit.sh', 'UFF.rad'))


@pytest.fixture(scope='function')
def mg_mof74_cifdata():
"""CifData for Mg MOF74 CIF."""
from aiida.orm import CifData # pylint: disable=import-outside-toplevel
with open(os.path.join(DATA_DIR, 'Mg_MOF_74.cif'), 'rb') as handle:
cif = CifData(file=handle)

return cif
2 changes: 0 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
The aiida-lsmo plugin for `AiiDA`_
=====================================================

``aiida-lsmo`` is available at http://github.com/yakutovicha/aiida-lsmo


.. toctree::
:maxdepth: 1
Expand Down
9 changes: 9 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[coverage:run]
parallel=true

[tool:pytest]
addopts = --durations=0 --cov=aiida_lsmo
filterwarnings =
ignore::DeprecationWarning:frozendict:
ignore::DeprecationWarning:sqlalchemy_utils:
ignore::DeprecationWarning:reentry:
9 changes: 5 additions & 4 deletions setup.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aiida-lsmo",
"version": "1.0.0b1",
"version": "1.0.0b2",
"author": "Aliaksandr Yakutovich, Daniele Ongari, Leopold Talirz",
"author_email": "[email protected]",
"description": "AiiDA workflows for the LSMO laboratory at EPFL",
Expand All @@ -10,8 +10,7 @@
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7"
],
"setup_requires": ["reentry"],
"reentry_register": true,
"include_package_data": true,
"install_requires": [
"aiida-core >= 1.0.0",
"aiida-cp2k >= 1.0.0b6",
Expand Down Expand Up @@ -51,7 +50,9 @@
],
"extras_require": {
"testing": [
"pytest==4.4.1"
"pgtest~=1.3.1",
"aiida-testing @ git+https://github.com/ltalirz/aiida-testing@fix-args#egg=aiida-testing",
"pytest-cov~=2.6"
],
"pre-commit": [
"pre-commit==1.17.0",
Expand Down
5 changes: 5 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Tests for aiida-lsmo."""
import os

THIS_DIR = os.path.dirname(os.path.abspath(__file__))
DATA_DIR = os.path.join(THIS_DIR, 'data')
File renamed without changes.
Loading

0 comments on commit af5e894

Please sign in to comment.