diff --git a/.github/workflows/test_qlib_from_pip.yml b/.github/workflows/test_qlib_from_pip.yml index 165329971..1bcb00221 100644 --- a/.github/workflows/test_qlib_from_pip.yml +++ b/.github/workflows/test_qlib_from_pip.yml @@ -38,9 +38,13 @@ jobs: run: | python -m pip install pywinpty --only-binary=:all: + # # joblib was released on 2025-05-04 with version 1.5.0, in which _backend_args was removed and replaced by _backend_kwargs. + # This change caused the application to fail, so the version of joblib is restricted here. + # This restriction will be removed in the next release. The current qlib version is: 0.9.6 - name: Qlib installation test run: | python -m pip install pyqlib + python -m pip install "joblib<=1.4.2" - name: Install Lightgbm for MacOS if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-15' }} diff --git a/qlib/utils/paral.py b/qlib/utils/paral.py index 3b6671ddb..8eb7311c9 100644 --- a/qlib/utils/paral.py +++ b/qlib/utils/paral.py @@ -6,6 +6,7 @@ from functools import partial from threading import Thread from typing import Callable, Text, Union +import joblib from joblib import Parallel, delayed from joblib._parallel_backends import MultiprocessingBackend import pandas as pd @@ -21,7 +22,12 @@ class ParallelExt(Parallel): maxtasksperchild = kwargs.pop("maxtasksperchild", None) super(ParallelExt, self).__init__(*args, **kwargs) if isinstance(self._backend, MultiprocessingBackend): - self._backend_args["maxtasksperchild"] = maxtasksperchild + # 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": + self._backend_args["maxtasksperchild"] = maxtasksperchild # pylint: disable=E1101 + else: + self._backend_kwargs["maxtasksperchild"] = maxtasksperchild # pylint: disable=E1101 def datetime_groupby_apply(