From 82f499610b792a90802a9ca24439d9deddbd4409 Mon Sep 17 00:00:00 2001 From: "M. Eric Irrgang" Date: Wed, 30 Sep 2020 15:39:37 +0300 Subject: [PATCH] Restrict gmxapi pytest tests to `-nt 2` Fixes #3704 The current change is a quick fix to alleviate pressure on the project's automation resources. Hard-coded resource constraints should be removed in a follow-up change. Also, the new facility to the mdrun ResourceManager needs to be considered in future work. --- .../sample_restraint/tests/test_binding.py | 8 ++++++-- python_packaging/src/gmxapi/simulation/mdrun.py | 10 +++++++--- python_packaging/src/test/test_mdrun.py | 8 +++++++- python_packaging/test/pytesthelpers.py | 8 +++++++- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/python_packaging/sample_restraint/tests/test_binding.py b/python_packaging/sample_restraint/tests/test_binding.py index f0d3bb98c7..7dff38ca63 100644 --- a/python_packaging/sample_restraint/tests/test_binding.py +++ b/python_packaging/sample_restraint/tests/test_binding.py @@ -42,7 +42,9 @@ def test_ensemble_potential_nompi(spc_water_box): print("Testing plugin potential with input file {}".format(os.path.abspath(tpr_filename))) assert gmx.version.api_is_at_least(0, 0, 5) - md = from_tpr([tpr_filename], append_output=False) + # Note that *threads* argument causes errors for MPI-enabled GROMACS. + # Ref #3563 and #3573 + md = from_tpr([tpr_filename], append_output=False, threads=2) # Create a WorkElement for the potential params = {'sites': [1, 4], @@ -79,7 +81,9 @@ def test_ensemble_potential_withmpi(spc_water_box): logger.info("Testing plugin potential with input file {}".format(os.path.abspath(tpr_filename))) assert gmx_version.api_is_at_least(0, 0, 5) - md = from_tpr([tpr_filename, tpr_filename], append_output=False) + # Note that *threads* argument causes errors for MPI-enabled GROMACS. + # Ref #3563 and #3573 + md = from_tpr([tpr_filename, tpr_filename], append_output=False, threads=2) # Create a WorkElement for the potential params = {'sites': [1, 4], diff --git a/python_packaging/src/gmxapi/simulation/mdrun.py b/python_packaging/src/gmxapi/simulation/mdrun.py index 066d40c4c0..92f904a0b8 100644 --- a/python_packaging/src/gmxapi/simulation/mdrun.py +++ b/python_packaging/src/gmxapi/simulation/mdrun.py @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2019, by the GROMACS development team, led by +# Copyright (c) 2019,2020, by the GROMACS development team, led by # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, # and including many others, as listed in the AUTHORS file in the # top-level source directory and at http://www.gromacs.org. @@ -261,8 +261,12 @@ class LegacyImplementationSubscription(object): ensemble_rank, self.workdir )) - # TODO: We have not exposed the ability to pass any run time parameters to mdrun. - work = workflow.from_tpr(tpr_filenames) + # TODO: Normalize the way we pass run time parameters to mdrun. + # See also #3573 + kwargs = getattr(resource_manager, 'mdrun_kwargs', {}) + for key, value in kwargs.items(): + logger.debug('Adding mdrun run time argument: {}'.format(key + '=' + str(value))) + work = workflow.from_tpr(tpr_filenames, **kwargs) self.workspec = work.workspec context = LegacyContext(work=self.workspec, workdir_list=workdir_list, communicator=ensemble_comm) self.simulation_module_context = context diff --git a/python_packaging/src/test/test_mdrun.py b/python_packaging/src/test/test_mdrun.py index e18d2bbe8b..132267291c 100644 --- a/python_packaging/src/test/test_mdrun.py +++ b/python_packaging/src/test/test_mdrun.py @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2019, by the GROMACS development team, led by +# Copyright (c) 2019,2020, by the GROMACS development team, led by # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, # and including many others, as listed in the AUTHORS file in the # top-level source directory and at http://www.gromacs.org. @@ -48,6 +48,12 @@ import pytest import gmxapi as gmx +# TODO: (#3573) Normalize the handling of run-time arguments. +from gmxapi.simulation.mdrun import ResourceManager as _ResourceManager +# Note that *threads* argument causes errors for MPI-enabled GROMACS. +# Ref #3563 and #3573 +_ResourceManager.mdrun_kwargs = {'threads': 2} + # Configure the `logging` module before proceeding any further. gmx.logger.setLevel(logging.WARNING) diff --git a/python_packaging/test/pytesthelpers.py b/python_packaging/test/pytesthelpers.py index 60ae6e034e..480dd45f86 100644 --- a/python_packaging/test/pytesthelpers.py +++ b/python_packaging/test/pytesthelpers.py @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2019, by the GROMACS development team, led by +# Copyright (c) 2019,2020, by the GROMACS development team, led by # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, # and including many others, as listed in the AUTHORS file in the # top-level source directory and at http://www.gromacs.org. @@ -39,6 +39,12 @@ Define the ``withmpi_only`` test decorator. import pytest +# TODO: (#3573) Normalize the handling of run-time arguments. +from gmxapi.simulation.mdrun import ResourceManager as _ResourceManager +# Note that *threads* argument causes errors for MPI-enabled GROMACS. +# Ref #3563 and #3573 +_ResourceManager.mdrun_kwargs = {'threads': 2} + withmpi_only = None try: -- 2.22.0