Skip to content

Commit 52038ca

Browse files
authored
Merge pull request #237 from AchimGaedkeLynker/patch-1
Use script to update version SHA
2 parents 66c43cb + 6c40975 commit 52038ca

File tree

6 files changed

+70
-26
lines changed

6 files changed

+70
-26
lines changed

.github/workflows/conda-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
steps:
4545

4646
- name: Checkout code
47+
# Do not change this to v5 until cirun can handle node v24
4748
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
4849

4950
- name: Build on Linux

recipe/build-core.bat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ echo %CONDA_PREFIX%
2727
python -c "import os; print('\n'.join(os.environ['PATH'].split(';')))"
2828
echo ----------
2929

30+
echo ========================================
31+
echo Fix up the sha in python/ray/_version.py
32+
echo ========================================
33+
"%PYTHON%" "%RECIPE_DIR%/fixup_sha.py" python/ray/_version.py "%PKG_VERSION%"
34+
35+
3036
echo ==========================================================
3137
echo calling pip to install
3238
echo ==========================================================

recipe/build-core.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ echo '---------------- .bazelrc --------------------------'
4949
cat .bazelrc
5050
echo '----------------------------------------------------'
5151

52+
echo ========================================
53+
echo Fix up the sha in python/ray/_version.py
54+
echo ========================================
55+
python3 ${RECIPE_DIR}/fixup_sha.py python/ray/_version.py ${PKG_VERSION}
56+
5257
cd python/
5358
export SKIP_THIRDPARTY_INSTALL_CONDA_FORGE=1
5459

recipe/fixup_sha.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Call like python3 __file__ python/ray/_version.py 2.49.2
2+
3+
import json
4+
import os
5+
import sys
6+
import time
7+
from urllib.request import HTTPError, urlopen
8+
9+
10+
def get_commit_sha(ver: str) -> str:
11+
"""
12+
Return sha from version tag commit.
13+
14+
Use retry information in headers and exponential backoff to address rate limiting issues.
15+
See: https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#exceeding-the-rate-limit
16+
"""
17+
exp_backoff = 60
18+
retry_count = 0
19+
while True:
20+
try:
21+
content = urlopen(
22+
f"https://api.github.com/repos/ray-project/ray/git/ref/tags/ray-{ver}"
23+
).read()
24+
return json.loads(content)["object"]["sha"]
25+
except HTTPError as e:
26+
if retry_count < 10:
27+
if (e.code == 403 and e.msg == "rate limit exceeded") or e.code == 429:
28+
retry_count += 1
29+
timeout = exp_backoff
30+
if "retry-after" in e.hdrs:
31+
timeout = int(e.hdrs["retry-after"])
32+
elif e.hdrs.get("x-ratelimit-remaining", None) == "0":
33+
timeout = max(int(e.hdrs["x-ratelimit-reset"]) - time.time(), 0)
34+
else:
35+
exp_backoff *= 1.5
36+
print(f"{e}:, retrying after {timeout} s", file=sys.stderr)
37+
time.sleep(timeout)
38+
continue
39+
raise
40+
41+
42+
versionpy = sys.argv[1]
43+
ver = sys.argv[2]
44+
45+
assert os.path.exists(versionpy)
46+
47+
with open(versionpy, "r") as fid:
48+
txt = fid.read()
49+
50+
sha = get_commit_sha(ver)
51+
52+
txt = txt.replace("{{RAY_COMMIT_SHA}}", sha)
53+
assert f'version = "{ver}"' in txt
54+
assert f'commit = "{sha}"' in txt
55+
with open(versionpy, "w") as fid:
56+
fid.write(txt)

recipe/patches/0004-update-commit-sha.patch

Lines changed: 0 additions & 23 deletions
This file was deleted.

recipe/recipe.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ source:
1515
- patches/0001-Disable-making-entry-scripts.patch
1616
- patches/0002-Ignore-warnings-in-event.cc-and-logging.cc.patch
1717
- patches/0003-Newer-hermetic-python.patch
18-
# This needs modification for each release
19-
- patches/0004-update-commit-sha.patch
2018
# See https://github.com/conda-forge/ray-packages-feedstock/issues/136
2119
# Keep in sync with current or active migration of libgrpc to avoid
2220
# ABI breakage
@@ -35,7 +33,8 @@ source:
3533
- patches/0012-No-path-isolation.patch
3634

3735
build:
38-
number: 0
36+
number: 2
37+
3938

4039
outputs:
4140
- package:

0 commit comments

Comments
 (0)