Skip to content

Commit 491cbcd

Browse files
committed
Deprecate loky.
1 parent ff3f45a commit 491cbcd

File tree

9 files changed

+14
-44
lines changed

9 files changed

+14
-44
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
rev: v3.11.0
2828
hooks:
2929
- id: reorder-python-imports
30-
args: [--py37-plus, --add-import, 'from __future__ import annotations']
30+
args: [--py38-plus, --add-import, 'from __future__ import annotations']
3131
- repo: https://github.com./asottile/setup-cfg-fmt
3232
rev: v2.4.0
3333
hooks:

CHANGES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask-parallel) and
77

88
## 0.4.0 - 2023-xx-xx
99

10-
- {pull}`62` deprecates Python 3.7.
10+
- {pull}`62` deprecates Python 3.7 and remove loky.
1111

1212
## 0.3.1 - 2023-05-27
1313

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ $ conda install -c conda-forge pytask-parallel
3030

3131
By default, the plugin uses `concurrent.futures.ProcessPoolExecutor`.
3232

33-
It is also possible to select the executor from loky or `ThreadPoolExecutor` from the
34-
[concurrent.futures](https://docs.python.org/3/library/concurrent.futures.html) module
35-
as backends to execute tasks asynchronously.
36-
3733
## Usage
3834

3935
To parallelize your tasks across many workers, pass an integer greater than 1 or
@@ -65,7 +61,7 @@ You can also set the options in a `pyproject.toml`.
6561

6662
[tool.pytask.ini_options]
6763
n_workers = 1
68-
parallel_backend = "processes" # or loky or threads
64+
parallel_backend = "processes" # or threads
6965
```
7066

7167
## Some implementation details

environment.yml

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ dependencies:
1818
# Package dependencies
1919
- pytask >=0.3
2020
- cloudpickle
21-
- loky
2221
- pybaum >=0.1.1
2322

2423
# Misc

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ignore_errors = true
2525

2626

2727
[tool.ruff]
28-
target-version = "py37"
28+
target-version = "py38"
2929
select = ["ALL"]
3030
fix = true
3131
extend-ignore = [

setup.cfg

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ packages = find:
2626
install_requires =
2727
click
2828
cloudpickle
29-
loky
3029
pybaum>=0.1.1
3130
pytask>=0.3
3231
python_requires = >=3.8

src/pytask_parallel/backends.py

+10-32
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def deserialize_and_run_with_cloudpickle(
2323
class CloudpickleProcessPoolExecutor(ProcessPoolExecutor):
2424
"""Patches the standard executor to serialize functions with cloudpickle."""
2525

26-
# The type signature is wrong for version above Py3.7. Fix when 3.7 is deprecated.
26+
# The type signature has issues. See https://github.com./python/typeshed/issues/7750
27+
# for more information.
2728
def submit( # type: ignore[override]
2829
self, fn: Callable[..., Any], *args: Any, **kwargs: Any # noqa: ARG002
2930
) -> Future[Any]:
@@ -35,39 +36,16 @@ def submit( # type: ignore[override]
3536
)
3637

3738

38-
try:
39-
from loky import get_reusable_executor
39+
class ParallelBackendChoices(enum.Enum):
40+
"""Choices for parallel backends."""
4041

41-
except ImportError:
42+
PROCESSES = "processes"
43+
THREADS = "threads"
4244

43-
class ParallelBackendChoices(enum.Enum):
44-
"""Choices for parallel backends."""
4545

46-
PROCESSES = "processes"
47-
THREADS = "threads"
48-
49-
PARALLEL_BACKENDS = {
50-
ParallelBackendChoices.PROCESSES: CloudpickleProcessPoolExecutor,
51-
ParallelBackendChoices.THREADS: ThreadPoolExecutor,
52-
}
53-
54-
else:
55-
56-
class ParallelBackendChoices(enum.Enum): # type: ignore[no-redef]
57-
"""Choices for parallel backends."""
58-
59-
PROCESSES = "processes"
60-
THREADS = "threads"
61-
LOKY = "loky"
62-
63-
PARALLEL_BACKENDS_DEFAULT = ParallelBackendChoices.PROCESSES
64-
65-
PARALLEL_BACKENDS = {
66-
ParallelBackendChoices.PROCESSES: CloudpickleProcessPoolExecutor,
67-
ParallelBackendChoices.THREADS: ThreadPoolExecutor,
68-
ParallelBackendChoices.LOKY: ( # type: ignore[attr-defined]
69-
get_reusable_executor
70-
),
71-
}
46+
PARALLEL_BACKENDS = {
47+
ParallelBackendChoices.PROCESSES: CloudpickleProcessPoolExecutor,
48+
ParallelBackendChoices.THREADS: ThreadPoolExecutor,
49+
}
7250

7351
PARALLEL_BACKENDS_DEFAULT = ParallelBackendChoices.PROCESSES

tests/test_execute.py

-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ def myfunc():
132132
backend_name_space = {
133133
ParallelBackendChoices.PROCESSES: ProcessesNameSpace,
134134
ParallelBackendChoices.THREADS: DefaultBackendNameSpace,
135-
ParallelBackendChoices.LOKY: DefaultBackendNameSpace,
136135
}[parallel_backend]
137136

138137
future = backend_name_space.pytask_execute_task(session, task)

tox.ini

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ usedevelop = true
77
[testenv:pytest]
88
conda_deps =
99
cloudpickle
10-
loky
1110
pytask >=0.3.0
1211
pytest
1312
pytest-cov

0 commit comments

Comments
 (0)