Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement loky and process-pool seperately #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions adaptive_scheduler/run_script.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ from adaptive_scheduler.utils import connect_to_ipyparallel
{% elif executor_type == "dask-mpi" %}
from distributed import Client
{% elif executor_type == "process-pool" %}
from concurrent.futures import ProcessPoolExecutor
{% elif executor_type == "loky" %}
from loky import get_reusable_executor
{% endif %}
if __name__ == "__main__": # ← use this, see warning @ https://bit.ly/2HAk0GG
Expand Down Expand Up @@ -54,6 +56,8 @@ if __name__ == "__main__": # ← use this, see warning @ https://bit.ly/2HAk0GG
{% elif executor_type == "dask-mpi" %}
executor = Client()
{% elif executor_type == "process-pool" %}
executor = ProcessPoolExecutor(max_workers=args.n)
{% elif executor_type == "loky" %}
executor = get_reusable_executor(max_workers=args.n)
{% endif %}
# this is serialized by cloudpickle.dumps
Expand Down
7 changes: 4 additions & 3 deletions adaptive_scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class BaseScheduler(metaclass=_RequireAttrsABCMeta):
used (so probably from ``conda``).
executor_type : str, default: "mpi4py"
The executor that is used, by default `mpi4py.futures.MPIPoolExecutor` is used.
One can use ``"ipyparallel"``, ``"dask-mpi"``, ``"mpi4py"``, or ``"process-pool"``.
One can use ``"ipyparallel"``, ``"dask-mpi"``, ``"mpi4py"``, ``"loky"``,
or ``"process-pool"``.
num_threads : int, default 1
``MKL_NUM_THREADS``, ``OPENBLAS_NUM_THREADS``, ``OMP_NUM_THREADS``, and
``NUMEXPR_NUM_THREADS`` will be set to this number.
Expand Down Expand Up @@ -231,11 +232,11 @@ def _executor_specific(self, name: str) -> str:
" the rest of the cores for the engines, so use more than 1 core."
)
return self._ipyparallel(name)
elif self.executor_type == "process-pool":
elif self.executor_type in ("process-pool", "loky"):
return self._process_pool(name)
else:
raise NotImplementedError(
"Use 'ipyparallel', 'dask-mpi', 'mpi4py' or 'process-pool'."
"Use 'ipyparallel', 'dask-mpi', 'mpi4py', 'loky' or 'process-pool'."
)

def log_fname(self, name: str) -> str:
Expand Down
10 changes: 8 additions & 2 deletions adaptive_scheduler/server_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,15 @@ def _make_default_run_script(
runner_kwargs = dict(default_runner_kwargs, goal=goal, **(runner_kwargs or {}))
serialized_runner_kwargs = cloudpickle.dumps(runner_kwargs)

if executor_type not in ("mpi4py", "ipyparallel", "dask-mpi", "process-pool"):
if executor_type not in (
"mpi4py",
"ipyparallel",
"dask-mpi",
"loky",
"process-pool",
):
raise NotImplementedError(
"Use 'ipyparallel', 'dask-mpi', 'mpi4py' or 'process-pool'."
"Use 'ipyparallel', 'dask-mpi', 'mpi4py', 'loky', or 'process-pool'."
)

if executor_type == "dask-mpi":
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_version_and_cmdclass(package_name):
include_package_data=True,
maintainer="Bas Nijholt",
maintainer_email="[email protected]",
description="Run many `adaptive.Learner`s on many cores (>10k) using `mpi4py.futures`, `ipyparallel`, `dask-mpi`, or `process-pool`.",
description="Run many `adaptive.Learner`s on many cores (>10k) using `mpi4py.futures`, `ipyparallel`, `dask-mpi`, `loky`, or `process-pool`.",
long_description=readme,
long_description_content_type="text/x-rst",
license="BSD-3",
Expand Down