-
Notifications
You must be signed in to change notification settings - Fork 155
285 lines (275 loc) · 9.44 KB
/
_build_test_upload.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
name: Build, Test and Upload Wheel
on:
workflow_call:
inputs:
branch:
required: true
type: string
pre_dev_release:
required: true
type: boolean
pytorch_version:
required: true
type: string
do-upload:
required: false
default: true
type: boolean
secrets:
PYPI_TOKEN:
required: false
permissions:
id-token: write
contents: write
jobs:
get_release_type:
runs-on: ubuntu-latest
outputs:
type: ${{ steps.get_release_type.outputs.type }}
steps:
- name: Get Release Type
run: |
if [[ "${{ inputs.branch }}" == v* ]] && [[ ${{ inputs.pre_dev_release }} == false ]]; then
RELEASE_TYPE=official
elif [[ "${{ inputs.branch }}" == release/* ]] && [[ ${{ inputs.pre_dev_release }} == true ]]; then
RELEASE_TYPE=test
else
if [[ "${{ github.base_ref }}" == release/* ]]; then
RELEASE_TYPE=test
else
RELEASE_TYPE=nightly
fi
fi
echo "Release Type: $RELEASE_TYPE"
echo "type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
id: get_release_type
wheel_build_test:
needs: get_release_type
runs-on: ${{ matrix.os }}
container: ${{ startsWith( matrix.os, 'ubuntu' ) && 'pytorch/manylinux-cpu' || null }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
python-version:
- 3.9
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- pure
exclude:
- os: windows-latest
python-version: pure
steps:
- name: Checkout Source Repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
submodules: recursive
- name: Setup Python ${{ matrix.python-version }} for Windows
if: ${{ startsWith( matrix.os, 'windows' ) }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Add temp runner environment variables
if: ${{ startsWith( matrix.os, 'macos' ) }}
shell: bash -l {0}
run: |
echo "MINICONDA_INSTALL_PATH_MACOS=${RUNNER_TEMP}/miniconda" >> "${GITHUB_ENV}"
- name: Setup msbuild on Windows
if: startsWith( matrix.os, 'windows' )
uses: microsoft/[email protected]
- name: Set up Visual Studio shell
if: startsWith( matrix.os, 'windows' )
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: Install Build Dependency
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
pip install cmake ninja setuptools
echo "/home/runner/.local/bin" >> $GITHUB_PATH
- name: Install PyTorch and Build TorchData Wheel
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
PYTORCH_VERSION: ${{ inputs.pytorch_version }}
BUILD_S3: 0
run: |
set -ex
packaging/build_wheel.sh
- name: Validate TorchData Wheel
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
pip3 install pkginfo
for pkg in dist/torchdata*.whl; do
echo "PkgInfo of $pkg:"
pkginfo $pkg
if ${{ startsWith( matrix.os, 'ubuntu' ) && matrix.python-version != 'pure' }}; then
auditwheel show $pkg
auditwheel repair $pkg --plat manylinux2014_x86_64 -w wheelhouse
fi
done
- name: Install TorchData Wheel
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
pip3 install dist/torchdata*.whl
- name: Run Smoke Tests
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
if ${{ matrix.python-version == 'pure' }}; then
python test/smoke_test/smoke_test.py --no-s3
else
python test/smoke_test/smoke_test.py
fi
- name: Upload Wheels to Github
if: always()
uses: actions/upload-artifact@v4
with:
name: torchdata-artifact-${{ matrix.os }}-${{ matrix.python-version }}
path: dist/torchdata*.whl
wheel_upload:
if: always() && inputs.branch != '' && inputs.do-upload == true
needs: [get_release_type, wheel_build_test]
runs-on: ubuntu-latest
environment: pytorchbot-env
outputs:
upload: ${{ steps.trigger_upload.outputs.value }}
steps:
- name: Configure aws credentials (pytorch account)
if: ${{ needs.get_release_type.outputs.type == 'nightly' }}
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::749337293305:role/gha_workflow_nightly_build_wheels
aws-region: us-east-1
- name: Configure aws credentials (pytorch account)
if: ${{ needs.get_release_type.outputs.type == 'test' }}
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::749337293305:role/gha_workflow_test_build_wheels
aws-region: us-east-1
- name: Download Artifacts from Github
continue-on-error: true
uses: actions/download-artifact@v4
with:
pattern: torchdata-artifact-*
merge-multiple: true
- name: Determine if Wheel Uploading is needed
run: |
upload=false
for txt in torchdata*.whl; do
upload=true
break
done
echo "value=$upload" >> $GITHUB_OUTPUT
id: trigger_upload
- name: Display All TorchData Wheels
if: steps.trigger_upload.outputs.value == 'true'
run: ls -lh torchdata*.whl
- name: Upload Wheels to S3 Storage
if: steps.trigger_upload.outputs.value == 'true'
run: |
if [[ ${{ inputs.branch }} == 'main' ]]; then
S3_PATH=s3://pytorch/whl/nightly/
else
S3_PATH=s3://pytorch/whl/test/
fi
pip3 install awscli
set -x
for pkg in torchdata*.whl; do
aws s3 cp "$pkg" "$S3_PATH" --acl public-read
done
- name: Upload Official Wheels to PYPI
if: |
steps.trigger_upload.outputs.value == 'true' &&
needs.get_release_type.outputs.type == 'official'
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
pip3 install twine
python -m twine upload \
--username __token__ \
--password "$PYPI_TOKEN" \
torchdata*.whl
build_docs:
if: |
always() && inputs.branch != '' &&
( needs.wheel_upload.outputs.upload == 'true')
needs: [get_release_type, wheel_upload]
runs-on: ubuntu-latest
steps:
- name: Setup Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
submodules: recursive
- name: Install Dependencies
run: |
echo `python3 --version`
sudo apt-get install -y python-setuptools
python3 -m pip install --upgrade pip
python3 -m pip install setuptools
python3 -m pip install matplotlib
sudo apt-get install -y yarn
- name: Install PyTorch & TorchData
run: |
pip3 install numpy
# Add version requirement to PyTorch except nightly release
if [[ -z "${{ inputs.pytorch_version }}" ]]; then
PYTORCH_VERSION=torch
else
PYTORCH_VERSION=torch==${{ inputs.pytorch_version }}
fi
PIP_CHANNEL=${{ needs.get_release_type.outputs.type }}
if [[ $PIP_CHANNEL == 'official' ]]; then
pip3 install "$PYTORCH_VERSION" -f https://download.pytorch.org/whl/torch_stable.html
else
pip3 install --pre "$PYTORCH_VERSION" --index-url "https://download.pytorch.org/whl/$PIP_CHANNEL/cpu"
fi
pip3 install -r requirements.txt
pip3 install .
- name: Check env
run: echo `which spinx-build`
- name: Build the docset
run: |
cd ./docs
sudo apt-get install -y graphviz
pip3 install -r requirements.txt
make html
cd ..
- name: Export Target Folder
run: |
TARGET_FOLDER=${{ inputs.branch }}
if [[ $TARGET_FOLDER == release/* ]]; then
TARGET_FOLDER=${TARGET_FOLDER:8}
elif [[ $TARGET_FOLDER == tags/* ]]; then
TARGET_FOLDER=${TARGET_FOLDER:5}
elif [[ $TARGET_FOLDER == v* ]] && [[ ${{ inputs.pre_dev_release }} == false ]]; then
if [[ $TARGET_FOLDER == v*.*.* ]]; then
TARGET_FOLDER=${TARGET_FOLDER%.*}
fi
TARGET_FOLDER=${TARGET_FOLDER:1}
fi
echo "value=$TARGET_FOLDER" >> $GITHUB_OUTPUT
id: target_folder
- name: Deploy
uses: JamesIves/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages # The branch the action should deploy to.
folder: docs/build/html # The folder the action should deploy.
target-folder: ${{ steps.target_folder.outputs.value }} # The destination folder the action should deploy to.