Skip to content
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
3 changes: 2 additions & 1 deletion qlib/utils/paral.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import joblib
from joblib import Parallel, delayed
from joblib._parallel_backends import MultiprocessingBackend
from packaging import version
import pandas as pd

from queue import Empty, Queue
Expand All @@ -24,7 +25,7 @@ def __init__(self, *args, **kwargs):
if isinstance(self._backend, MultiprocessingBackend):
# 2025-05-04 joblib released version 1.5.0, in which _backend_args was removed and replaced by _backend_kwargs.
# Ref: https://github.com/joblib/joblib/pull/1525/files#diff-e4dff8042ce45b443faf49605b75a58df35b8c195978d4a57f4afa695b406bdc
if joblib.__version__ < "1.5.0":
if version.parse(joblib.__version__) < version.parse("1.5.0"):
self._backend_args["maxtasksperchild"] = maxtasksperchild # pylint: disable=E1101
else:
self._backend_kwargs["maxtasksperchild"] = maxtasksperchild # pylint: disable=E1101
Expand Down
10 changes: 10 additions & 0 deletions tests/misc/test_paral.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import qlib.utils.paral as paral_mod
from qlib.utils.paral import ParallelExt


def test_parallel_ext_uses_semantic_joblib_version(monkeypatch):
monkeypatch.setattr(paral_mod.joblib, "__version__", "1.10.0")

parallel = ParallelExt(n_jobs=2, backend="multiprocessing", maxtasksperchild=3)

assert parallel._backend_kwargs["maxtasksperchild"] == 3