Skip to content

Commit

Permalink
Merge 91465b4 into 6386ff5
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha committed Jan 5, 2023
2 parents 6386ff5 + 91465b4 commit fe4aceb
Show file tree
Hide file tree
Showing 26 changed files with 497 additions and 458 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
extend-ignore =
E501
W503
E203
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
password: ${{ secrets.PYPI_TOKEN }}
45 changes: 35 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
# Install pre-commit hooks via:
# pre-commit install

# yapf = yet another python formatter
---
repos:
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.28.0
hooks:
- id: yapf
name: yapf
args: ["-i"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
exclude: ^.*data/
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: [--profile, black, --filter-files]
- repo: https://github.com/PyCQA/autoflake
rev: v2.0.0
hooks:
- id: autoflake
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args: [--count, --show-source, --statistics]
additional_dependencies: [flake8-bugbear, flake8-builtins, flake8-comprehensions,
flake8-debugger, flake8-logging-format, pep8-naming, pyflakes, tryceratops]
7 changes: 0 additions & 7 deletions .style.yapf

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ parameters = {
},
'input_parameters': { # appended at the end of the input
'output.wfx':None
},
},
}
```
In `route_parameters`, specifying `key: None` adds only `key` without the equals sign to the input script.
Expand All @@ -56,7 +56,7 @@ A quick demo of how to submit a calculation:
verdi daemon start # make sure the daemon is running
cd examples
# Submit test calculation (argument is the label of gaussian code)
verdi run example_01_opt.py gaussian09
verdi run example_01_opt.py gaussian09
```

## For maintainers
Expand Down
1 change: 0 additions & 1 deletion aiida_gaussian/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
aiida_gaussian
Expand Down
9 changes: 4 additions & 5 deletions aiida_gaussian/calculations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from .gaussian import GaussianCalculation
from .formchk import FormchkCalculation
from .cubegen import CubegenCalculation
from .formchk import FormchkCalculation
from .gaussian import GaussianCalculation

__all__ = ["CubegenCalculation", "FormchkCalculation", "GaussianCalculation"]
34 changes: 18 additions & 16 deletions aiida_gaussian/calculations/cubegen.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
"""Gaussian input plugin."""
from __future__ import absolute_import

from aiida.orm import Dict, RemoteData, Str, Int, Bool, SinglefileData
from aiida.common import CalcInfo, CodeInfo
from aiida.engine import CalcJob
from aiida.orm import Bool, Dict, Int, RemoteData, SinglefileData


class CubegenCalculation(CalcJob):
Expand Down Expand Up @@ -42,20 +40,20 @@ class CubegenCalculation(CalcJob):

@classmethod
def define(cls, spec):
super(CubegenCalculation, cls).define(spec)
super().define(spec)

spec.input(
"parameters",
valid_type=Dict,
required=True,
help='dictionary containing entries for cubes to be printed.'
help="dictionary containing entries for cubes to be printed.",
)

spec.input(
'parent_calc_folder',
"parent_calc_folder",
valid_type=RemoteData,
required=True,
help='the folder of a containing the .fchk'
help="the folder of a containing the .fchk",
)

spec.input(
Expand All @@ -66,23 +64,23 @@ def define(cls, spec):
)

spec.input(
'retrieve_cubes',
"retrieve_cubes",
valid_type=Bool,
required=False,
default=lambda: Bool(False),
help='should the cubes be retrieved?'
help="should the cubes be retrieved?",
)

spec.input(
"gauss_memdef",
valid_type=Int,
required=False,
default=lambda: Int(1024),
help="Set the GAUSS_MEMDEF env variable to set the max memory in MB."
help="Set the GAUSS_MEMDEF env variable to set the max memory in MB.",
)

# Turn mpi off by default
spec.input('metadata.options.withmpi', valid_type=bool, default=False)
spec.input("metadata.options.withmpi", valid_type=bool, default=False)

spec.input(
"metadata.options.parser_name",
Expand Down Expand Up @@ -122,7 +120,7 @@ def prepare_for_submission(self, folder):

if "stencil" in self.inputs:
calcinfo.local_copy_list.append(
(self.inputs.stencil.uuid, self.inputs.stencil.filename, 'stencil.txt')
(self.inputs.stencil.uuid, self.inputs.stencil.filename, "stencil.txt")
)

for key, params in self.inputs.parameters.get_dict().items():
Expand All @@ -136,15 +134,19 @@ def prepare_for_submission(self, folder):

codeinfo.cmdline_params = []
codeinfo.cmdline_params.append(
str(self.inputs.metadata.options.resources['tot_num_mpiprocs'])
str(self.inputs.metadata.options.resources["tot_num_mpiprocs"])
)
codeinfo.cmdline_params.append(kind_str)
codeinfo.cmdline_params.append(self.PARENT_FOLDER_NAME + "/" + self.DEFAULT_INPUT_FILE)
codeinfo.cmdline_params.append(
self.PARENT_FOLDER_NAME + "/" + self.DEFAULT_INPUT_FILE
)
codeinfo.cmdline_params.append(cube_name)

if npts == -1:
if 'stencil' not in self.inputs:
self.report("Warning: npts: -1 set but no stencil provided, using -2")
if "stencil" not in self.inputs:
self.report(
"Warning: npts: -1 set but no stencil provided, using -2"
)
codeinfo.cmdline_params.append("-2")
else:
codeinfo.cmdline_params.append(str(npts))
Expand Down
27 changes: 14 additions & 13 deletions aiida_gaussian/calculations/formchk.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
"""Gaussian formchk plugin."""
from __future__ import absolute_import

from aiida.orm import List, RemoteData, SinglefileData, Str, Bool
from aiida.common import CalcInfo, CodeInfo
from aiida.engine import CalcJob
from aiida.orm import Bool, RemoteData, Str


class FormchkCalculation(CalcJob):
Expand All @@ -18,31 +16,31 @@ class FormchkCalculation(CalcJob):

@classmethod
def define(cls, spec):
super(FormchkCalculation, cls).define(spec)
super().define(spec)

spec.input(
'parent_calc_folder',
"parent_calc_folder",
valid_type=RemoteData,
required=True,
help='the folder of a containing the .chk'
help="the folder of a containing the .chk",
)
spec.input(
'chk_name',
"chk_name",
valid_type=Str,
required=False,
default=lambda: Str(cls.DEFAULT_INPUT_FILE),
help="name of the checkpoint file"
help="name of the checkpoint file",
)
spec.input(
'retrieve_fchk',
"retrieve_fchk",
valid_type=Bool,
required=False,
default=lambda: Bool(False),
help="retrieve the fchk file"
help="retrieve the fchk file",
)

# Turn mpi off by default
spec.input('metadata.options.withmpi', valid_type=bool, default=False)
spec.input("metadata.options.withmpi", valid_type=bool, default=False)

# --------------------------------------------------------------------------
def prepare_for_submission(self, folder):
Expand All @@ -51,7 +49,8 @@ def prepare_for_submission(self, folder):
codeinfo = CodeInfo()
codeinfo.code_uuid = self.inputs.code.uuid
codeinfo.cmdline_params = [
self.PARENT_FOLDER_NAME + "/" + self.inputs.chk_name.value, self.DEFAULT_OUTPUT_FILE
self.PARENT_FOLDER_NAME + "/" + self.inputs.chk_name.value,
self.DEFAULT_OUTPUT_FILE,
]
codeinfo.withmpi = self.inputs.metadata.options.withmpi

Expand All @@ -70,7 +69,9 @@ def prepare_for_submission(self, folder):
comp_uuid = self.inputs.parent_calc_folder.computer.uuid
remote_path = self.inputs.parent_calc_folder.get_remote_path()
copy_info = (comp_uuid, remote_path, self.PARENT_FOLDER_NAME)
if self.inputs.code.computer.uuid == comp_uuid: # if running on the same computer - make a symlink
if (
self.inputs.code.computer.uuid == comp_uuid
): # if running on the same computer - make a symlink
# if not - copy the folder
calcinfo.remote_symlink_list.append(copy_info)
else:
Expand Down
27 changes: 15 additions & 12 deletions aiida_gaussian/calculations/gaussian.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# -*- coding: utf-8 -*-
"""Gaussian input plugin."""
from __future__ import absolute_import

from aiida.orm import Dict, RemoteData, Float
import pymatgen.io.gaussian as mgaus
from aiida.common import CalcInfo, CodeInfo

# from aiida.cmdline.utils import echo
from aiida.engine import CalcJob
from aiida.orm import Dict, Float, RemoteData
from aiida.plugins import DataFactory

import pymatgen.io.gaussian as mgaus

StructureData = DataFactory("core.structure")


class GaussianCalculation(CalcJob):
"""
AiiDA calculation plugin wrapping Gaussian
Template:
parameters = Dict(dict={
Expand Down Expand Up @@ -47,7 +44,7 @@ class GaussianCalculation(CalcJob):

@classmethod
def define(cls, spec):
super(GaussianCalculation, cls).define(spec)
super().define(spec)

# Input parameters
spec.input(
Expand All @@ -57,7 +54,9 @@ def define(cls, spec):
help="Input structure; will be converted to pymatgen object",
)

spec.input("parameters", valid_type=Dict, required=True, help="Input parameters")
spec.input(
"parameters", valid_type=Dict, required=True, help="Input parameters"
)
spec.input(
"settings",
valid_type=Dict,
Expand Down Expand Up @@ -162,7 +161,7 @@ def prepare_for_submission(self, folder):
the plugin should put all its files.
"""

if 'structure' in self.inputs:
if "structure" in self.inputs:
pmg_structure = self.inputs.structure.get_pymatgen_molecule()
else:
# If structure is not specified, it is read from the chk file
Expand Down Expand Up @@ -204,7 +203,7 @@ def prepare_for_submission(self, folder):
comp_uuid = self.inputs.parent_calc_folder.computer.uuid
remote_path = self.inputs.parent_calc_folder.get_remote_path()
copy_info = (comp_uuid, remote_path, self.PARENT_FOLDER_NAME)
if (self.inputs.code.computer.uuid == comp_uuid):
if self.inputs.code.computer.uuid == comp_uuid:
# if running on the same computer - make a symlink
# if not - copy the folder
calcinfo.remote_symlink_list.append(copy_info)
Expand All @@ -229,13 +228,17 @@ def _render_input_string_from_params(cls, param_dict, pmg_structure):
pmg_structure,
title="input generated by the aiida-gaussian plugin",
charge=param_dict.get("charge"),
spin_multiplicity=param_dict.get("multiplicity", param_dict.get("spin_multiplicity")),
spin_multiplicity=param_dict.get(
"multiplicity", param_dict.get("spin_multiplicity")
),
functional=param_dict.get("functional"),
basis_set=param_dict.get("basis_set"),
route_parameters=param_dict.get("route_parameters"),
input_parameters=param_dict.get("input_parameters"),
link0_parameters=param_dict.get("link0_parameters"),
dieze_tag=param_dict.get("dieze_tag", "#N"), # normal print level by default
dieze_tag=param_dict.get(
"dieze_tag", "#N"
), # normal print level by default
)

return inp.to_string(cart_coords=True)

0 comments on commit fe4aceb

Please sign in to comment.