Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 1 addition & 14 deletions python/ray/_private/runtime_env/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import json
import logging
import os
import platform
import runpy
import shutil
import subprocess
Expand Down Expand Up @@ -111,10 +110,6 @@ def _current_py_version():
return ".".join(map(str, sys.version_info[:3])) # like 3.6.10


def _is_m1_mac():
return sys.platform == "darwin" and platform.machine() == "arm64"


def current_ray_pip_specifier(
logger: Optional[logging.Logger] = default_logger,
) -> Optional[str]:
Expand Down Expand Up @@ -148,17 +143,9 @@ def current_ray_pip_specifier(
return None
elif "dev" in ray.__version__:
# Running on a nightly wheel.
if _is_m1_mac():
raise ValueError("Nightly wheels are not available for M1 Macs.")
return get_master_wheel_url()
else:
if _is_m1_mac():
# M1 Mac release wheels are currently not uploaded to AWS S3; they
# are only available on PyPI. So unfortunately, this codepath is
# not end-to-end testable prior to the release going live on PyPI.
return f"ray=={ray.__version__}"
else:
return get_release_wheel_url()
return get_release_wheel_url()


def inject_dependencies(
Expand Down
31 changes: 14 additions & 17 deletions python/ray/_private/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,28 +947,25 @@ def get_wheel_filename(

architecture = architecture or platform.processor()

if py_version_str in ["311", "310", "39", "38"] and architecture == "arm64":
darwin_os_string = "macosx_12_0_arm64"
else:
darwin_os_string = "macosx_12_0_x86_64"

if architecture == "aarch64":
linux_os_string = "manylinux2014_aarch64"
else:
linux_os_string = "manylinux2014_x86_64"
assert sys_platform in ["darwin", "linux", "win32"], sys_platform

os_strings = {
"darwin": darwin_os_string,
"linux": linux_os_string,
"win32": "win_amd64",
}

assert sys_platform in os_strings, sys_platform
if sys_platform == "darwin":
if architecture == "x86_64":
os_string = "macosx_12_0_x86_64"
else:
os_string = "macosx_12_0_arm64"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: macOS Wheel Filename Mismatch

The get_wheel_filename function generates x86_64 macOS wheel names, but the test_get_wheel_filename test skips x86_64 for macOS, commenting that "MacOS only has arm64 wheels". This inconsistency could lead to the function generating URLs for non-existent wheels, causing 404 errors for Intel Mac users.

Additional Locations (1)

Fix in Cursor Fix in Web

elif sys_platform == "linux":
if architecture == "aarch64" or architecture == "arm64":
os_string = "manylinux2014_aarch64"
else:
os_string = "manylinux2014_x86_64"
elif sys_platform == "win32":
os_string = "win_amd64"

wheel_filename = (
f"ray-{ray_version}-cp{py_version_str}-"
f"cp{py_version_str}{'m' if py_version_str in ['37'] else ''}"
f"-{os_strings[sys_platform]}.whl"
f"-{os_string}.whl"
)

return wheel_filename
Expand Down
32 changes: 0 additions & 32 deletions python/ray/tests/test_runtime_env_conda_and_pip.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import platform
import subprocess
import sys
import tempfile
Expand All @@ -11,7 +10,6 @@
import ray
from ray._common.test_utils import wait_for_condition
from ray._private.runtime_env import dependency_utils
from ray._private.runtime_env.conda import _get_conda_dict_with_ray_inserted
from ray._private.runtime_env.dependency_utils import (
INTERNAL_PIP_FILENAME,
MAX_INTERNAL_PIP_FILENAME_TRIES,
Expand All @@ -21,7 +19,6 @@
check_local_files_gced,
generate_runtime_env_dict,
)
from ray.runtime_env import RuntimeEnv
from ray.util.state import list_tasks

if not os.environ.get("CI"):
Expand All @@ -30,35 +27,6 @@
os.environ["RAY_RUNTIME_ENV_LOCAL_DEV_MODE"] = "1"


def test_get_conda_dict_with_ray_inserted_m1_wheel(monkeypatch):
# Disable dev mode to prevent Ray dependencies being automatically inserted
# into the conda dict.
if os.environ.get("RAY_RUNTIME_ENV_LOCAL_DEV_MODE") is not None:
monkeypatch.delenv("RAY_RUNTIME_ENV_LOCAL_DEV_MODE")
if os.environ.get("RAY_CI_POST_WHEEL_TESTS") is not None:
monkeypatch.delenv("RAY_CI_POST_WHEEL_TESTS")
monkeypatch.setattr(ray, "__version__", "1.9.0")
monkeypatch.setattr(ray, "__commit__", "92599d9127e228fe8d0a2d94ca75754ec21c4ae4")
monkeypatch.setattr(sys, "version_info", (3, 9, 7, "final", 0))
# Simulate running on an M1 Mac.
monkeypatch.setattr(sys, "platform", "darwin")
monkeypatch.setattr(platform, "machine", lambda: "arm64")

input_conda = {"dependencies": ["blah", "pip", {"pip": ["pip_pkg"]}]}
runtime_env = RuntimeEnv(conda=input_conda)
output_conda = _get_conda_dict_with_ray_inserted(runtime_env)
# M1 wheels are not uploaded to AWS S3. So rather than have an S3 URL
# inserted as a dependency, we should just have the string "ray==1.9.0".
assert output_conda == {
"dependencies": [
"blah",
"pip",
{"pip": ["ray==1.9.0", "ray[default]", "pip_pkg"]},
"python=3.9.7",
]
}


@pytest.mark.skipif(
os.environ.get("CI") and sys.platform != "linux",
reason="Requires PR wheels built in CI, so only run on linux CI machines.",
Expand Down
13 changes: 10 additions & 3 deletions python/ray/tests/test_runtime_env_get_wheel_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ def test_get_wheel_filename():
ray_version = "3.0.0.dev0"
for arch in ["x86_64", "aarch64", "arm64"]:
for sys_platform in ["darwin", "linux", "win32"]:
# Windows only has x86_64 wheels
if sys_platform == "win32" and arch != "x86_64":
continue
# MacOS only has arm64 wheels
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment on this line is a bit misleading. While it might be true that for these specific dev wheels only arm64 builds are produced for macOS, it's not true in general as macOS has x86_64 wheels. This could cause confusion for future maintainers. I'd suggest clarifying the comment to be more specific to dev wheels.

For example:

- # MacOS only has arm64 wheels
+ # For nightly dev wheels, we currently only build for arm64 on macOS.

if sys_platform == "darwin" and arch == "x86_64":
continue

for py_version in ray_constants.RUNTIME_ENV_CONDA_PY_VERSIONS:
filename = get_wheel_filename(
sys_platform, ray_version, py_version, arch
Expand All @@ -35,8 +42,8 @@ def test_get_master_wheel_url():
# `s3://ray-wheels/master/<test_commit>/`.
#
# Link to commit:
# https://github.com/ray-project/ray/commit/263c7e1e66746c03f16e8ee20753d05a9936f6f0
test_commit = "263c7e1e66746c03f16e8ee20753d05a9936f6f0"
# https://github.com/ray-project/ray/commit/faf06e09e55558fb36c72e91a5cf8a7e3da8b8c6
test_commit = "faf06e09e55558fb36c72e91a5cf8a7e3da8b8c6"
for sys_platform in ["darwin", "linux", "win32"]:
for py_version in ray_constants.RUNTIME_ENV_CONDA_PY_VERSIONS:
url = get_master_wheel_url(
Expand All @@ -50,7 +57,7 @@ def test_get_release_wheel_url():
# This should be a commit for which wheels have already been built for
# all platforms and python versions at
# `s3://ray-wheels/releases/2.2.0/<commit>/`.
test_commits = {"2.47.1": "61d3f2f1aa33563faa398105f4abda88cb39440b"}
test_commits = {"2.49.2": "479fa716904109d9df4b56b98ca3c3350e1ec13c"}
for sys_platform in ["darwin", "linux", "win32"]:
for py_version in ray_constants.RUNTIME_ENV_CONDA_PY_VERSIONS:
for version, commit in test_commits.items():
Expand Down