Skip to content

Commit ab63182

Browse files
committed
Update ray patch
1 parent 308eddb commit ab63182

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

graalpython/lib-graalpython/patches/Cython/Cython-0.29.32.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,19 @@ index b2c67dc..ad80ca4 100644
202202
}
203203
#endif
204204
else if (PyMethod_Check(method)) {
205+
diff --git a/Cython/Utility/Exceptions.c b/Cython/Utility/Exceptions.c
206+
index 2cd4b60..2c92132 100644
207+
--- a/Cython/Utility/Exceptions.c
208+
+++ b/Cython/Utility/Exceptions.c
209+
@@ -661,7 +661,7 @@ static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int
210+
211+
__Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
212+
213+
-#if CYTHON_COMPILING_IN_CPYTHON
214+
+#if 0
215+
cython_runtime_dict = _PyObject_GetDictPtr(${cython_runtime_cname});
216+
if (likely(cython_runtime_dict)) {
217+
__PYX_PY_DICT_LOOKUP_IF_MODIFIED(
205218
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c
206219
index f8bf885..94d0ca6 100644
207220
--- a/Cython/Utility/ModuleSetupCode.c

graalpython/lib-graalpython/patches/ray/ray-2.9.1.patch

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,36 @@ index bee0ae6..ee0e3ea 100644
123123
"actor_method_names": json.dumps(list(actor_method_names)),
124124
}
125125

126+
diff --git a/python/ray/_private/resource_spec.py b/python/ray/_private/resource_spec.py
127+
index 69780aade9..3be8cbbc4c 100644
128+
--- a/python/ray/_private/resource_spec.py
129+
+++ b/python/ray/_private/resource_spec.py
130+
@@ -160,9 +160,22 @@ class ResourceSpec(
131+
if is_head:
132+
resources[HEAD_NODE_RESOURCE_NAME] = 1.0
133+
134+
- num_cpus = self.num_cpus
135+
- if num_cpus is None:
136+
- num_cpus = ray._private.utils.get_num_cpus()
137+
+ try:
138+
+ system_num_cpus = __graalpython__.get_max_process_count()
139+
+ factor = min(system_num_cpus, 4)
140+
+ num_cpus = system_num_cpus // factor
141+
+ if self.num_cpus:
142+
+ num_cpus = min(self.num_cpus, num_cpus)
143+
+ if num_cpus != self.num_cpus:
144+
+ logger.warning(
145+
+ f"GraalPy: user requested {self.num_cpus} for number"
146+
+ "of CPUs, but GraalPy can only support up to {num_cpus} CPUs"
147+
+ )
148+
+ except:
149+
+ # We are not running on GraalPy
150+
+ num_cpus = self.num_cpus
151+
+ if num_cpus is None:
152+
+ num_cpus = ray._private.utils.get_num_cpus()
153+
154+
num_gpus = 0
155+
for (
126156
diff --git a/python/ray/_private/services.py b/python/ray/_private/services.py
127157
index 867b748..40b3fb2 100644
128158
--- a/python/ray/_private/services.py
@@ -272,10 +302,10 @@ index a34a39c..51a1a17 100644
272302
if BAZEL_ARGS:
273303
diff --git a/ray_build_backend.py b/ray_build_backend.py
274304
new file mode 100644
275-
index 0000000..9e7f3fd
305+
index 0000000000..10f532ae9e
276306
--- /dev/null
277307
+++ b/ray_build_backend.py
278-
@@ -0,0 +1,117 @@
308+
@@ -0,0 +1,125 @@
279309
+# We need a whole custom build backend just because the setup.py is in a subdir
280310
+import os
281311
+import re
@@ -385,6 +415,14 @@ index 0000000..9e7f3fd
385415
+ env = os.environ.copy()
386416
+ env['SKIP_THIRDPARTY_INSTALL'] = 'true'
387417
+ try:
418+
+ system_num_cpus = __graalpython__.get_max_process_count()
419+
+ env['BAZEL_LIMIT_CPUS'] = '%d' % system_num_cpus
420+
+ except:
421+
+ # do not limit bazel
422+
+ pass
423+
+ try:
424+
+ if os.path.isdir(Path('dist')):
425+
+ shutil.rmtree(Path('dist'))
388426
+ subprocess.run([sys.executable, 'setup.py', 'bdist_wheel'], env=env, check=True)
389427
+ wheels = list(Path('dist').glob('*.whl'))
390428
+ assert len(wheels) == 1, f"Expected 1 wheel, found {len(wheels)}"

0 commit comments

Comments
 (0)