Skip to content

Commit e74ae19

Browse files
committed
[GR-50282] Add ray 2.9.1 patch
PullRequest: graalpython/3196
2 parents 8f2ee33 + c3136fe commit e74ae19

File tree

4 files changed

+170
-5
lines changed

4 files changed

+170
-5
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ContextvarsModuleBuiltins.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -45,6 +45,7 @@
4545

4646
import java.util.List;
4747

48+
import com.oracle.graal.python.annotations.ArgumentClinic;
4849
import com.oracle.graal.python.builtins.Builtin;
4950
import com.oracle.graal.python.builtins.CoreFunctions;
5051
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
@@ -54,8 +55,9 @@
5455
import com.oracle.graal.python.nodes.PRaiseNode;
5556
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
5657
import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
57-
import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode;
58+
import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode;
5859
import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
60+
import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
5961
import com.oracle.graal.python.runtime.PythonContext;
6062
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
6163
import com.oracle.truffle.api.dsl.Bind;
@@ -87,8 +89,14 @@ protected Object copyCtx(
8789
}
8890

8991
@Builtin(name = "ContextVar", minNumOfPositionalArgs = 2, parameterNames = {"cls", "name", "default"}, constructsClass = PythonBuiltinClassType.ContextVar)
92+
@ArgumentClinic(name = "name", conversion = ArgumentClinic.ClinicConversion.TString)
9093
@GenerateNodeFactory
91-
public abstract static class ContextVarNode extends PythonTernaryBuiltinNode {
94+
public abstract static class ContextVarNode extends PythonTernaryClinicBuiltinNode {
95+
96+
@Override
97+
protected ArgumentClinicProvider getArgumentClinic() {
98+
return ContextvarsModuleBuiltinsClinicProviders.ContextVarNodeClinicProviderGen.INSTANCE;
99+
}
92100

93101
@Specialization
94102
protected static Object constructDef(@SuppressWarnings("unused") Object cls, TruffleString name, Object def,

graalpython/lib-graalpython/patches/ray/metadata.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ patch = 'ray-2.3.0.patch'
55
[[add-sources]]
66
version = '2.3.0'
77
url = 'https://github.com/ray-project/ray/releases/download/ray-2.3.0/ray-2.3.0.tar.gz'
8+
9+
[[rules]]
10+
version = '== 2.9.1'
11+
patch = 'ray-2.9.1.patch'
12+
13+
[[add-sources]]
14+
version = '2.9.1'
15+
url = 'https://github.com/ray-project/ray/archive/refs/tags/ray-2.9.1.tar.gz'
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
diff --git a/bazel/ray.bzl b/bazel/ray.bzl
2+
index 4cd1aa2..95250a4 100644
3+
--- a/bazel/ray.bzl
4+
+++ b/bazel/ray.bzl
5+
@@ -30,6 +30,9 @@ PYX_COPTS = select({
6+
"//conditions:default": [
7+
# Ignore this warning since CPython and Cython have issue removing deprecated tp_print on MacOS
8+
"-Wno-deprecated-declarations",
9+
+ "-Wno-unused-variable",
10+
+ "-Wno-unused-function",
11+
+ "-Wno-sign-compare",
12+
],
13+
}) + select({
14+
"@bazel_tools//src/conditions:windows": [
15+
diff --git a/bazel/ray_deps_setup.bzl b/bazel/ray_deps_setup.bzl
16+
index f91eb30..b0d11ea 100644
17+
--- a/bazel/ray_deps_setup.bzl
18+
+++ b/bazel/ray_deps_setup.bzl
19+
@@ -188,6 +188,10 @@ def ray_deps_setup():
20+
build_file = True,
21+
url = "https://github.com/cython/cython/archive/c48361d0a0969206e227ec016f654c9d941c2b69.tar.gz",
22+
sha256 = "37c466fea398da9785bc37fe16f1455d2645d21a72e402103991d9e2fa1c6ff3",
23+
+ patch_cmds = [
24+
+ 'graalpy -m autopatch_capi .',
25+
+ '''patch -p1 < "$(graalpy -c 'print(__graalpython__.core_home)')/patches/Cython/Cython-0.29.32.patch"''',
26+
+ ],
27+
)
28+
29+
auto_http_archive(
30+
diff --git a/dashboard/optional_deps.py b/dashboard/optional_deps.py
31+
index 1dfaaca..6eeb618 100644
32+
--- a/dashboard/optional_deps.py
33+
+++ b/dashboard/optional_deps.py
34+
@@ -15,7 +15,7 @@ import aiohttp_cors # noqa: F401
35+
from aiohttp import hdrs # noqa: F401
36+
from aiohttp.typedefs import PathLike # noqa: F401
37+
from aiohttp.web import RouteDef # noqa: F401
38+
-import pydantic # noqa: F401
39+
+# import pydantic # noqa: F401
40+
import grpc # noqa: F401
41+
42+
# Adding new modules should also be reflected in the
43+
diff --git a/pyproject.toml b/pyproject.toml
44+
new file mode 100644
45+
index 0000000..de2b7ad
46+
--- /dev/null
47+
+++ b/pyproject.toml
48+
@@ -0,0 +1,4 @@
49+
+[build-system]
50+
+requires = ["setuptools >= 40.6.0", "wheel", "pip", "psutil", "setproctitle", "colorama"]
51+
+build-backend = "ray_build_backend"
52+
+backend-path = ["."]
53+
diff --git a/python/ray/_private/services.py b/python/ray/_private/services.py
54+
index 867b748..40b3fb2 100644
55+
--- a/python/ray/_private/services.py
56+
+++ b/python/ray/_private/services.py
57+
@@ -1000,7 +1000,7 @@ def start_ray_process(
58+
stdout=stdout_file,
59+
stderr=stderr_file,
60+
stdin=subprocess.PIPE if pipe_stdin else None,
61+
- preexec_fn=preexec_fn if sys.platform != "win32" else None,
62+
+ #preexec_fn=preexec_fn if sys.platform != "win32" else None,
63+
creationflags=CREATE_SUSPENDED if win32_fate_sharing else 0,
64+
)
65+
66+
diff --git a/python/ray/cloudpickle/cloudpickle.py b/python/ray/cloudpickle/cloudpickle.py
67+
index 9c67ec6..12fda5a 100644
68+
--- a/python/ray/cloudpickle/cloudpickle.py
69+
+++ b/python/ray/cloudpickle/cloudpickle.py
70+
@@ -521,10 +521,8 @@ def _walk_global_ops(code):
71+
"""
72+
Yield referenced name for all global-referencing instructions in *code*.
73+
"""
74+
- for instr in dis.get_instructions(code):
75+
- op = instr.opcode
76+
- if op in GLOBAL_OPS:
77+
- yield instr.argval
78+
+ # GraalPy change: we don't support dis
79+
+ yield from code.co_names
80+
81+
82+
def _extract_class_dict(cls):
83+
diff --git a/ray_build_backend.py b/ray_build_backend.py
84+
new file mode 100644
85+
index 0000000..e9d325f
86+
--- /dev/null
87+
+++ b/ray_build_backend.py
88+
@@ -0,0 +1,41 @@
89+
+# We need a whole custom build backend just because the setup.py is in a subdir
90+
+import os
91+
+import re
92+
+import sys
93+
+import tarfile
94+
+import subprocess
95+
+import tempfile
96+
+import shutil
97+
+from pathlib import Path
98+
+
99+
+
100+
+def build_sdist(sdist_directory, config_settings=None):
101+
+ nv = 'ray-2.9.1'
102+
+ srcdir = Path(__file__).parent
103+
+ archive_path = Path(sdist_directory) / f'{nv}.tar.gz'
104+
+
105+
+ def tarfilter(info):
106+
+ if re.match(r'\./(?:.git|bazel-|venv|[^-/]+-venv|dist)', info.name):
107+
+ return None
108+
+ info.name = f'./{nv}/{info.name}'
109+
+ return info
110+
+
111+
+ with tarfile.open(archive_path, 'w:gz') as tar:
112+
+ tar.add('.', filter=tarfilter)
113+
+ return archive_path.name
114+
+
115+
+
116+
+def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
117+
+ wheel_directory = Path(wheel_directory).absolute()
118+
+ os.chdir('python')
119+
+ env = os.environ.copy()
120+
+ env['SKIP_THIRDPARTY_INSTALL'] = 'true'
121+
+ try:
122+
+ subprocess.run([sys.executable, 'setup.py', 'bdist_wheel'], env=env, check=True)
123+
+ wheels = list(Path('dist').glob('*.whl'))
124+
+ assert len(wheels) == 1, f"Expected 1 wheel, found {len(wheels)}"
125+
+ wheel = wheels[0]
126+
+ shutil.copyfile(wheel, wheel_directory / wheel.name)
127+
+ return str(wheel.name)
128+
+ finally:
129+
+ os.chdir('..')
130+
diff --git a/src/ray/util/logging.cc b/src/ray/util/logging.cc
131+
index f41aa65..f8e895d 100644
132+
--- a/src/ray/util/logging.cc
133+
+++ b/src/ray/util/logging.cc
134+
@@ -374,6 +374,7 @@ bool RayLog::IsFailureSignalHandlerEnabled() {
135+
}
136+
137+
void RayLog::InstallFailureSignalHandler(const char *argv0, bool call_previous_handler) {
138+
+ /*
139+
#ifdef _WIN32
140+
// If process fails to initialize, don't display an error window.
141+
SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS);
142+
@@ -389,6 +390,7 @@ void RayLog::InstallFailureSignalHandler(const char *argv0, bool call_previous_h
143+
options.writerfn = WriteFailureMessage;
144+
absl::InstallFailureSignalHandler(options);
145+
is_failure_signal_handler_installed_ = true;
146+
+ */
147+
}
148+
149+
void RayLog::InstallTerminateHandler() { std::set_terminate(TerminateHandler); }

graalpython/lib-graalpython/patches/tensorflow/tensorflow-2.15.0.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,10 @@ index 00000000000..2b3824c8765
337337
+ print('Wheel:\n\t' + find_tf_whl(args.whl_path))
338338
+
339339
+ if not args.no_install:
340-
+ run(PIP + ["install", "--force-reinstall", os.path.join(whl_path, find_tf_whl(args.whl_path))])
340+
+ run(PIP + ["install", "--force-reinstall", os.path.join(args.whl_path, find_tf_whl(args.whl_path))])
341341
+
342342
+ if args.test:
343-
+ populate_cached_wheels(invalidate=args.no_pipreq)
343+
+ populate_cached_wheels(skip_if_exist=args.no_pipreq)
344344
+ if not os.path.exists(TRACK_DIR):
345345
+ os.mkdir(TRACK_DIR)
346346
+ BAZEL_TEST = [

0 commit comments

Comments
 (0)