Skip to content

Commit

Permalink
Remove Python2 compatibility. (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha committed Feb 20, 2020
1 parent 0dcc2c1 commit 2024b32
Show file tree
Hide file tree
Showing 38 changed files with 14 additions and 93 deletions.
2 changes: 0 additions & 2 deletions .ci/check_travis_tag.py
Original file line number Diff line number Diff line change
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: 1 addition & 1 deletion .docker/opt/add-codes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ fi
unset __conda_setup

# Install raspa code.
verdi code show raspa@localhost || verdi code setup --config /opt/aiida-raspa/.docker/raspa-code.yml --non-interactive
verdi code show raspa@localhost || verdi code setup --config /opt/aiida-raspa/.docker/raspa-code.yml --non-interactive
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ 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
7 changes: 2 additions & 5 deletions aiida_raspa/calculations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# -*- coding: utf-8 -*-
"""Raspa input plugin."""
from __future__ import absolute_import
import os
from shutil import copyfile, copytree
import six
from six.moves import map, range

from aiida.orm import Dict, FolderData, List, RemoteData, SinglefileData
from aiida.common import CalcInfo, CodeInfo, InputValidationError
Expand All @@ -31,7 +28,7 @@ class RaspaCalculation(CalcJob):

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

#Input parameters
spec.input('parameters', valid_type=Dict, required=True, help='Input parameters')
Expand All @@ -55,7 +52,7 @@ def define(cls, spec):
valid_type=FolderData,
required=False,
help='To use an old calculation as a starting poing for a new one.')
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)

# Output parameters
spec.output('output_parameters', valid_type=Dict, required=True, help="The results of a calculation")
Expand Down
2 changes: 0 additions & 2 deletions aiida_raspa/parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Raspa output parser."""
from __future__ import absolute_import
import os
from six.moves import range

from aiida.common import NotExistent, OutputParsingError
from aiida.engine import ExitCode
Expand Down
1 change: 0 additions & 1 deletion aiida_raspa/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
"""Raspa utils."""
from __future__ import absolute_import
from .base_parser import parse_base_output
from .base_input_generator import RaspaInput
from .inspection_tools import check_widom_convergence, check_gcmc_convergence, check_gemc_convergence
Expand Down
4 changes: 1 addition & 3 deletions aiida_raspa/utils/base_input_generator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Basic raspa input generator."""
from __future__ import absolute_import
from copy import deepcopy
import six

ORDERED_ITEMS_COMPONENT_SECTION = [
"NumberOfIdentityChanges",
Expand Down Expand Up @@ -63,7 +61,7 @@ def render(self):

molecule["BlockPocketsFileName"] = bps
molecule["BlockPockets"] = ["yes" if bp else "no" for bp in bps]
elif isinstance(molecule["BlockPocketsFileName"], six.string_types):
elif isinstance(molecule["BlockPocketsFileName"], str):
molecule["BlockPockets"] = "yes"

if "CreateNumberOfMolecules" in molecule:
Expand Down
4 changes: 0 additions & 4 deletions aiida_raspa/utils/base_parser.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# -*- coding: utf-8 -*-
"""Basic raspa output parser."""
from __future__ import absolute_import
from __future__ import print_function
import re

from math import isnan, isinf
from six.moves import range
from six.moves import zip

float_base = float # pylint: disable=invalid-name

Expand Down
4 changes: 0 additions & 4 deletions aiida_raspa/utils/inspection_tools.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# -*- coding: utf-8 -*-
"""RASPA inspection tools"""
from __future__ import print_function
from __future__ import absolute_import

from six.moves import range

from aiida.engine import calcfunction
from aiida.orm import Dict, Int, Str, Float
Expand Down
1 change: 0 additions & 1 deletion aiida_raspa/utils/other_utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
"""Other utilities."""
from __future__ import absolute_import
from collections import namedtuple
from functools import wraps

Expand Down
9 changes: 4 additions & 5 deletions aiida_raspa/workchains/aiida_base_restart.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# pylint: disable=inconsistent-return-statements,no-member
"""Base implementation of `WorkChain` class that implements a simple automated restart mechanism for calculations."""
from __future__ import absolute_import

from aiida import orm
from aiida.common import exceptions
Expand Down Expand Up @@ -58,7 +57,7 @@ class BaseRestartWorkChain(WorkChain):

def __init__(self, *args, **kwargs):
"""Construct the instance."""
super(BaseRestartWorkChain, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

if self._calculation_class is None or not issubclass(self._calculation_class, CalcJob):
raise ValueError('no valid CalcJob class defined for `_calculation_class` attribute')
Expand All @@ -72,7 +71,7 @@ def load_instance_state(self, saved_state, load_context):
:param saved_state: saved state of existing process instance
:param load_context: context for loading instance state
"""
super(BaseRestartWorkChain, self).load_instance_state(saved_state, load_context)
super().load_instance_state(saved_state, load_context)
self._load_error_handlers()

def _load_error_handlers(self):
Expand All @@ -91,7 +90,7 @@ def _load_error_handlers(self):
def define(cls, spec):
"""Define the process specification."""
# yapf: disable
super(BaseRestartWorkChain, cls).define(spec)
super().define(spec)
spec.input('max_iterations', valid_type=orm.Int, default=lambda: orm.Int(5),
help='Maximum number of iterations the work chain will restart the calculation to finish successfully.')
spec.input('clean_workdir', valid_type=orm.Bool, default=lambda: orm.Bool(False),
Expand Down Expand Up @@ -222,7 +221,7 @@ def results(self):

def on_terminated(self):
"""Clean the working directories of all child calculations if `clean_workdir=True` in the inputs."""
super(BaseRestartWorkChain, self).on_terminated()
super().on_terminated()

if self.inputs.clean_workdir.value is False:
self.report('remote folders will not be cleaned')
Expand Down
9 changes: 4 additions & 5 deletions aiida_raspa/workchains/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
"""Base workchain to run a RASPA calculation"""
from __future__ import absolute_import

from aiida.common import AttributeDict
from aiida.engine import while_
Expand All @@ -20,7 +19,7 @@ class RaspaBaseWorkChain(BaseRestartWorkChain):

@classmethod
def define(cls, spec):
super(RaspaBaseWorkChain, cls).define(spec)
super().define(spec)
spec.expose_inputs(RaspaCalculation, namespace='raspa')
spec.outline(
cls.setup,
Expand All @@ -35,9 +34,9 @@ def define(cls, spec):
def setup(self):
"""Call the `setup` of the `BaseRestartWorkChain` and then create the inputs dictionary in `self.ctx.inputs`.
This `self.ctx.inputs` dictionary will be used by the `BaseRestartWorkChain` to submit the calculations in the
internal loop.
"""
super(RaspaBaseWorkChain, self).setup()
internal loop."""

super().setup()
self.ctx.inputs = AttributeDict(self.exposed_inputs(RaspaCalculation, 'raspa'))
if "WriteBinaryRestartFileEvery" not in self.ctx.inputs.parameters["GeneralSettings"]:
self.ctx.inputs.parameters = add_write_binary_restart(self.ctx.inputs.parameters, Int(1000))
Expand Down
1 change: 0 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
For pytest initialise a test database and profile
"""
from __future__ import absolute_import
import pytest
pytest_plugins = ['aiida.manage.tests.pytest_fixtures'] # pylint: disable=invalid-name

Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@
master_doc = 'index'

# General information about the project.
project = u'aiida-raspa'
project = 'aiida-raspa'
copyright_first_year = "2019"
copyright_owners = "The AiiDA Team"

current_year = str(time.localtime().tm_year)
copyright_year_string = current_year if current_year == copyright_first_year else "{}-{}".format(
copyright_first_year, current_year)
# pylint: disable=redefined-builtin
copyright = u'{}, {}. All rights reserved'.format(copyright_year_string, copyright_owners)
copyright = '{}, {}. All rights reserved'.format(copyright_year_string, copyright_owners)

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_calculations/example_base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Run simple RASPA calculation."""

from __future__ import print_function
from __future__ import absolute_import
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_calculations/example_base_restart.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Restart from simple RASPA calculation."""

from __future__ import print_function
from __future__ import absolute_import
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_calculations/example_binary_mixture.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Run RASPA calculation with components mixture."""

from __future__ import print_function
from __future__ import absolute_import
import sys
import click

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
"""Run RASPA calculation with blocked pockets."""
from __future__ import print_function
from __future__ import absolute_import
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_calculations/example_block_pockets_simple.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
"""Run RASPA calculation with blocked pockets."""
from __future__ import print_function
from __future__ import absolute_import
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_calculations/example_ff_files.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Run RASPA calculation using Local force field"""

from __future__ import print_function
from __future__ import absolute_import
import sys
import os
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_calculations/example_framework_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# -*- coding: utf-8 -*-
"""Run simple RASPA calculation."""

from __future__ import print_function
from __future__ import absolute_import
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_calculations/example_framework_box_restart.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Run simple RASPA calculation."""

from __future__ import print_function
from __future__ import absolute_import
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_calculations/example_gemc_single_comp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Run RASPA single-component GEMC calculation"""

from __future__ import print_function
from __future__ import absolute_import
import sys
import click
import pytest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Run RASPA single-component GEMC calculation -- Restart"""

from __future__ import print_function
from __future__ import absolute_import
import sys
import click
import pytest
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_calculations/example_henry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
"""Run RASPA calculation to compute Henry coefficient."""
from __future__ import print_function
from __future__ import absolute_import
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_calculations/example_identity.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Run simple RASPA calculation."""

from __future__ import print_function
from __future__ import absolute_import
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/simple_calculations/fixme_base_binary_restart.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Restart from simple RASPA calculation."""

from __future__ import print_function
from __future__ import absolute_import
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/workchains/example_base_restart_timeout.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Example for RaspaBaseWorkChain."""

from __future__ import absolute_import
from __future__ import print_function
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/workchains/example_base_workchain_gcmc_2comp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Two-component GCMC through RaspaBaseWorkChain"""

from __future__ import absolute_import
from __future__ import print_function
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/workchains/example_base_workchain_gemc_1comp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""One-component GEMC through RaspaBaseWorkChain"""

from __future__ import absolute_import
from __future__ import print_function
import sys
import click

Expand Down
2 changes: 0 additions & 2 deletions examples/workchains/example_base_workchain_widom_1comp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""One-component Widom particle insertion through RaspaBaseWorkChain"""

from __future__ import absolute_import
from __future__ import print_function
import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/workchains/example_base_workchain_widom_2comp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Two-component Widom insertion through RaspaBaseWorkChain"""

from __future__ import absolute_import
from __future__ import print_function
import os
import sys
import click
Expand Down

0 comments on commit 2024b32

Please sign in to comment.