Skip to content

Commit

Permalink
Mpiexec Patch (#192)
Browse files Browse the repository at this point in the history
Updates the MpiexecSettings (and all other OpenMPI settings classes)
to use `subprocess.run` as opposed to `subprocess.check_output` 
when checking version statements so that it can handle a non-zero 
status return code.

[ committed by @MattToast  ]
[ reviewed by @al-rigazzi @Spartee ]
  • Loading branch information
MattToast authored May 17, 2022
1 parent 7b0f188 commit a984ead
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions smartsim/settings/mpirunSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import subprocess as sp
import subprocess
import re

from ..error import SSUnsupportedError
Expand Down Expand Up @@ -268,8 +268,12 @@ def __init__(self, exe, exe_args=None, run_args=None, env_vars=None, **kwargs):
"""
super().__init__(exe, exe_args, "mpirun", run_args, env_vars, **kwargs)

version_stmt = sp.check_output([self.run_command, "-V"]).decode()
if not re.match(r"mpirun\s\(Open MPI\)\s4.\d+.\d+", version_stmt):
completed_process = subprocess.run(
[self.run_command, "-V"], capture_output=True
) # type: subprocess.CompletedProcess
version_statement = completed_process.stdout.decode()

if not re.match(r"mpirun\s\(Open MPI\)\s4.\d+.\d+", version_statement):
logger.warning("Non-OpenMPI implementation of `mpirun` detected")


Expand All @@ -296,8 +300,12 @@ def __init__(self, exe, exe_args=None, run_args=None, env_vars=None, **kwargs):
"""
super().__init__(exe, exe_args, "mpiexec", run_args, env_vars, **kwargs)

version_stmt = sp.check_output([self.run_command, "-V"]).decode()
if not re.match(r"mpiexec\s\(OpenRTE\)\s4.\d+.\d+", version_stmt):
completed_process = subprocess.run(
[self.run_command, "-V"], capture_output=True
) # type: subprocess.CompletedProcess
version_statement = completed_process.stdout.decode()

if not re.match(r"mpiexec\s\(OpenRTE\)\s4.\d+.\d+", version_statement):
logger.warning("Non-OpenMPI implementation of `mpiexec` detected")


Expand All @@ -324,6 +332,10 @@ def __init__(self, exe, exe_args=None, run_args=None, env_vars=None, **kwargs):
"""
super().__init__(exe, exe_args, "orterun", run_args, env_vars, **kwargs)

version_stmt = sp.check_output([self.run_command, "-V"]).decode()
if not re.match(r"orterun\s\(OpenRTE\)\s4.\d+.\d+", version_stmt):
completed_process = subprocess.run(
[self.run_command, "-V"], capture_output=True
) # type: subprocess.CompletedProcess
version_statement = completed_process.stdout.decode()

if not re.match(r"orterun\s\(OpenRTE\)\s4.\d+.\d+", version_statement):
logger.warning("Non-OpenMPI implementation of `orterun` detected")

0 comments on commit a984ead

Please sign in to comment.