Skip to content

Commit e3819d1

Browse files
authored
Add m1 tagged build for torchtext (#1776) (#1785)
* Add m1 tagged build for torchtext * Remove default chanell * prettier
1 parent 29a6311 commit e3819d1

File tree

2 files changed

+47
-11
lines changed

2 files changed

+47
-11
lines changed

.github/workflows/build-m1-binaries.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ on:
66
push:
77
branches:
88
- nightly
9+
tags:
10+
# NOTE: Binary build pipelines should only get triggered on release candidate builds
11+
# Release candidate tags look like: v1.11.0-rc1
12+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
913
workflow_dispatch:
14+
env:
15+
CHANNEL: "nightly"
1016
jobs:
1117
build_wheels:
1218
name: "Build TorchText M1 wheels"
@@ -17,6 +23,13 @@ jobs:
1723
steps:
1824
- name: Checkout repository
1925
uses: actions/checkout@v2
26+
- name: Set CHANNEL (only for tagged pushes)
27+
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') }}
28+
run: |
29+
# reference ends with an RC suffix
30+
if [[ ${GITHUB_REF_NAME} = *-rc[0-9]* ]]; then
31+
echo "CHANNEL=test" >> "$GITHUB_ENV"
32+
fi
2033
- name: Build TorchText M1 wheel
2134
shell: arch -arch arm64 bash {0}
2235
env:
@@ -27,11 +40,16 @@ jobs:
2740
. ~/miniconda3/etc/profile.d/conda.sh
2841
set -ex
2942
. packaging/pkg_helpers.bash
30-
setup_build_version
43+
# if we are uploading to test channell, our version consist only of the base: 0.x.x - no date string or suffix added
44+
if [[ $CHANNEL == "test" ]]; then
45+
setup_base_build_version
46+
else
47+
setup_build_version
48+
fi
3149
git submodule update --init --recursive
3250
WHL_NAME=torchtext-${BUILD_VERSION}-cp${PY_VERS/.}-cp${PY_VERS/.}-macosx_11_0_arm64.whl
3351
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy cmake ninja wheel pkg-config
34-
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
52+
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
3553
conda run -p ${ENV_NAME} python3 -mpip install delocate
3654
conda run -p ${ENV_NAME} python3 setup.py bdist_wheel
3755
export PYTORCH_VERSION="$(conda run -p ${ENV_NAME} python3 -mpip show torch | grep ^Version: | sed 's/Version: *//')"
@@ -46,24 +64,27 @@ jobs:
4664
. ~/miniconda3/etc/profile.d/conda.sh
4765
set -ex
4866
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy
49-
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
67+
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
5068
conda run -p ${ENV_NAME} python3 -mpip install dist/*.whl
5169
# Test torch is importable, by changing cwd and running import commands
5270
conda run --cwd /tmp -p ${ENV_NAME} python3 -c "import torchtext;print('torchtext version is ', torchtext.__version__)"
5371
conda env remove -p ${ENV_NAME}
5472
- name: Upload wheel to GitHub
55-
if: ${{ github.event_name == 'push' && steps.extract_branch.outputs.branch == 'nightly' }}
73+
if:
74+
${{ github.event_name == 'push' && (github.event.ref == 'ref/heads/nightly' || startsWith(github.event.ref,
75+
'refs/tags/')) }}
5676
uses: actions/upload-artifact@v3
5777
with:
5878
name: torchtext-py${{ matrix.py_vers }}-macos11-m1
5979
path: dist/
6080
- name: Upload wheel to S3
61-
if: ${{ github.event_name == 'push' && steps.extract_branch.outputs.branch == 'nightly' }}
81+
if:
82+
${{ github.event_name == 'push' && (github.event.ref == 'ref/heads/nightly' || startsWith(github.event.ref,
83+
'refs/tags/')) }}
6284
shell: arch -arch arm64 bash {0}
6385
env:
6486
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID }}
6587
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY }}
66-
CHANNEL: nightly
6788
run: |
6889
for pkg in dist/*; do
6990
aws s3 cp "$pkg" "s3://pytorch/whl/${CHANNEL}/cpu/" --acl public-read

packaging/pkg_helpers.bash

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,32 @@ setup_cuda() {
8888
# Usage: setup_build_version
8989
setup_build_version() {
9090
if [[ -z "$BUILD_VERSION" ]]; then
91-
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
92-
# version.txt for some reason has `a` character after major.minor.rev
93-
# command below yields 0.10.0 from version.txt containing 0.10.0a0
94-
_VERSION_BASE=$( cut -f 1 -d a "$SCRIPT_DIR/../version.txt" )
95-
BUILD_VERSION="$_VERSION_BASE.dev$(date "+%Y%m%d")$VERSION_SUFFIX"
91+
if [[ -z "$1" ]]; then
92+
setup_base_build_version
93+
else
94+
BUILD_VERSION="$1"
95+
fi
96+
BUILD_VERSION="$BUILD_VERSION.dev$(date "+%Y%m%d")$VERSION_SUFFIX"
9697
else
9798
BUILD_VERSION="$BUILD_VERSION$VERSION_SUFFIX"
9899
fi
100+
101+
# Set build version based on tag if on tag
102+
if [[ -n "${CIRCLE_TAG}" ]]; then
103+
# Strip tag
104+
BUILD_VERSION="$(echo "${CIRCLE_TAG}" | sed -e 's/^v//' -e 's/-.*$//')${VERSION_SUFFIX}"
105+
fi
106+
99107
export BUILD_VERSION
100108
}
101109

110+
setup_base_build_version() {
111+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
112+
# version.txt for some reason has `a` character after major.minor.rev
113+
# command below yields 0.10.0 from version.txt containing 0.10.0a0
114+
BUILD_VERSION=$( cut -f 1 -d a "$SCRIPT_DIR/../version.txt" )
115+
export BUILD_VERSION
116+
}
102117
# Set some useful variables for OS X, if applicable
103118
setup_macos() {
104119
if [[ "$(uname)" == Darwin ]]; then

0 commit comments

Comments
 (0)