Skip to content

Commit

Permalink
Merge 6d30bab into bb9f2a9
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha committed Apr 17, 2020
2 parents bb9f2a9 + 6d30bab commit da45a59
Show file tree
Hide file tree
Showing 35 changed files with 294 additions and 505 deletions.
2 changes: 0 additions & 2 deletions .ci/check_travis_tag.py
Expand Up @@ -7,8 +7,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""Check travis tag"""
from __future__ import print_function
from __future__ import absolute_import

import os
import sys
Expand Down
2 changes: 2 additions & 0 deletions .coveragerc
@@ -0,0 +1,2 @@
[run]
parallel=True
2 changes: 1 addition & 1 deletion .docker/my_init.d/add-codes.sh
Expand Up @@ -4,4 +4,4 @@ set -em
su -c /opt/add-codes.sh aiida

# Make /opt/aiida-cp2k folder editable for the $SYSTEM_USER.
chown -R aiida:aiida /opt/aiida-cp2k/
chown -R ${SYSTEM_USER}:${SYSTEM_USER} /opt/aiida-cp2k/
1 change: 1 addition & 0 deletions .docker/opt/add-codes.sh
Expand Up @@ -6,4 +6,5 @@ set -x
# Environment
export SHELL=/bin/bash

# Install cp2k code.
verdi code show cp2k@localhost || verdi code setup --config /opt/aiida-cp2k/.docker/cp2k-code.yml --non-interactive
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
@@ -1,17 +1,6 @@
# # Install pre-commit hooks via
# pre-commit install

# modernizer: make sure our code-base is Python 3 ready
- repo: https://github.com/python-modernize/python-modernize.git
sha: a234ce4e185cf77a55632888f1811d83b4ad9ef2
hooks:
- id: python-modernize
exclude: ^docs/
args:
- --write
- --nobackups
- --nofix=dict_six

- repo: local
hooks:
# yapf = yet another python formatter
Expand Down
4 changes: 0 additions & 4 deletions .pylintrc
Expand Up @@ -273,10 +273,6 @@ ignored-argument-names=_.*|^ignored_|^unused_
# Tells whether we should check for unused import in __init__ files.
init-import=no

# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,future.builtins


[MISCELLANEOUS]

Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -7,10 +7,9 @@ before_install:
- python .ci/check_travis_tag.py
- docker build -t aiida_cp2k_test .
- export DOCKERID=`docker run -d aiida_cp2k_test`
- sleep 30 # wait until the container is launched

script:
- "echo \"Docker ID: $DOCKERID\""
- docker exec --tty $DOCKERID wait-for-services
- docker exec -it --user aiida $DOCKERID /bin/bash -l -c 'cd /opt/aiida-cp2k/ && pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )'
- docker exec -it --user aiida $DOCKERID /bin/bash -l -c 'cd /opt/aiida-cp2k/ && py.test --cov aiida_cp2k --cov-append .'
- docker exec -it --user aiida $DOCKERID /bin/bash -l -c 'cd /opt/aiida-cp2k/docs && make'
Expand Down
10 changes: 2 additions & 8 deletions Dockerfile
Expand Up @@ -5,11 +5,7 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################

FROM aiidateam/aiida-docker-stack

# Set HOME and PATH variables.
ENV HOME="/home/aiida"
ENV PATH="${HOME}/.local/bin:${PATH}"
FROM aiidateam/aiida-core:latest

# To prevent the container to exit prematurely.
ENV KILL_ALL_RPOCESSES_TIMEOUT=50
Expand All @@ -28,6 +24,4 @@ RUN pip install coveralls

# Install the cp2k code.
COPY .docker/opt/add-codes.sh /opt/
COPY .docker/my_init.d/add-codes.sh /etc/my_init.d/40_add-codes.sh

RUN chown -R aiida:aiida ${HOME}
COPY .docker/my_init.d/add-codes.sh /etc/my_init.d/50_add-codes.sh
2 changes: 1 addition & 1 deletion aiida_cp2k/__init__.py
Expand Up @@ -7,6 +7,6 @@
###############################################################################
"""AiiDA-CP2K plugins, parsers, workflows, etc ..."""

__version__ = "1.0.0"
__version__ = "1.1.0"

# EOF
17 changes: 6 additions & 11 deletions aiida_cp2k/calculations/__init__.py
Expand Up @@ -7,11 +7,7 @@
###############################################################################
"""AiiDA-CP2K input plugin."""

from __future__ import absolute_import

import io
import six
from six.moves import map

from aiida.engine import CalcJob
from aiida.orm import Computer, Dict, SinglefileData, StructureData, RemoteData, BandsData
Expand Down Expand Up @@ -51,16 +47,13 @@ def define(cls, spec):
dynamic=True)

# Specify default parser.
spec.input('metadata.options.parser_name',
valid_type=six.string_types,
default=cls._DEFAULT_PARSER,
non_db=True)
spec.input('metadata.options.parser_name', valid_type=str, default=cls._DEFAULT_PARSER, non_db=True)

# Add input_filename attribute.
spec.input('metadata.options.input_filename', valid_type=six.string_types, default=cls._DEFAULT_INPUT_FILE)
spec.input('metadata.options.input_filename', valid_type=str, default=cls._DEFAULT_INPUT_FILE)

# Add output_filename attribute.
spec.input('metadata.options.output_filename', valid_type=six.string_types, default=cls._DEFAULT_OUTPUT_FILE)
spec.input('metadata.options.output_filename', valid_type=str, default=cls._DEFAULT_OUTPUT_FILE)

# Use mpi by default.
spec.input('metadata.options.withmpi', valid_type=bool, default=True)
Expand Down Expand Up @@ -95,6 +88,8 @@ def define(cls, spec):
spec.output('output_bands', valid_type=BandsData, required=False, help='optional band structure')
spec.default_output_node = 'output_parameters'

spec.outputs.dynamic = True

def prepare_for_submission(self, folder):
"""Create the input files from the input nodes passed to this instance of the `CalcJob`.
Expand Down Expand Up @@ -129,7 +124,7 @@ def prepare_for_submission(self, folder):
try:
fobj.write(inp.render())
except ValueError as exc:
six.raise_from(InputValidationError("invalid keys or values in input parameters found"), exc)
raise InputValidationError("Invalid keys or values in input parameters found") from exc

settings = self.inputs.settings.get_dict() if 'settings' in self.inputs else {}

Expand Down
1 change: 0 additions & 1 deletion aiida_cp2k/parsers/__init__.py
Expand Up @@ -6,7 +6,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""AiiDA-CP2K output parser."""
from __future__ import absolute_import

import io
import os
Expand Down
3 changes: 1 addition & 2 deletions aiida_cp2k/utils/__init__.py
Expand Up @@ -6,9 +6,8 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""AiiDA-CP2K utils"""
from __future__ import absolute_import

from .input_generator import Cp2kInput
from .input_generator import Cp2kInput, add_restart_sections
from .parser import parse_cp2k_output
from .parser import parse_cp2k_output_advanced
from .parser import parse_cp2k_trajectory
Expand Down
40 changes: 28 additions & 12 deletions aiida_cp2k/utils/input_generator.py
Expand Up @@ -5,18 +5,14 @@
# AiiDA-CP2K is hosted on GitHub at https://github.com/aiidateam/aiida-cp2k #
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""AiiDA-CP2K input generator"""

from __future__ import absolute_import
from __future__ import division
"""AiiDA-CP2K input generator."""

from copy import deepcopy
from collections.abc import Mapping, Sequence

import six
if six.PY2:
from collections import Mapping, Sequence # pylint: disable=import-error, no-name-in-module
else:
from collections.abc import Mapping, Sequence # pylint: disable=import-error, no-name-in-module
from aiida.orm import Dict
from aiida.engine import calcfunction
from .workchains import merge_dict


class Cp2kInput: # pylint: disable=old-style-class
Expand Down Expand Up @@ -55,7 +51,7 @@ def add_keyword(self, kwpath, value, override=True, conflicting_keys=None):
added.
"""

if isinstance(kwpath, six.string_types):
if isinstance(kwpath, str):
kwpath = kwpath.split("/")

Cp2kInput._add_keyword(kwpath, value, self._params, ovrd=override, cfct=conflicting_keys)
Expand Down Expand Up @@ -89,7 +85,7 @@ def _add_keyword(kwpath, value, params, ovrd, cfct):
Cp2kInput._add_keyword(kwpath[1:], value, params[kwpath[0]], ovrd, cfct)

# if it is a list, loop over its elements
elif isinstance(params[kwpath[0]], Sequence) and not isinstance(params[kwpath[0]], six.string_types):
elif isinstance(params[kwpath[0]], Sequence) and not isinstance(params[kwpath[0]], str):
for element in params[kwpath[0]]:
Cp2kInput._add_keyword(kwpath[1:], value, element, ovrd, cfct)

Expand Down Expand Up @@ -151,7 +147,7 @@ def _render_section(output, params, indent=0):
Cp2kInput._render_section(output, val, indent + 3)
output.append('{}&END {}'.format(' ' * indent, key))

elif isinstance(val, Sequence) and not isinstance(val, six.string_types):
elif isinstance(val, Sequence) and not isinstance(val, str):
for listitem in val:
Cp2kInput._render_section(output, {key: listitem}, indent)

Expand All @@ -161,3 +157,23 @@ def _render_section(output, params, indent=0):

else:
output.append('{}{} {}'.format(' ' * indent, key, val))


@calcfunction
def add_restart_sections(input_dict):
"""Add restart section to the input dictionary."""

params = input_dict.get_dict()
restart_wfn_dict = {
'FORCE_EVAL': {
'DFT': {
'RESTART_FILE_NAME': './parent_calc/aiida-RESTART.wfn',
'SCF': {
'SCF_GUESS': 'RESTART',
},
},
},
}
merge_dict(params, restart_wfn_dict)
params['EXT_RESTART'] = {'RESTART_FILE_NAME': './parent_calc/aiida-1.restart'}
return Dict(dict=params)
3 changes: 0 additions & 3 deletions aiida_cp2k/utils/parser.py
Expand Up @@ -7,9 +7,6 @@
###############################################################################
"""AiiDA-CP2K input plugin."""

from __future__ import absolute_import
from __future__ import division

import re
import math

Expand Down
1 change: 0 additions & 1 deletion aiida_cp2k/utils/workchains.py
Expand Up @@ -7,7 +7,6 @@
###############################################################################
"""AiiDA-CP2K utilities for workchains"""

from __future__ import absolute_import
from aiida.engine import calcfunction
from aiida.orm import Dict, StructureData

Expand Down

0 comments on commit da45a59

Please sign in to comment.