Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-upfdata-input
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha committed Aug 24, 2023
2 parents ecd0b8f + 3774529 commit 49a1435
Show file tree
Hide file tree
Showing 28 changed files with 68 additions and 121 deletions.
8 changes: 3 additions & 5 deletions aiida_cp2k/calculations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
write_pseudos,
)

BandsData = DataFactory("core.array.bands") # pylint: disable=invalid-name
StructureData = DataFactory("core.structure") # pylint: disable=invalid-name
KpointsData = DataFactory("core.array.kpoints") # pylint: disable=invalid-name
BandsData = DataFactory("core.array.bands")
StructureData = DataFactory("core.structure")
KpointsData = DataFactory("core.array.kpoints")
UpfData = DataFactory("pseudo.upf")


Expand Down Expand Up @@ -224,8 +224,6 @@ def prepare_for_submission(self, folder):
:return: `aiida.common.datastructures.CalcInfo` instance
"""

# pylint: disable=too-many-statements,too-many-branches

# Create cp2k input file.
inp = Cp2kInput(self.inputs.parameters.get_dict())
inp.add_keyword("GLOBAL/PROJECT", self._DEFAULT_PROJECT_NAME)
Expand Down
8 changes: 3 additions & 5 deletions aiida_cp2k/parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

# -

StructureData = DataFactory("core.structure") # pylint: disable=invalid-name
BandsData = DataFactory("core.array.bands") # pylint: disable=invalid-name
StructureData = DataFactory("core.structure")
BandsData = DataFactory("core.array.bands")


class Cp2kBaseParser(Parser):
Expand Down Expand Up @@ -71,9 +71,7 @@ def _parse_trajectory(self):

from ase import Atoms

fname = (
self.node.process_class._DEFAULT_RESTART_FILE_NAME
) # pylint: disable=protected-access
fname = self.node.process_class._DEFAULT_RESTART_FILE_NAME

# Check if the restart file is present.
if fname not in self.retrieved.base.repository.list_object_names():
Expand Down
3 changes: 0 additions & 3 deletions aiida_cp2k/utils/datatype_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def validate_basissets(inp, basissets, structure):
listed in a KIND section, or none of them are, at which point they're
verified against the symbols in the structure.
"""
# pylint: disable=too-many-branches,too-many-statements

# convert a structure
# {
Expand Down Expand Up @@ -294,8 +293,6 @@ def validate_pseudos_namespace(pseudos, _):
def validate_pseudos(inp, pseudos, structure):
"""Verify that all referenced pseudos are present in the input"""

# pylint: disable=too-many-branches,too-many-statements

pseudos_specified = {pseudo for _, pseudo in _unpack(pseudos)}
pseudos_used = set()
explicit_kinds = [] # list of kinds with explicitly specified kind sections
Expand Down
5 changes: 2 additions & 3 deletions aiida_cp2k/utils/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def parse_cp2k_output(fstring):

def parse_cp2k_output_advanced(
fstring,
): # pylint: disable=too-many-locals, too-many-statements, too-many-branches
):
"""Parse CP2K output into a dictionary (ADVANCED: more info parsed @ PRINT_LEVEL MEDIUM)."""
lines = fstring.splitlines()

Expand Down Expand Up @@ -380,8 +380,7 @@ def parse_cp2k_trajectory(content):

import numpy as np

# pylint: disable=protected-access
# parse coordinate section
# Parse coordinate section
match = re.search(r"\n\s*&COORD\n(.*?)\n\s*&END COORD\n", content, re.DOTALL)
coord_lines = [line.strip().split() for line in match.group(1).splitlines()]

Expand Down
10 changes: 4 additions & 6 deletions aiida_cp2k/utils/workchains.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from aiida.orm import Dict
from aiida.plugins import DataFactory

StructureData = DataFactory("core.structure") # pylint: disable=invalid-name
StructureData = DataFactory("core.structure")

HARTREE2EV = 27.211399
HARTREE2KJMOL = 2625.500
Expand All @@ -36,7 +36,7 @@ def merge_dict(dct, merge_dct):


@calcfunction
def merge_Dict(d1, d2): # pylint: disable=invalid-name
def merge_Dict(d1, d2):
"""Make all the data in the second Dict overwrite the corrisponding data in the first Dict"""
d1_dict = d1.get_dict()
d2_dict = d2.get_dict()
Expand Down Expand Up @@ -86,9 +86,7 @@ def ot_has_small_bandgap(cp2k_input, cp2k_output, bandgap_thr_ev):
list_true = [True, "T", "t", ".TRUE.", "True", "true"] # add more?
try:
ot_settings = cp2k_input["FORCE_EVAL"]["DFT"]["SCF"]["OT"]
if (
"_" not in ot_settings.keys() or ot_settings["_"] in list_true
): # pylint: disable=simplifiable-if-statement
if "_" not in ot_settings.keys() or ot_settings["_"] in list_true:
using_ot = True
else:
using_ot = False
Expand All @@ -103,7 +101,7 @@ def ot_has_small_bandgap(cp2k_input, cp2k_output, bandgap_thr_ev):


@calcfunction
def check_resize_unit_cell(struct, threshold): # pylint: disable=too-many-locals
def check_resize_unit_cell(struct, threshold):
"""Returns the multiplication factors for the cell vectors to respect, in every direction:
min(perpendicular_width) > threshold.
"""
Expand Down
4 changes: 2 additions & 2 deletions aiida_cp2k/workchains/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ..utils import add_ext_restart_section, add_wfn_restart_section

Cp2kCalculation = CalculationFactory('cp2k') # pylint: disable=invalid-name
Cp2kCalculation = CalculationFactory('cp2k')


class Cp2kBaseWorkChain(BaseRestartWorkChain):
Expand Down Expand Up @@ -81,7 +81,7 @@ def restart_incomplete_calculation(self, calc):
"Sending a signal to stop the Base work chain.")

# Signaling to the base work chain that the problem could not be recovered.
return ProcessHandlerReport(True, self.exit_codes.NO_RESTART_DATA) # pylint: disable=no-member
return ProcessHandlerReport(True, self.exit_codes.NO_RESTART_DATA)

self.ctx.inputs.parent_calc_folder = calc.outputs.remote_folder
params = self.ctx.inputs.parameters
Expand Down
16 changes: 7 additions & 9 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""
For pytest initialise a test database and profile
"""
"""For pytest initialise a test database and profile."""
import pytest

pytest_plugins = ["aiida.manage.tests.pytest_fixtures"] # pylint: disable=invalid-name
pytest_plugins = ["aiida.manage.tests.pytest_fixtures"]


@pytest.fixture(scope="function")
def cp2k_code(aiida_local_code_factory): # pylint: disable=unused-argument
def cp2k_code(aiida_local_code_factory):
return aiida_local_code_factory("cp2k", "cp2k")


Expand All @@ -18,13 +16,13 @@ def clear_database(aiida_profile_clean):

# from https://stackoverflow.com/a/25188424
# required for examples for optional features to show appropriate error messages
def pytest_configure(config): # pylint: disable=unused-argument
def pytest_configure(config):
import sys

sys._called_from_test = True # pylint: disable=protected-access
sys._called_from_test = True


def pytest_unconfigure(config): # pylint: disable=unused-argument
def pytest_unconfigure(config):
import sys

del sys._called_from_test # pylint: disable=protected-access
del sys._called_from_test
5 changes: 1 addition & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
serve to show the default.
"""

# pylint: disable=invalid-name,ungrouped-imports

import os
import sys
import time
Expand All @@ -32,7 +30,7 @@
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

import aiida_cp2k # pylint: disable=wrong-import-position
import aiida_cp2k

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -80,7 +78,6 @@
if current_year == copyright_first_year
else f"{copyright_first_year}-{current_year}"
)
# pylint: disable=redefined-builtin
copyright = f"{copyright_year_string}, {copyright_owners}. All rights reserved."

# The version info for the project you're documenting, acts as replacement for
Expand Down
5 changes: 2 additions & 3 deletions examples/gaussian_datatypes/example_automatic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=import-outside-toplevel
###############################################################################
# Copyright (c), The AiiDA-CP2K authors. #
# SPDX-License-Identifier: MIT #
Expand All @@ -18,7 +17,7 @@
from aiida.plugins import DataFactory
from gdt_data import load_data

StructureData = DataFactory("core.structure") # pylint: disable=invalid-name
StructureData = DataFactory("core.structure")


def example_gdt(cp2k_code):
Expand Down Expand Up @@ -95,4 +94,4 @@ def cli(codelabel):


if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter
cli()
5 changes: 2 additions & 3 deletions examples/gaussian_datatypes/example_explicit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=import-outside-toplevel
###############################################################################
# Copyright (c), The AiiDA-CP2K authors. #
# SPDX-License-Identifier: MIT #
Expand All @@ -18,7 +17,7 @@
from aiida.plugins import DataFactory
from gdt_data import load_data

StructureData = DataFactory("core.structure") # pylint: disable=invalid-name
StructureData = DataFactory("core.structure")


def example_gdt(cp2k_code):
Expand Down Expand Up @@ -113,4 +112,4 @@ def cli(codelabel):


if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter
cli()
5 changes: 2 additions & 3 deletions examples/gaussian_datatypes/gdt_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=import-outside-toplevel
###############################################################################
# Copyright (c), The AiiDA-CP2K authors. #
# SPDX-License-Identifier: MIT #
Expand Down Expand Up @@ -59,8 +58,8 @@ def load_data(prefix="MY-"):
0.25682890 0
"""

BasisSet = DataFactory("gaussian.basisset") # pylint: disable=invalid-name
Pseudo = DataFactory("gaussian.pseudo") # pylint: disable=invalid-name
BasisSet = DataFactory("gaussian.basisset")
Pseudo = DataFactory("gaussian.pseudo")

fhandle_bset = StringIO(bset_input)
fhandle_pseudo = StringIO(pseudo_input)
Expand Down
7 changes: 3 additions & 4 deletions examples/single_calculations/example_bands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=invalid-name
###############################################################################
# Copyright (c), The AiiDA-CP2K authors. #
# SPDX-License-Identifier: MIT #
Expand All @@ -18,8 +17,8 @@
from aiida.plugins import DataFactory
from ase.atoms import Atoms

StructureData = DataFactory("core.structure") # pylint: disable=invalid-name
KpointsData = DataFactory("core.array.kpoints") # pylint: disable=invalid-name
StructureData = DataFactory("core.structure")
KpointsData = DataFactory("core.array.kpoints")


def example_bands(cp2k_code):
Expand Down Expand Up @@ -241,4 +240,4 @@ def cli(codelabel):


if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter
cli()
5 changes: 2 additions & 3 deletions examples/single_calculations/example_dft.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=invalid-name
###############################################################################
# Copyright (c), The AiiDA-CP2K authors. #
# SPDX-License-Identifier: MIT #
Expand All @@ -17,7 +16,7 @@
from aiida.orm import Dict, SinglefileData, load_code
from aiida.plugins import DataFactory

StructureData = DataFactory("core.structure") # pylint: disable=invalid-name
StructureData = DataFactory("core.structure")


def example_dft(cp2k_code):
Expand Down Expand Up @@ -120,4 +119,4 @@ def cli(codelabel):


if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter
cli()
5 changes: 2 additions & 3 deletions examples/single_calculations/example_dft_atomic_kinds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=invalid-name
###############################################################################
# Copyright (c), The AiiDA-CP2K authors. #
# SPDX-License-Identifier: MIT #
Expand All @@ -17,7 +16,7 @@
from aiida.orm import Dict, SinglefileData, load_code
from aiida.plugins import DataFactory

StructureData = DataFactory("core.structure") # pylint: disable=invalid-name
StructureData = DataFactory("core.structure")


def example_dft_atomic_kinds(cp2k_code):
Expand Down Expand Up @@ -141,4 +140,4 @@ def cli(codelabel):


if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter
cli()
3 changes: 1 addition & 2 deletions examples/single_calculations/example_failure.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=invalid-name
###############################################################################
# Copyright (c), The AiiDA-CP2K authors. #
# SPDX-License-Identifier: MIT #
Expand Down Expand Up @@ -58,4 +57,4 @@ def cli(codelabel):


if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter
cli()
5 changes: 2 additions & 3 deletions examples/single_calculations/example_geopt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=invalid-name
###############################################################################
# Copyright (c), The AiiDA-CP2K authors. #
# SPDX-License-Identifier: MIT #
Expand All @@ -17,7 +16,7 @@
from aiida.orm import Dict, SinglefileData, load_code
from aiida.plugins import DataFactory

StructureData = DataFactory("core.structure") # pylint: disable=invalid-name
StructureData = DataFactory("core.structure")


def example_geopt(cp2k_code):
Expand Down Expand Up @@ -147,4 +146,4 @@ def cli(codelabel):


if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter
cli()
5 changes: 2 additions & 3 deletions examples/single_calculations/example_max_error.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=invalid-name
###############################################################################
# Copyright (c), The AiiDA-CP2K authors. #
# SPDX-License-Identifier: MIT #
Expand All @@ -17,7 +16,7 @@
from aiida.orm import Dict, SinglefileData, load_code
from aiida.plugins import CalculationFactory, DataFactory

StructureData = DataFactory("core.structure") # pylint: disable=invalid-name
StructureData = DataFactory("core.structure")
Cp2kCalculation = CalculationFactory("cp2k")


Expand Down Expand Up @@ -134,4 +133,4 @@ def cli(codelabel):


if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter
cli()
7 changes: 2 additions & 5 deletions examples/single_calculations/example_mm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=invalid-name
###############################################################################
# Copyright (c), The AiiDA-CP2K authors. #
# SPDX-License-Identifier: MIT #
Expand Down Expand Up @@ -45,9 +44,7 @@ def example_mm(cp2k_code):
END"""
)

water_pot = SinglefileData(
file=os.path.join("/tmp", "water.pot")
) # pylint: disable=no-value-for-parameter
water_pot = SinglefileData(file=os.path.join("/tmp", "water.pot"))

thisdir = os.path.dirname(os.path.realpath(__file__))

Expand Down Expand Up @@ -148,4 +145,4 @@ def cli(codelabel):


if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter
cli()
Loading

0 comments on commit 49a1435

Please sign in to comment.