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

Add support to joblib 1.3.0 #48

Merged
merged 7 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 1 addition & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ jobs:
- name: Install python packages
run: |
pip install joblib>=0.14.0 scikit-learn>=0.23.1 pytest pylint
thinkall marked this conversation as resolved.
Show resolved Hide resolved
if [ "${{ matrix.PYSPARK_VERSION }}" = "3.4.0" ]; then
pip install https://dist.apache.org/repos/dist/dev/spark/v3.4.0-rc1-bin/pyspark-3.4.0.tar.gz
else
pip install pyspark==${{ matrix.PYSPARK_VERSION }}
fi;
pip install pyspark==${{ matrix.PYSPARK_VERSION }}
- name: Run pylint
run: |
./run-pylint.sh
Expand Down
2 changes: 1 addition & 1 deletion joblibspark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""
Joblib spark backend is a extension for joblib, which make joblib running on spark parallelly.
"""
__version__ = '0.5.1'
__version__ = '0.5.2'


def register_spark():
Expand Down
16 changes: 13 additions & 3 deletions joblibspark/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@

from joblib.parallel \
import AutoBatchingMixin, ParallelBackendBase, register_parallel_backend, SequentialBackend
from joblib._parallel_backends import SafeFunction

try:
from joblib._parallel_backends import SafeFunction
except ImportError:
# joblib >= 1.3.0
SafeFunction = None

from py4j.clientserver import ClientServer

Expand Down Expand Up @@ -202,11 +207,16 @@ def mapper_fn(_):
except ImportError:
pass

if SafeFunction is None:
return self._get_pool().apply_async(
run_on_worker_and_fetch_result, callback=callback
thinkall marked this conversation as resolved.
Show resolved Hide resolved
)

return self._get_pool().apply_async(
SafeFunction(run_on_worker_and_fetch_result),
callback=callback
SafeFunction(run_on_worker_and_fetch_result), callback=callback
)


def get_nested_backend(self):
"""Backend instance to be used by nested Parallel calls.
For nested backend, always use `SequentialBackend`
Expand Down