Skip to content

Commit 76d0e4a

Browse files
committed
Remove support for dill as a serialization backend.
1 parent 8f582ff commit 76d0e4a

14 files changed

+22
-126
lines changed

doc/install.rst

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ pygmo has the following **mandatory** runtime dependencies:
1717
Additionally, pygmo has the following **optional** runtime
1818
dependencies:
1919

20-
* `dill <https://dill.readthedocs.io>`__, which can be used as an
21-
alternative serialization backend,
2220
* `Matplotlib <https://matplotlib.org/>`__, which is used by a few
2321
plotting utilities,
2422
* `NetworkX <https://networkx.github.io/>`__, which is used for

pygmo/__init__.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,7 @@ def set_serialization_backend(name):
746746
The valid backends are:
747747
748748
* ``'pickle'`` (i.e., the standard Python :mod:`pickle` module),
749-
* ``'cloudpickle'``,
750-
* ``'dill'`` (from the `dill <https://pypi.org/project/dill/>`__ library).
749+
* ``'cloudpickle'``.
751750
752751
.. warning::
753752
@@ -760,8 +759,7 @@ def set_serialization_backend(name):
760759
761760
Raises:
762761
TypeError: if *name* is not a :class:`str`
763-
ValueError: if *name* is not one of ``['pickle', 'cloudpickle', 'dill']``
764-
ImportError: if *name* is ``'dill'`` but the dill module is not installed
762+
ValueError: if *name* is not one of ``['pickle', 'cloudpickle']``
765763
766764
"""
767765
if not isinstance(name, str):
@@ -777,18 +775,9 @@ def set_serialization_backend(name):
777775
_serialization_backend = pickle
778776
elif name == "cloudpickle":
779777
_serialization_backend = _cloudpickle
780-
elif name == "dill":
781-
try:
782-
import dill
783-
784-
_serialization_backend = dill
785-
except ImportError:
786-
raise ImportError(
787-
"The 'dill' serialization backend was specified, but the dill module is not installed."
788-
)
789778
else:
790779
raise ValueError(
791-
"The serialization backend '{}' is not valid. The valid backends are: ['pickle', 'cloudpickle', 'dill']".format(
780+
"The serialization backend '{}' is not valid. The valid backends are: ['pickle', 'cloudpickle']".format(
792781
name
793782
)
794783
)

pygmo/_island_test.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -501,17 +501,8 @@ def run_basic_tests(self):
501501
from . import mp_island
502502
from copy import copy, deepcopy
503503

504-
has_dill = False
505-
try:
506-
import dill
504+
from pickle import dumps, loads
507505

508-
has_dill = True
509-
except ImportError:
510-
pass
511-
if has_dill:
512-
from dill import dumps, loads
513-
else:
514-
from pickle import dumps, loads
515506
# Try shutting down a few times, to confirm that the second
516507
# and third shutdowns don't do anything.
517508
mp_island.shutdown_pool()

pygmo/_py_islands.py

+7-53
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,8 @@
1212
def _evolve_func_mp_pool(ser_algo_pop):
1313
# The evolve function that is actually run from the separate processes
1414
# in mp_island (when using the pool).
15-
has_dill = False
16-
try:
17-
import dill
18-
19-
has_dill = True
20-
except ImportError:
21-
pass
22-
if has_dill:
23-
from dill import dumps, loads
24-
else:
25-
from pickle import dumps, loads
15+
from pickle import dumps, loads
16+
2617
algo, pop = loads(ser_algo_pop)
2718
new_pop = algo.evolve(pop)
2819
return dumps((algo, new_pop))
@@ -44,17 +35,8 @@ def _evolve_func_mp_pipe(conn, ser_algo_pop):
4435
# of a child process happens in a separate thread and Python disallows messing
4536
# with signal handlers from a thread different from the main one :(
4637
with _temp_disable_sigint():
47-
has_dill = False
48-
try:
49-
import dill
38+
from pickle import dumps, loads
5039

51-
has_dill = True
52-
except ImportError:
53-
pass
54-
if has_dill:
55-
from dill import dumps, loads
56-
else:
57-
from pickle import dumps, loads
5840
try:
5941
algo, pop = loads(ser_algo_pop)
6042
new_pop = algo.evolve(pop)
@@ -227,17 +209,8 @@ def run_evolve(self, algo, pop):
227209
# that if there are serialization errors, we catch them early here rather
228210
# than failing in the bootstrap phase of the remote process, which
229211
# can lead to hangups.
230-
has_dill = False
231-
try:
232-
import dill
212+
from pickle import dumps, loads
233213

234-
has_dill = True
235-
except ImportError:
236-
pass
237-
if has_dill:
238-
from dill import dumps, loads
239-
else:
240-
from pickle import dumps, loads
241214
ser_algo_pop = dumps((algo, pop))
242215

243216
if self._use_pool:
@@ -470,17 +443,8 @@ def shutdown_pool():
470443
def _evolve_func_ipy(ser_algo_pop):
471444
# The evolve function that is actually run from the separate processes
472445
# in ipyparallel_island.
473-
has_dill = False
474-
try:
475-
import dill
476-
477-
has_dill = True
478-
except ImportError:
479-
pass
480-
if has_dill:
481-
from dill import dumps, loads
482-
else:
483-
from pickle import dumps, loads
446+
from pickle import dumps, loads
447+
484448
algo, pop = loads(ser_algo_pop)
485449
new_pop = algo.evolve(pop)
486450
return dumps((algo, new_pop))
@@ -613,17 +577,7 @@ def run_evolve(self, algo, pop):
613577
# serialization errors early.
614578
from ._ipyparallel_utils import _make_ipyparallel_view
615579

616-
has_dill = False
617-
try:
618-
import dill
619-
620-
has_dill = True
621-
except ImportError:
622-
pass
623-
if has_dill:
624-
from dill import dumps, loads
625-
else:
626-
from pickle import dumps, loads
580+
from pickle import dumps, loads
627581

628582
ser_algo_pop = dumps((algo, pop))
629583
with ipyparallel_island._view_lock:

pygmo/test.py

+2-38
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ def run_s11n_test(self):
6969
from . import set_serialization_backend as ssb, get_serialization_backend as gsb
7070
from . import problem, island, de
7171

72-
has_dill = False
73-
try:
74-
import dill
75-
76-
has_dill = True
77-
except ImportError:
78-
pass
79-
8072
# Default s11n backend.
8173
self.assertTrue(gsb() == clpickle)
8274

@@ -93,19 +85,10 @@ def run_s11n_test(self):
9385
ssb("hello")
9486
err = cm.exception
9587
self.assertEqual(
96-
"The serialization backend 'hello' is not valid. The valid backends are: ['pickle', 'cloudpickle', 'dill']",
88+
"The serialization backend 'hello' is not valid. The valid backends are: ['pickle', 'cloudpickle']",
9789
str(err),
9890
)
9991

100-
if not has_dill:
101-
with self.assertRaises(ImportError) as cm:
102-
ssb("dill")
103-
err = cm.exception
104-
self.assertEqual(
105-
"The 'dill' serialization backend was specified, but the dill module is not installed.",
106-
str(err),
107-
)
108-
10992
ssb("pickle")
11093
self.assertTrue(gsb() == pickle)
11194

@@ -115,16 +98,6 @@ def run_s11n_test(self):
11598
isl = island(prob=p, algo=de(gen=500), size=20)
11699
self.assertEqual(str(pickle.loads(pickle.dumps(isl))), str(isl))
117100

118-
# Try with dill as well, if available.
119-
if has_dill:
120-
ssb("dill")
121-
self.assertTrue(gsb() == dill)
122-
123-
p = problem(_prob())
124-
self.assertEqual(str(dill.loads(dill.dumps(p))), str(p))
125-
isl = island(prob=p, algo=de(gen=500), size=20)
126-
self.assertEqual(str(dill.loads(dill.dumps(isl))), str(isl))
127-
128101
# Reset to cloudpickle before exiting.
129102
ssb("cloudpickle")
130103
self.assertTrue(gsb() == clpickle)
@@ -1495,17 +1468,8 @@ def run_pickle_tests(self):
14951468
migrant_handling,
14961469
)
14971470

1498-
has_dill = False
1499-
try:
1500-
import dill
1471+
from pickle import dumps, loads
15011472

1502-
has_dill = True
1503-
except ImportError:
1504-
pass
1505-
if has_dill:
1506-
from dill import dumps, loads
1507-
else:
1508-
from pickle import dumps, loads
15091473
a = archipelago(5, algo=de(), prob=rosenbrock(), pop_size=10)
15101474
self.assertEqual(repr(a), repr(loads(dumps(a))))
15111475
a = archipelago(5, algo=de(), prob=_prob(), pop_size=10, udi=mp_island())

tools/circleci_bionic_conda_pagmo_head_310.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export PATH="$HOME/miniconda/bin:$PATH"
1616
bash miniconda.sh -b -p $HOME/miniconda
1717
conda config --add channels conda-forge
1818
conda config --set channel_priority strict
19-
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt ipopt boost-cpp tbb tbb-devel python=3.10 numpy cloudpickle networkx dill=0.3.5.1 numba pybind11 sphinx=4.5.0 myst-nb sphinx-book-theme scipy
19+
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt ipopt boost-cpp tbb tbb-devel python=3.10 numpy cloudpickle networkx numba pybind11 sphinx=4.5.0 myst-nb sphinx-book-theme scipy
2020
source activate $deps_dir
2121

2222
# Install pagmo.

tools/circleci_bionic_conda_pagmo_head_38.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export PATH="$HOME/miniconda/bin:$PATH"
1616
bash miniconda.sh -b -p $HOME/miniconda
1717
conda config --add channels conda-forge
1818
conda config --set channel_priority strict
19-
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt ipopt boost-cpp tbb tbb-devel python=3.8 numpy cloudpickle networkx dill=0.3.5.1 numba pybind11 scipy
19+
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt ipopt boost-cpp tbb tbb-devel python=3.8 numpy cloudpickle networkx numba pybind11 scipy
2020
source activate $deps_dir
2121

2222
# Install pagmo.

tools/circleci_bionic_conda_pagmo_head_39.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export PATH="$HOME/miniconda/bin:$PATH"
1616
bash miniconda.sh -b -p $HOME/miniconda
1717
conda config --add channels conda-forge
1818
conda config --set channel_priority strict
19-
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt ipopt boost-cpp tbb tbb-devel python=3.9 numpy cloudpickle networkx dill=0.3.5.1 numba pybind11 scipy
19+
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt ipopt boost-cpp tbb tbb-devel python=3.9 numpy cloudpickle networkx numba pybind11 scipy
2020
source activate $deps_dir
2121

2222
# Install pagmo.

tools/circleci_ubuntu_arm64.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge
1414
export deps_dir=$HOME/local
1515
export PATH="$HOME/miniconda/bin:$PATH"
1616
bash miniconda.sh -b -p $HOME/miniconda
17-
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt boost-cpp tbb tbb-devel python=3.8 numpy cloudpickle networkx dill=0.3.5.1 numba pybind11 scipy
17+
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt boost-cpp tbb tbb-devel python=3.8 numpy cloudpickle networkx numba pybind11 scipy
1818
source activate $deps_dir
1919

2020
# Install pagmo.

tools/gha_deploydocs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ bash miniconda.sh -b -p $HOME/miniconda
1717
conda config --add channels conda-forge
1818
conda config --set channel_priority strict
1919
conda install mamba
20-
mamba create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt ipopt boost-cpp tbb tbb-devel python=3.10 numpy cloudpickle networkx dill=0.3.5.1 numba pybind11 sphinx=4.5.0 myst-nb sphinx-book-theme scipy
20+
mamba create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt ipopt boost-cpp tbb tbb-devel python=3.10 numpy cloudpickle networkx numba pybind11 sphinx=4.5.0 myst-nb sphinx-book-theme scipy
2121
source activate $deps_dir
2222

2323
# Install pagmo.

tools/gha_macos-10.15-py310.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export PATH="$HOME/miniconda/bin:$PATH"
1313
bash miniconda.sh -b -p $HOME/miniconda
1414
conda config --add channels conda-forge
1515
conda config --set channel_priority strict
16-
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt ipopt boost-cpp tbb tbb-devel python=3.10 numpy cloudpickle networkx dill=0.3.5.1 numba pybind11 sphinx myst-nb sphinx-book-theme scipy
16+
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt ipopt boost-cpp tbb tbb-devel python=3.10 numpy cloudpickle networkx numba pybind11 sphinx myst-nb sphinx-book-theme scipy
1717
source activate $deps_dir
1818

1919
# Install pagmo.

tools/gha_manylinux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fi
4949
# Python mandatory deps.
5050
/opt/python/${PYTHON_DIR}/bin/pip install cloudpickle numpy
5151
# Python optional deps.
52-
/opt/python/${PYTHON_DIR}/bin/pip install dill==0.3.5.1 networkx ipyparallel scipy
52+
/opt/python/${PYTHON_DIR}/bin/pip install networkx ipyparallel scipy
5353

5454
# In the pagmo2/manylinux228_x86_64_with_deps:latest image in dockerhub
5555
# the working directory is /root/install, we will install pagmo there

tools/gha_windows.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Powershell script
33
# Install conda environment
44
conda config --set always_yes yes
5-
conda create --name pygmo cmake eigen nlopt ipopt boost-cpp tbb tbb-devel numpy cloudpickle networkx dill=0.3.5.1 numba pybind11 scipy
5+
conda create --name pygmo cmake eigen nlopt ipopt boost-cpp tbb tbb-devel numpy cloudpickle networkx numba pybind11 scipy
66
conda activate pygmo
77

88
# Install pagmo.

tools/travis_ubuntu_ppc64.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge
1414
export deps_dir=$HOME/local
1515
export PATH="$HOME/miniconda/bin:$PATH"
1616
bash miniconda.sh -b -p $HOME/miniconda
17-
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt boost-cpp tbb tbb-devel python=3.8 numpy cloudpickle networkx dill=0.3.5.1 numba pybind11 scipy
17+
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake eigen nlopt boost-cpp tbb tbb-devel python=3.8 numpy cloudpickle networkx numba pybind11 scipy
1818
source activate $deps_dir
1919

2020
# Install pagmo.

0 commit comments

Comments
 (0)