Skip to content

Commit

Permalink
Merge pull request #15 from JuDFTteam/support/aiida-2.X
Browse files Browse the repository at this point in the history
Support/aiida 2.x
  • Loading branch information
PhilippRue committed Sep 26, 2022
2 parents 8841a42 + d189756 commit 836ec4b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 22 deletions.
33 changes: 29 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,29 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: ["3.7", "3.8", "3.9", "3.10"]
aiida: [{version: 'aiida-core==1.6.8', name: '1.6.8'}, {version: 'aiida-core==2.0.1', name: '2.0.1'}]
masci-tools: [{version: 'masci-tools', name: ''}]
allowed-to-fail: [false]
backend: ['django']
include:
# for python 3.9 we also test with the latest aiida-core version and the latest version of masci-tools
- python-version: 3.9
aiida: {version: 'git+https://github.com/aiidateam/aiida-core.git@main', name: 'latest'}
masci-tools: {version: 'git+https://github.com/JuDFTteam/masci-tools.git@develop', name: '-masci-develop'}
allowed-to-fail: true
- python-version: 3.9
aiida: {version: 'aiida-core==1.6.8', name: '1.6.8'}
masci-tools: {version: 'git+https://github.com/JuDFTteam/masci-tools.git@develop', name: '-masci-develop'}
allowed-to-fail: true
exclude:
# aiida-core>=2.0 needs at least python 3.8
- python-version: 3.7
aiida: {version: 'aiida-core==2.0.1', name: '2.0.1'}
masci-tools: {version: 'masci-tools', name: ''}
allowed-to-fail: false

services:
postgres:
Expand Down Expand Up @@ -42,12 +62,15 @@ jobs:
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[testing]
reentry scan -r aiida
pip install ${{ matrix.aiida.version }}
pip install ${{ matrix.masci-tools.version }}
pip install .[testing]
pip install reentry
reentry scan
pip freeze
- name: Run test suite
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
# show timings of tests
PYTEST_ADDOPTS: "--durations=0"
run: py.test --cov aiida_spirit --cov-append .
Expand All @@ -70,6 +93,7 @@ jobs:
run: |
pip install --upgrade pip
pip install -e .[docs]
pip install reentry
reentry scan -r aiida
- name: Build docs
run: cd docs && make
Expand All @@ -87,6 +111,7 @@ jobs:
run: |
pip install --upgrade pip
pip install -e .[pre-commit,docs,testing]
pip install reentry
reentry scan -r aiida
- name: Run pre-commit
run: |
Expand Down
5 changes: 3 additions & 2 deletions aiida_spirit/data/_type_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ def validate_array(key, val, len_check=None, minval=None, maxval=None):
_ = len(val)
# convert to numpy array
val = np.array(val)
except TypeError:
except TypeError as error:
raise TypeError(
f'Array input {key} is not an array-like object ({val}).')
f'Array input {key} is not an array-like object ({val}).'
) from error

# check shape of the array
if len(val) < 1:
Expand Down
2 changes: 1 addition & 1 deletion aiida_spirit/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, node):
:param node: ProcessNode of calculation
:param type node: :class:`aiida.orm.ProcessNode`
"""
super(SpiritParser, self).__init__(node)
super(SpiritParser, self).__init__(node) # pylint: disable=super-with-arguments
if not issubclass(node.process_class, SpiritCalculation):
raise exceptions.ParsingError('Can only parse SpiritCalculation')

Expand Down
4 changes: 2 additions & 2 deletions aiida_spirit/tools/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ def get_code(entry_point, computer):

try:
executable = executables[entry_point]
except KeyError:
except KeyError as error:
raise KeyError(
"Entry point '{}' not recognized. Allowed values: {}".format(
entry_point, list(executables.keys())))
entry_point, list(executables.keys()))) from error

codes = Code.objects.find(filters={'label': executable}) # pylint: disable=no-member
if codes:
Expand Down
12 changes: 6 additions & 6 deletions aiida_spirit/tools/spirit_script_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def method(self, key):
"""Set Spirit run method (i.e. LLG, MC)"""
try:
return self._method_dict[key.lower()]
except KeyError:
raise ValueError('Invalid method!')
except KeyError as error:
raise ValueError('Invalid method!') from error

_solver_dict = {
'depondt': 'simulation.SOLVER_DEPONDT',
Expand All @@ -103,8 +103,8 @@ def solver(self, key):
"""Set spirit solver (Depodt, VP, ...)"""
try:
return self._solver_dict[key.lower()]
except KeyError:
raise ValueError('Invalid solver!')
except KeyError as error:
raise ValueError('Invalid solver!') from error

_module_dict = {
'configuration': 'configuration',
Expand All @@ -119,8 +119,8 @@ def module(self, key):
"""Import the spirit modules"""
try:
return self._module_dict[key.lower()]
except KeyError:
raise ValueError('Invalid module!')
except KeyError as error:
raise ValueError('Invalid module!') from error

@staticmethod
def _dict_to_arg_string(dict): # pylint: disable=redefined-builtin
Expand Down
13 changes: 6 additions & 7 deletions setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,24 @@
"setup_requires": ["reentry"],
"reentry_register": true,
"install_requires": [
"aiida-core>=1.1.0,<2.0.0",
"sqlalchemy<1.4",
"aiida-core>=1.1.0,<3.0.0",
"numpy",
"pandas",
"masci-tools"
],
"extras_require": {
"testing": [
"pgtest~=1.3.1",
"wheel~=0.31",
"pgtest>=1.3.1",
"wheel>=0.31",
"coverage",
"pytest~=3.6,<5.0.0",
"pytest>=3.6",
"pytest-cov",
"spirit"
],
"pre-commit": [
"astroid<2.5",
"pre-commit~=2.2",
"pylint~=2.5.0"
"pre-commit>=2.2",
"pylint>=2.5.0"
],
"docs": [
"sphinx",
Expand Down

0 comments on commit 836ec4b

Please sign in to comment.