-
Notifications
You must be signed in to change notification settings - Fork 152
435 lines (420 loc) · 15.4 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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
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
CONDA_PYTORCHBOT_TOKEN:
required: false
CONDA_TEST_PYTORCHBOT_TOKEN:
required: false
CONDA_NIGHTLY_PYTORCHBOT_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@v3
with:
ref: ${{ inputs.branch }}
submodules: recursive
- name: Setup Python ${{ matrix.python-version }} for Windows
if: ${{ startsWith( matrix.os, 'windows' ) }}
uses: actions/setup-python@v4
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@v3
with:
name: torchdata-artifact
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@v3
with:
name: torchdata-artifact
- 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
conda_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"
steps:
- name: Checkout Source Repository
uses: actions/checkout@v3
with:
ref: ${{ inputs.branch }}
submodules: recursive
- name: Determine if build AWSSDK
shell: bash -l {0}
run: |
BUILD_S3=0
echo "value=$BUILD_S3" >> $GITHUB_OUTPUT
id: build_s3
- name: Add temp runner environment variables
shell: bash -l {0}
run: |
echo "MINICONDA_INSTALL_PATH=${RUNNER_TEMP}/miniconda" >> "${GITHUB_ENV}"
echo "CONDA_ENV_PATH=${RUNNER_TEMP}/conda_build_env" >> "${GITHUB_ENV}"
- name: Create Conda Env on Windows
if: ${{ startsWith( matrix.os, 'windows' ) }}
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
activate-environment: ${{ env.CONDA_ENV_PATH }}
- name: Build TorchData for Conda
shell: bash -l {0}
env:
PYTHON_VERSION: ${{ matrix.python-version }}
PYTORCH_VERSION: ${{ inputs.pytorch_version }}
BUILD_S3: ${{ steps.build_s3.outputs.value }}
run: |
set -ex
if ${{ ! startsWith( matrix.os, 'windows' ) }}; then
source "${MINICONDA_INSTALL_PATH}/etc/profile.d/conda.sh"
fi
conda activate "${CONDA_ENV_PATH}"
if [[ "${PYTHON_VERSION}" = "3.11" ]]; then
conda install -yq conda-build -c malfet -c conda-forge
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c malfet"
else
conda install -yq conda-build
fi
packaging/build_conda.sh
# conda index ./conda-bld
- name: Upload Conda Package to Github
if: always()
uses: actions/upload-artifact@v3
with:
name: torchdata-artifact
path: conda-bld/*/torchdata-*.tar.bz2
conda_upload:
if: always() && inputs.branch != '' && inputs.do-upload == true
needs: [get_release_type, conda_build_test]
runs-on: ubuntu-latest
container: continuumio/miniconda3
environment: pytorchbot-env
outputs:
upload: ${{ steps.trigger_upload.outputs.value }}
steps:
- name: Download Artifacts from Github
continue-on-error: true
uses: actions/download-artifact@v3
with:
name: torchdata-artifact
- name: Determine if Conda Uploading is needed
run: |
upload=false
for pkg in ./*/torchdata-*.tar.bz2; do
upload=true
break
done
echo "value=$upload" >> $GITHUB_OUTPUT
id: trigger_upload
- name: Display All TorchData Conda Package
if: steps.trigger_upload.outputs.value == 'true'
run: ls -lh ./*/torchdata-*.tar.bz2
- name: Upload Packages to Conda
if: steps.trigger_upload.outputs.value == 'true'
shell: bash -l {0}
env:
CONDA_PYTORCHBOT_TOKEN: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
CONDA_NIGHTLY_PYTORCHBOT_TOKEN: ${{ secrets.CONDA_NIGHTLY_PYTORCHBOT_TOKEN }}
CONDA_TEST_PYTORCHBOT_TOKEN: ${{ secrets.CONDA_TEST_PYTORCHBOT_TOKEN }}
run: |
conda create -y --name conda_upload_env
conda activate conda_upload_env
conda install -yq anaconda-client
conda install -c conda-forge -yq jq
if [[ ${{ needs.get_release_type.outputs.type }} == 'official' ]]; then
CONDA_CHANNEL=pytorch
CONDA_TOKEN=${CONDA_PYTORCHBOT_TOKEN}
elif [[ ${{ needs.get_release_type.outputs.type }} == 'test' ]]; then
CONDA_CHANNEL=pytorch-${{ needs.get_release_type.outputs.type }}
CONDA_TOKEN=${CONDA_TEST_PYTORCHBOT_TOKEN}
else
CONDA_CHANNEL=pytorch-${{ needs.get_release_type.outputs.type }}
CONDA_TOKEN=${CONDA_NIGHTLY_PYTORCHBOT_TOKEN}
fi
if [[ ${{ needs.get_release_type.outputs.type }} == 'nightly' ]]; then
# Loop over all platforms [win-64, osx-64, linux-64]
for subdir in $(find . -type f -name '*torchdata*.tar.bz2' | sed -r 's|/[^/]+$||' | uniq | cut -f2 -d/) ; do
version=""
# Find existing conda packages on pytorch nightly
for val in $(conda search --json torchdata --channel=$CONDA_CHANNEL --subdir=$subdir | jq -r '.[][] | .version, .build'); do
if [[ -z $version ]]; then
version=$val
else
build=$val
# Check if a new conda package built based on the same Python version and platform exists
for new_package in ./$subdir/torchdata-*-$build.tar.bz2; do
if [[ -f "$new_package" ]]; then
echo "Removing $CONDA_CHANNEL/torchdata/$version/$subdir/torchdata-$version-$build.tar.bz2"
anaconda -t "${CONDA_TOKEN}" remove -f "$CONDA_CHANNEL/torchdata/$version/$subdir/torchdata-$version-$build.tar.bz2"
break
fi
done
version=""
build=""
fi
done
# Upload new conda packages per subdir
anaconda -t "${CONDA_TOKEN}" upload ./$subdir/torchdata-*.tar.bz2 -u "$CONDA_CHANNEL" --label main --no-progress --force
done
else
anaconda -t "${CONDA_TOKEN}" upload ./*/torchdata-*.tar.bz2 -u "$CONDA_CHANNEL" --label main --no-progress --force
fi
build_docs:
if: |
always() && inputs.branch != '' &&
( needs.wheel_upload.outputs.upload == 'true' || needs.conda_upload.outputs.upload == 'true' )
needs: [get_release_type, wheel_upload, conda_upload]
runs-on: ubuntu-latest
steps:
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Checkout
uses: actions/checkout@v3
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.