Skip to content

Commit 6b3db77

Browse files
aslonnieYoussefEssDS
authored andcommitted
[release auto] support uploading wheels from arbitrary branch (ray-project#58344)
so that we can perform surgeries in the last minute if required. Signed-off-by: Lonnie Liu <[email protected]>
1 parent 2ad1f39 commit 6b3db77

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

ci/ray_ci/automation/ray_wheels_lib.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from typing import List
2+
from typing import List, Optional
33

44
import boto3
55

@@ -82,6 +82,7 @@ def download_ray_wheels_from_s3(
8282
commit_hash: str,
8383
ray_version: str,
8484
directory_path: str,
85+
branch: Optional[str] = None,
8586
) -> None:
8687
"""
8788
Download Ray wheels from S3 to the given directory.
@@ -93,8 +94,10 @@ def download_ray_wheels_from_s3(
9394
"""
9495
full_directory_path = os.path.join(bazel_workspace_dir, directory_path)
9596
wheels = _get_wheel_names(ray_version=ray_version)
97+
if not branch:
98+
branch = f"releases/{ray_version}"
9699
for wheel in wheels:
97-
s3_key = f"releases/{ray_version}/{commit_hash}/{wheel}.whl"
100+
s3_key = f"{branch}/{commit_hash}/{wheel}.whl"
98101
download_wheel_from_s3(s3_key, full_directory_path)
99102

100103
_check_downloaded_wheels(full_directory_path, wheels)

ci/ray_ci/automation/test_ray_wheels_lib.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,36 @@ def test_download_ray_wheels_from_s3(
153153
mock_check_wheels.assert_called_with(tmp_dir, SAMPLE_WHEELS)
154154

155155

156+
@mock.patch("ci.ray_ci.automation.ray_wheels_lib.download_wheel_from_s3")
157+
@mock.patch("ci.ray_ci.automation.ray_wheels_lib._check_downloaded_wheels")
158+
@mock.patch("ci.ray_ci.automation.ray_wheels_lib._get_wheel_names")
159+
def test_download_ray_wheels_from_s3_with_branch(
160+
mock_get_wheel_names, mock_check_wheels, mock_download_wheel
161+
):
162+
commit_hash = "1234567"
163+
ray_version = "1.0.0"
164+
165+
mock_get_wheel_names.return_value = SAMPLE_WHEELS
166+
167+
with tempfile.TemporaryDirectory() as tmp_dir:
168+
download_ray_wheels_from_s3(
169+
commit_hash=commit_hash,
170+
ray_version=ray_version,
171+
directory_path=tmp_dir,
172+
branch="custom_branch",
173+
)
174+
175+
mock_get_wheel_names.assert_called_with(ray_version=ray_version)
176+
assert mock_download_wheel.call_count == len(SAMPLE_WHEELS)
177+
for i, call_args in enumerate(mock_download_wheel.call_args_list):
178+
assert (
179+
call_args[0][0] == f"custom_branch/{commit_hash}/{SAMPLE_WHEELS[i]}.whl"
180+
)
181+
assert call_args[0][1] == tmp_dir
182+
183+
mock_check_wheels.assert_called_with(tmp_dir, SAMPLE_WHEELS)
184+
185+
156186
@mock.patch("ci.ray_ci.automation.ray_wheels_lib.download_wheel_from_s3")
157187
@mock.patch("ci.ray_ci.automation.ray_wheels_lib._check_downloaded_wheels")
158188
@mock.patch("ci.ray_ci.automation.ray_wheels_lib._get_wheel_names")

ci/ray_ci/automation/upload_wheels_pypi.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,21 @@
1414
@click.option("--ray_version", required=True, type=str)
1515
@click.option("--commit_hash", required=True, type=str)
1616
@click.option("--pypi_env", required=True, type=click.Choice(["test", "prod"]))
17+
@click.option("--branch", required=False, type=str)
1718
@click.option("--build_tag", required=False, type=str)
1819
def main(
19-
ray_version: str, commit_hash: str, pypi_env: str, build_tag: Optional[str] = None
20+
ray_version: str,
21+
commit_hash: str,
22+
pypi_env: str,
23+
branch: Optional[str] = None,
24+
build_tag: Optional[str] = None,
2025
):
2126
with tempfile.TemporaryDirectory() as temp_dir:
2227
download_ray_wheels_from_s3(
2328
commit_hash=commit_hash,
2429
ray_version=ray_version,
2530
directory_path=temp_dir,
31+
branch=branch,
2632
)
2733
if build_tag:
2834
add_build_tag_to_wheels(directory_path=temp_dir, build_tag=build_tag)

0 commit comments

Comments
 (0)