File tree Expand file tree Collapse file tree 2 files changed +23
-8
lines changed Expand file tree Collapse file tree 2 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,11 @@ if git diff --cached --name-only | grep -q "^torch_pin.py$"; then
88 echo " 📝 Updating PyTorch commit pin..."
99
1010 # Run the update script
11- if python .github/scripts/update_pytorch_pin.py; then
11+ hook_output=$( python .github/scripts/update_pytorch_pin.py 2>&1 )
12+ hook_status=$?
13+ echo " $hook_output "
14+
15+ if [ $hook_status -eq 0 ]; then
1216 # Check if pytorch.txt was modified
1317 if ! git diff --quiet .ci/docker/ci_commit_pins/pytorch.txt; then
1418 echo " ✅ PyTorch commit pin updated successfully"
@@ -19,9 +23,14 @@ if git diff --cached --name-only | grep -q "^torch_pin.py$"; then
1923 echo " ℹ️ PyTorch commit pin unchanged"
2024 fi
2125 else
22- echo " ❌ Failed to update PyTorch commit pin"
23- echo " Please run: python .github/scripts/update_pytorch_pin.py"
24- exit 1
26+ if echo " $hook_output " | grep -qi " rate limit exceeded" ; then
27+ echo " ⚠️ PyTorch commit pin not updated due to GitHub API rate limiting."
28+ echo " Please manually update .ci/docker/ci_commit_pins/pytorch.txt if needed."
29+ else
30+ echo " ❌ Failed to update PyTorch commit pin"
31+ echo " Please run: python .github/scripts/update_pytorch_pin.py"
32+ exit 1
33+ fi
2534 fi
2635fi
2736
Original file line number Diff line number Diff line change 44import re
55import sys
66import urllib .request
7- from datetime import datetime
87
98
109def parse_nightly_version (nightly_version ):
@@ -53,7 +52,7 @@ def get_commit_hash_for_nightly(date_str):
5352 Commit hash string
5453 """
5554 api_url = "https://api.github.com/repos/pytorch/pytorch/commits"
56- params = f"?sha=nightly&per_page=100 "
55+ params = f"?sha=nightly&per_page=50 "
5756 url = api_url + params
5857
5958 req = urllib .request .Request (url )
@@ -74,14 +73,21 @@ def get_commit_hash_for_nightly(date_str):
7473 commit_msg = commit .get ("commit" , {}).get ("message" , "" )
7574 # Check if the first line of commit message matches
7675 first_line = commit_msg .split ("\n " )[0 ].strip ()
77- if first_line == target_title or first_line .startswith (f"{ date_str } nightly" ):
78- return commit [ "sha" ]
76+ if first_line .startswith (f"{ date_str } nightly" ):
77+ return extract_hash_from_title ( first_line )
7978
8079 raise ValueError (
8180 f"Could not find commit with title matching '{ target_title } ' in nightly branch"
8281 )
8382
8483
84+ def extract_hash_from_title (title ):
85+ match = re .search (r"\(([0-9a-fA-F]{7,40})\)" , title )
86+ if not match :
87+ raise ValueError (f"Could not extract commit hash from title '{ title } '" )
88+ return match .group (1 )
89+
90+
8591def update_pytorch_pin (commit_hash ):
8692 """
8793 Update .ci/docker/ci_commit_pins/pytorch.txt with the new commit hash.
You can’t perform that action at this time.
0 commit comments