Resolve some typos from earlier rebase.
Rearrange imports, dunders, and white space for better PEP8 compliance.
Change-Id: I14319b7882e17937f92951339a5caf9bc454cf4d
__all__ = []
-from os import devnull
import shutil
import subprocess
+from os import devnull
from gmxapi import exceptions
from gmxapi import logging
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',
'make_constant',
]
+import collections
+import functools
+import inspect
+import weakref
+from contextlib import contextmanager
+
from gmxapi import exceptions
# 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.
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
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.
# 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.
#
# 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.
"""
+__version__ = "0.1.0-dev0"
+
# TODO: (pending infrastructure and further discussion) Configure with CMake.
# __version__ = "@PROJECT_VERSION@"
# major = @PROJECT_VERSION_MAJOR@
from gmxapi.exceptions import Error as GmxapiError
-__version__ = "0.1.0-dev0"
major = 0
minor = 1
patch = 0
import tempfile
import os
+
@pytest.fixture()
def cleandir():
"""Provide a clean working directory for tests.
"""Configuration and fixtures for pytest."""
-import pytest
-import tempfile
import os
+import tempfile
+
+import pytest
+
@pytest.fixture()
def cleandir():
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.")
"""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.
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.
"""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:
# 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',
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