Skip to content

Commit 6822ad7

Browse files
committed
[GR-53644] Patching file from joblib fails
1 parent 2cb20be commit 6822ad7

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
diff --git a/joblib/_parallel_backends.py b/joblib/_parallel_backends.py
2+
index 8201c96..4679b59 100644
3+
--- a/joblib/_parallel_backends.py
4+
+++ b/joblib/_parallel_backends.py
5+
@@ -499,6 +499,10 @@ class MultiprocessingBackend(PoolManagerMixin, AutoBatchingMixin,
6+
stacklevel=3)
7+
return 1
8+
9+
+ # GraalPy change:
10+
+ if n_jobs < 0:
11+
+ return max(__graalpython__.get_max_process_count() + 1 + n_jobs, 1)
12+
+
13+
return super(MultiprocessingBackend, self).effective_n_jobs(n_jobs)
14+
15+
def configure(self, n_jobs=1, parallel=None, prefer=None, require=None,
16+
@@ -580,7 +584,9 @@ class LokyBackend(AutoBatchingMixin, ParallelBackendBase):
17+
stacklevel=3)
18+
return 1
19+
elif n_jobs < 0:
20+
- n_jobs = max(cpu_count() + 1 + n_jobs, 1)
21+
+ # GraalPy change:
22+
+ # n_jobs = max(cpu_count() + 1 + n_jobs, 1)
23+
+ n_jobs = max(__graalpython__.get_max_process_count() + 1 + n_jobs, 1)
24+
return n_jobs
25+
26+
def apply_async(self, func, callback=None):
27+
diff --git a/joblib/externals/cloudpickle/cloudpickle.py b/joblib/externals/cloudpickle/cloudpickle.py
28+
index eb43a96..55598f9 100644
29+
--- a/joblib/externals/cloudpickle/cloudpickle.py
30+
+++ b/joblib/externals/cloudpickle/cloudpickle.py
31+
@@ -401,10 +401,12 @@ def _builtin_type(name):
32+
33+
def _walk_global_ops(code):
34+
"""Yield referenced name for global-referencing instructions in code."""
35+
- for instr in dis.get_instructions(code):
36+
- op = instr.opcode
37+
- if op in GLOBAL_OPS:
38+
- yield instr.argval
39+
+ # GraalPy change: we don't support dis
40+
+ yield from code.co_names
41+
+ # for instr in dis.get_instructions(code):
42+
+ # op = instr.opcode
43+
+ # if op in GLOBAL_OPS:
44+
+ # yield instr.argval
45+
46+
47+
def _extract_class_dict(cls):
48+
diff --git a/joblib/externals/loky/backend/fork_exec.py b/joblib/externals/loky/backend/fork_exec.py
49+
index 2353c42..f083a63 100644
50+
--- a/joblib/externals/loky/backend/fork_exec.py
51+
+++ b/joblib/externals/loky/backend/fork_exec.py
52+
@@ -35,9 +35,6 @@ def fork_exec(cmd, keep_fds, env=None):
53+
env = env or {}
54+
child_env = {**os.environ, **env}
55+
56+
- pid = os.fork()
57+
- if pid == 0: # pragma: no cover
58+
- close_fds(keep_fds)
59+
- os.execve(sys.executable, cmd, child_env)
60+
- else:
61+
- return pid
62+
+ import subprocess
63+
+ p = subprocess.Popen(cmd, executable=sys.executable, pass_fds=keep_fds, env=child_env)
64+
+ return p.pid
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
[[rules]]
2-
patch = 'joblib.patch'
2+
version = '==1.4.0'
3+
patch = 'joblib-1.4.0.patch'
4+
5+
[[rules]]
6+
version = '<=1.3.2'
7+
patch = 'joblib-1.3.2.patch'

0 commit comments

Comments
 (0)