Skip to content

Commit 3b1938f

Browse files
committed
Address review comments
1 parent bc6baf3 commit 3b1938f

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

.ci/scripts/utils.sh

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,39 +60,44 @@ install_pytorch_and_domains() {
6060
# Fetch the target commit
6161
pushd pytorch || return
6262
git checkout "${TORCH_VERSION}"
63-
git submodule update --init --recursive
6463

65-
SYSTEM_NAME=$(uname)
66-
if [[ "${SYSTEM_NAME}" == "Darwin" ]]; then
67-
PLATFORM=$(python -c 'import sysconfig; import platform; v=platform.mac_ver()[0].split(".")[0]; platform=sysconfig.get_platform().split("-"); platform[1]=f"{v}_0"; print("_".join(platform))')
64+
local system_name=$(uname)
65+
if [[ "${system_name}" == "Darwin" ]]; then
66+
local platform=$(python -c 'import sysconfig; import platform; v=platform.mac_ver()[0].split(".")[0]; platform=sysconfig.get_platform().split("-"); platform[1]=f"{v}_0"; print("_".join(platform))')
6867
fi
69-
PYTHON_VERSION=$(python -c 'import platform; v=platform.python_version_tuple(); print(f"{v[0]}{v[1]}")')
70-
TORCH_RELEASE=$(cat version.txt)
71-
TORCH_SHORT_HASH=${TORCH_VERSION:0:7}
72-
TORCH_WHEEL_PATH="cached_artifacts/pytorch/executorch/pytorch_wheels/${SYSTEM_NAME}/${PYTHON_VERSION}"
73-
TORCH_WHEEL_NAME="torch-${TORCH_RELEASE}%2Bgit${TORCH_SHORT_HASH}-cp${PYTHON_VERSION}-cp${PYTHON_VERSION}-${PLATFORM:-}.whl"
68+
local python_version=$(python -c 'import platform; v=platform.python_version_tuple(); print(f"{v[0]}{v[1]}")')
69+
local torch_release=$(cat version.txt)
70+
local torch_short_hash=${TORCH_VERSION:0:7}
71+
local torch_wheel_path="cached_artifacts/pytorch/executorch/pytorch_wheels/${system_name}/${python_version}"
72+
local torch_wheel_name="torch-${torch_release}%2Bgit${torch_short_hash}-cp${python_version}-cp${python_version}-${platform:-}.whl"
7473

75-
CACHE_TORCH_WHEEL="https://gha-artifacts.s3.us-east-1.amazonaws.com/${TORCH_WHEEL_PATH}/${TORCH_WHEEL_NAME}"
74+
local cached_torch_wheel="https://gha-artifacts.s3.us-east-1.amazonaws.com/${torch_wheel_path}/${torch_wheel_name}"
7675
# Cache PyTorch wheel is only needed on MacOS, Linux CI already has this as part
7776
# of the Docker image
78-
if [[ "${SYSTEM_NAME}" == "Darwin" ]]; then
79-
pip install "${CACHE_TORCH_WHEEL}" || TORCH_WHEEL_NOT_FOUND=1
77+
if [[ "${system_name}" == "Darwin" ]]; then
78+
pip install "${cached_torch_wheel}" || TORCH_WHEEL_NOT_FOUND=1
79+
else
80+
TORCH_WHEEL_NOT_FOUND=1
8081
fi
8182

8283
# Found no such wheel, we will build it from source then
8384
if [[ "${TORCH_WHEEL_NOT_FOUND:-0}" == "1" ]]; then
85+
echo "No cached wheel found, continue with building PyTorch at ${TORCH_VERSION}"
86+
87+
git submodule update --init --recursive
8488
USE_DISTRIBUTED=1 python setup.py bdist_wheel
8589
pip install "$(echo dist/*.whl)"
8690

8791
# Only AWS runners have access to S3
8892
if command -v aws && [[ -z "${GITHUB_RUNNER:-}" ]]; then
89-
for WHEEL_PATH in dist/*.whl; do
90-
WHEEL_NAME=$(basename "${WHEEL_PATH}")
91-
aws s3 cp "${WHEEL_PATH}" "s3://gha-artifacts/${TORCH_WHEEL_PATH}/${WHEEL_NAME}"
93+
for wheel_path in dist/*.whl; do
94+
local wheel_name=$(basename "${wheel_path}")
95+
echo "Caching ${wheel_name}"
96+
aws s3 cp "${wheel_path}" "s3://gha-artifacts/${torch_wheel_path}/${wheel_name}"
9297
done
9398
fi
9499
else
95-
echo "Use cached wheel at ${CACHE_TORCH_WHEEL}"
100+
echo "Use cached wheel at ${cached_torch_wheel}"
96101
fi
97102

98103
# Grab the pinned audio and vision commits from PyTorch

0 commit comments

Comments
 (0)