From 3242062aa0541eab341306329f9248c62d2c79be Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Thu, 17 Jun 2021 11:46:34 +0200 Subject: [PATCH] Optionally disable mpi4py imports with an env flag This allows for the same environment to run on a compute node (where mpi4py should work) and a login node (where mpi4py often doesn't work) on HPC systems. --- Lib/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Lib/__init__.py b/Lib/__init__.py index a931ea4..034849f 100644 --- a/Lib/__init__.py +++ b/Lib/__init__.py @@ -2,11 +2,18 @@ Distributed array """ __all__ = ["mvMultiArrayIter"] -from .mvMultiArrayIter import MultiArrayIter +from .mvMultiArrayIter import MultiArrayIter + +import os + +mpi_disabled = os.environ.get("CDMS_NO_MPI", "False").lower() == 'true' # is mpi4py available? hasMpi4py = True try: + # skip trying to load mpi4py module + if mpi_disabled: + raise Exception() from mpi4py import MPI except: hasMpi4py = False