-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a patch to disable mpi4py with an env. var.
This is similar to what was done in the previous merge for the cdms2 package, but this time for the regrid2 package.
- Loading branch information
Showing
2 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
diff -ruN cdms-3.1.5/regrid2/Lib/esmf.py cdms-3.1.5-patch/regrid2/Lib/esmf.py | ||
--- cdms-3.1.5/regrid2/Lib/esmf.py 2020-07-31 03:01:33.000000000 +0200 | ||
+++ cdms-3.1.5-patch/regrid2/Lib/esmf.py 2021-06-09 15:18:29.043255491 +0200 | ||
@@ -18,6 +18,9 @@ | ||
import ESMF | ||
from functools import reduce | ||
|
||
+from .util import getenv_bool | ||
+ | ||
+ | ||
# constants | ||
R8 = ESMF.TypeKind.R8 | ||
R4 = ESMF.TypeKind.R4 | ||
@@ -463,7 +466,13 @@ | ||
# communicator | ||
self.comm = None | ||
|
||
+ mpi_disabled = getenv_bool("CDMS_NO_MPI", "False") | ||
+ | ||
try: | ||
+ # skip trying to load mpi4py module | ||
+ if mpi_disabled: | ||
+ raise Exception() | ||
+ | ||
from mpi4py import MPI | ||
self.comm = MPI.COMM_WORLD | ||
except BaseException: | ||
diff -ruN cdms-3.1.5/regrid2/Lib/mvESMFRegrid.py cdms-3.1.5-patch/regrid2/Lib/mvESMFRegrid.py | ||
--- cdms-3.1.5/regrid2/Lib/mvESMFRegrid.py 2020-07-31 03:01:33.000000000 +0200 | ||
+++ cdms-3.1.5-patch/regrid2/Lib/mvESMFRegrid.py 2021-06-09 10:40:05.039237116 +0200 | ||
@@ -22,9 +22,16 @@ | ||
except Exception: | ||
os.environ['MPICH_INTERFACE_HOSTNAME'] = 'localhost' | ||
|
||
+from .util import getenv_bool | ||
+ | ||
ESMF.Manager(debug=False) | ||
HAVE_MPI = False | ||
+mpi_disabled = getenv_bool("CDMS_NO_MPI", "False") | ||
+ | ||
try: | ||
+ # skip trying to load mpi4py module | ||
+ if mpi_disabled: | ||
+ raise Exception() | ||
from mpi4py import MPI | ||
HAVE_MPI = True | ||
except BaseException: | ||
diff -ruN cdms-3.1.5/regrid2/Lib/util.py cdms-3.1.5-patch/regrid2/Lib/util.py | ||
--- cdms-3.1.5/regrid2/Lib/util.py 1970-01-01 01:00:00.000000000 +0100 | ||
+++ cdms-3.1.5-patch/regrid2/Lib/util.py 2021-06-09 10:39:10.295311114 +0200 | ||
@@ -0,0 +1,16 @@ | ||
+import os | ||
+ | ||
+ | ||
+def getenv_bool(name, default=None): | ||
+ valid_bool_str = ["true", "false"] | ||
+ value = os.environ.get(name, default) | ||
+ | ||
+ if value is None: | ||
+ raise ValueError("{!r} was not set".format(name)) | ||
+ | ||
+ if value.lower() not in valid_bool_str: | ||
+ raise ValueError( | ||
+ "{!r} is not a valid value for {!r}, allowed values: {!r}".format( | ||
+ value, name, valid_bool_str)) | ||
+ | ||
+ return value.lower() == "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters