From db09523f4477aae4a18f35f219f1a02cab4e8237 Mon Sep 17 00:00:00 2001 From: Anowar Jaman Shajib Date: Mon, 1 Jul 2019 01:56:09 -0700 Subject: [PATCH 1/3] Set dill serializtion for MPI --- cosmoHammer/util/MpiUtil.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cosmoHammer/util/MpiUtil.py b/cosmoHammer/util/MpiUtil.py index 972b233..b29ff27 100644 --- a/cosmoHammer/util/MpiUtil.py +++ b/cosmoHammer/util/MpiUtil.py @@ -2,11 +2,13 @@ import os from cosmoHammer import getLogger import time +import dill # If mpi4py is installed, import it. try: from mpi4py import MPI MPI = MPI + MPI.pickle.__init__(dill.dumps, dill.loads) except ImportError: MPI = None From a2d48c26ec9d06b79ed9b87c82e695b16ead35aa Mon Sep 17 00:00:00 2001 From: Anowar Jaman Shajib Date: Mon, 1 Jul 2019 02:31:14 -0700 Subject: [PATCH 2/3] Set dill serializtion for MPI --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d1ea50b..ecd234f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ emcee numpy mock -pytest \ No newline at end of file +pytest +dill \ No newline at end of file From db183bcaf4845264db20a2415b4e9147ed48b8c3 Mon Sep 17 00:00:00 2001 From: Anowar Jaman Shajib Date: Wed, 3 Jul 2019 16:01:44 -0700 Subject: [PATCH 3/3] Use dill only in Python 3 --- cosmoHammer/util/MpiUtil.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cosmoHammer/util/MpiUtil.py b/cosmoHammer/util/MpiUtil.py index b29ff27..9323446 100644 --- a/cosmoHammer/util/MpiUtil.py +++ b/cosmoHammer/util/MpiUtil.py @@ -3,12 +3,16 @@ from cosmoHammer import getLogger import time import dill +import sys # If mpi4py is installed, import it. try: from mpi4py import MPI MPI = MPI - MPI.pickle.__init__(dill.dumps, dill.loads) + + # for Python 3 + if sys.version_info > (3, 0): + MPI.pickle.__init__(dill.dumps, dill.loads) except ImportError: MPI = None