Fix formatting and typos.
authorM. Eric Irrgang <ericirrgang@gmail.com>
Wed, 8 May 2019 12:30:58 +0000 (15:30 +0300)
committerMark Abraham <mark.j.abraham@gmail.com>
Thu, 9 May 2019 06:13:18 +0000 (08:13 +0200)
Resolve some typos from earlier rebase.

Rearrange imports, dunders, and white space for better PEP8 compliance.

Change-Id: I14319b7882e17937f92951339a5caf9bc454cf4d

python_packaging/src/gmxapi/commandline.py
python_packaging/src/gmxapi/operation.py
python_packaging/src/gmxapi/version.py
python_packaging/src/test/conftest.py
python_packaging/test/conftest.py
python_packaging/test/pytesthelpers.py
python_packaging/test/test_fr01.py
python_packaging/test/test_fr02.py
python_packaging/test/test_fr03.py

index aa732a87fd902969995a6b51557c451c3190e58d..3891e277c01d2d4e2d5fdec100ac6c2a62558e26 100644 (file)
@@ -37,9 +37,9 @@ Provide command line operation.
 
 __all__ = []
 
-from os import devnull
 import shutil
 import subprocess
+from os import devnull
 
 from gmxapi import exceptions
 from gmxapi import logging
index bf2a6b17c7234102a4f82e9a5bdcd09099d6160d..7c8dc598c4114e5ecbd6998652161fbea1bf8361 100644 (file)
@@ -48,12 +48,6 @@ instance is run.
 The framework ensures that an Operation instance is executed no more than once.
 """
 
-import collections
-from contextlib import contextmanager
-import functools
-import inspect
-import weakref
-
 __all__ = ['computed_result',
            'append_list',
            'concatenate_lists',
@@ -61,6 +55,12 @@ __all__ = ['computed_result',
            'make_constant',
            ]
 
+import collections
+import functools
+import inspect
+import weakref
+from contextlib import contextmanager
+
 from gmxapi import exceptions
 
 
@@ -211,6 +211,7 @@ def make_constant(value):
     # TODO: (FR4+) Manage type compatibility with gmxapi data interfaces.
     return type(value)(value)
 
+
 # In the longer term, Contexts could provide metaclasses that allow transformation or dispatching
 # of the basic aspects of the operation protocols between Contexts or from a result handle into a
 # new context, based on some attribute or behavior in the result handle.
@@ -309,6 +310,7 @@ def function_wrapper(output=None):
         Acts as an owning handle to ``instance``, preventing the reference count
         of ``instance`` from going to zero for the lifetime of the proxy object.
         """
+
         def __init__(self, instance):
             self._instance = instance
 
@@ -518,8 +520,10 @@ def function_wrapper(output=None):
                     dependencies that the framework promises to satisfy before the Operation
                     executes and produces output.
                     """
-                    ## Define the unique identity and data flow constraints of this work graph node.
-                    # TODO: (FR3) generalize
+                    #
+                    # Define the unique identity and data flow constraints of this work graph node.
+                    #
+                    # TODO: (FR4) generalize
                     input_dependencies = []
 
                     # TODO: Make allowed input strongly specified in the Operation definition.
@@ -538,9 +542,8 @@ def function_wrapper(output=None):
                     # TODO: Check input types
 
                     self.__input = PyFuncInput(args=[],
-                                         kwargs=input_kwargs,
-                                         dependencies=input_dependencies)
-                    ##
+                                               kwargs=input_kwargs,
+                                               dependencies=input_dependencies)
 
                     # TODO: (FR5+) Split the definition of the resource structure
                     #  and the resource initialization.
index 342278d46df72ac8fe4c5cfb7dccd486bf25b570..d598f02bef4b9bd755720b27725940d8963c6588 100644 (file)
@@ -30,6 +30,7 @@
 #
 # To help us fund GROMACS development, we humbly ask that you cite
 # the research papers on the package. Check out http://www.gromacs.org.
+
 """
 Provide version and release information.
 
@@ -41,6 +42,8 @@ Attributes:
 
 """
 
+__version__ = "0.1.0-dev0"
+
 # TODO: (pending infrastructure and further discussion) Configure with CMake.
 # __version__ = "@PROJECT_VERSION@"
 # major = @PROJECT_VERSION_MAJOR@
@@ -49,7 +52,6 @@ Attributes:
 
 from gmxapi.exceptions import Error as GmxapiError
 
-__version__ = "0.1.0-dev0"
 major = 0
 minor = 1
 patch = 0
index 2ccbc80c893a426bbf9333c4acd155ac365126d1..d0cbe405da41e3712d7049d07eaa5d624132e4b5 100644 (file)
@@ -38,6 +38,7 @@ import pytest
 import tempfile
 import os
 
+
 @pytest.fixture()
 def cleandir():
     """Provide a clean working directory for tests.
index 2ccbc80c893a426bbf9333c4acd155ac365126d1..f1775fec88f3bab2f1447f08d95222c9e409a325 100644 (file)
 
 """Configuration and fixtures for pytest."""
 
-import pytest
-import tempfile
 import os
+import tempfile
+
+import pytest
+
 
 @pytest.fixture()
 def cleandir():
index c8d8756c7dd75af3dacd0cf88424a1ef5e215747..60ae6e034e25a664743b267fb030e36dd870dcd5 100644 (file)
@@ -45,7 +45,7 @@ try:
     from mpi4py import MPI
     withmpi_only = \
         pytest.mark.skipif(not MPI.Is_initialized() or MPI.COMM_WORLD.Get_size() < 2,
-                           reason="Test requires at least 2 MPI ranks, " +
-                                  "but MPI is not initialized or context is too small.")
+                           reason="Test requires at least 2 MPI ranks, "
+                                  "but MPI is not initialized or context is too small.")
 except ImportError:
     withmpi_only = pytest.mark.skip(reason="Test requires at least 2 MPI ranks, but mpi4py is not available.")
index cf8c92fcde28f6a02d2951540f84e5c57b15809a..183e2557bb84c46313aeed0b9a753ddce27f9010 100644 (file)
 
 """Test gmxapi functionality described in roadmap.rst."""
 
-import pytest
-
 import gmxapi as gmx
+import pytest
 from gmxapi.version import has_feature
 
+
 @pytest.mark.skipif(not has_feature('fr1'),
-                   reason="Feature level not met.")
+                    reason="Feature level not met.")
 def test_fr1():
     """FR1: Wrap importable Python code.
 
index 6a0e886999942e905e0cd0a4a106ddbf561870e2..c10e2cee5ebd4fdd61129b369a286aee2b44c7f5 100644 (file)
 import os
 import tempfile
 
-import pytest
-
 import gmxapi as gmx
+import pytest
 from gmxapi.version import has_feature
 
+
 @pytest.mark.skipif(not has_feature('fr2'),
-                   reason="Feature level not met.")
+                    reason="Feature level not met.")
 def test_fr2():
     """FR2: Output proxy establishes execution dependency.
 
index 5781a9cf4e98d3b7200e35ea46d0489b22a8155c..b7f16f29bcf14d07792368797fbd3a2c22c8bef8 100644 (file)
 """Test gmxapi functionality described in roadmap.rst."""
 
 import os
+import shutil
 import stat
 import tempfile
 
-import pytest
-
 import gmxapi as gmx
+import pytest
 from gmxapi.version import has_feature
 
+
 @pytest.mark.skipif(not has_feature('fr3'),
-                   reason="Feature level not met.")
+                    reason="Feature level not met.")
 def test_fr3():
     """FR3: Output proxy can be used as input."""
     with tempfile.TemporaryDirectory() as directory:
@@ -54,7 +55,7 @@ def test_fr3():
         # Make a shell script that acts like the type of tool we are wrapping.
         scriptname = os.path.join(directory, 'clicommand.sh')
         with open(scriptname, 'w') as fh:
-            fh.write('\n'.join(['#!' + util.which('bash'),
+            fh.write('\n'.join(['#!' + shutil.which('bash'),
                                 '# Concatenate an input file and a string argument to an output file.',
                                 '# Mock a utility with the tested syntax.',
                                 '#     clicommand.sh "some words" -i inputfile -o outputfile',
@@ -62,16 +63,16 @@ def test_fr3():
         os.chmod(scriptname, stat.S_IRWXU)
 
         line1 = 'first line'
-        filewriter1 = commandline_operation(scriptname,
-                                            arguments=[line1],
-                                            input_files={'-i': os.devnull},
-                                            output_files={'-o': file1})
+        filewriter1 = gmx.commandline_operation(scriptname,
+                                                arguments=[line1],
+                                                input_files={'-i': os.devnull},
+                                                output_files={'-o': file1})
 
         line2 = 'second line'
-        filewriter2 = commandline_operation(scriptname,
-                                            arguments=[line2],
-                                            input_files={'-i': filewriter1.output.file['-o']},
-                                            output_files={'-o': file2})
+        filewriter2 = gmx.commandline_operation(scriptname,
+                                                arguments=[line2],
+                                                input_files={'-i': filewriter1.output.file['-o']},
+                                                output_files={'-o': file2})
 
         filewriter2.run()
         # Check that the files have the expected lines