Skip to content

Commit 4cd744f

Browse files
ejguanfacebook-github-bot
authored andcommitted
Enable release workflow for both conda and wheel and enable nightly release (#300)
Summary: Changes: - Remove redundant logic to compare commits between release wheels - Add `version.txt` as the single source of truth for the version of TorchData. - Reason: Conda needs the version without running `python setup.py ...`. Without this PR, the version of TorchData is determined by running `python setup.py ...`. - Fix a bug in `setup.py` that pytorch version is incorrect - Add `packaging/build_conda.sh` and `packaging/build_wheel.sh` and related utility for TorchData to build packages and wheels. (taking reference from TorchVision and TorchText) - Files in `packaging/torchdata/...` are required by conda-build - Reason: Conda won't to run `python setup.py ...` - Remove --release/--nightly option for `setup.py` as we would use the script above to do so. - Add conda package build/upload workflow - Enable nightly build (Example: https://github.com/pytorch/data/runs/5647039889?check_suite_focus=true) - Validated the version number for nightly release (wheel/conda) - Validated the dependency for nightly release (wheel/conda) Pull Request resolved: #300 Reviewed By: NivekT Differential Revision: D35050961 Pulled By: ejguan fbshipit-source-id: 41a805d271f6862e031ff145419729efba0a01ec
1 parent fda2c3f commit 4cd744f

File tree

15 files changed

+433
-174
lines changed

15 files changed

+433
-174
lines changed

.github/workflows/_build_test_upload.yml

Lines changed: 123 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ on:
1414
type: string
1515
secrets:
1616
PYTORCH_BINARY_AWS_ACCESS_KEY_ID:
17-
required: false
17+
required: true
1818
PYTORCH_BINARY_AWS_SECRET_ACCESS_KEY:
19-
required: false
19+
required: true
2020
PYPI_TOKEN:
2121
required: false
2222
CONDA_PYTORCHBOT_TOKEN:
23-
required: false
23+
required: true
2424

2525
jobs:
2626
get_release_type:
@@ -34,12 +34,10 @@ jobs:
3434
steps:
3535
- name: Get Release Type
3636
run: |
37-
if [[ ${{ inputs.branch }} == release/* ]]; then
38-
if [[ ${{ inputs.pre_dev_release }} == true ]]; then
39-
RELEASE_TYPE=test
40-
else
41-
RELEASE_TYPE=official
42-
fi
37+
if [[ ${{ inputs.branch }} == v* ]] && [[ ${{ inputs.pre_dev_release }} == false ]]; then
38+
RELEASE_TYPE=official
39+
elif [[ ${{ inputs.branch }} == release/* ]] && [[ ${{ inputs.pre_dev_release }} == true ]]; then
40+
RELEASE_TYPE=test
4341
elif [[ ${{ inputs.branch }} == main ]] && [[ ${{ inputs.pre_dev_release }} == true ]]; then
4442
RELEASE_TYPE=nightly
4543
else
@@ -52,148 +50,86 @@ jobs:
5250
echo "::set-output name=type::$RELEASE_TYPE"
5351
id: get_release_type
5452

55-
build_test:
53+
wheel_build_test:
5654
if: ${{ needs.get_release_type.outputs.type }}
5755
needs: get_release_type
5856
runs-on: ${{ matrix.os }}
5957
strategy:
6058
fail-fast: false
61-
# TODO: Turn the matrix on after cpp landed
6259
matrix:
6360
os:
64-
# - macos-latest
61+
- macos-latest
6562
- ubuntu-latest
66-
# - windows-latest
63+
- windows-latest
6764
python-version:
68-
# - 3.7
69-
# - 3.8
65+
- 3.7
66+
- 3.8
7067
- 3.9
68+
- "3.10"
7169
steps:
7270
- name: Setup Python ${{ matrix.python-version }}
7371
uses: actions/setup-python@v2
7472
with:
7573
python-version: ${{ matrix.python-version }}
76-
- name: Install Pre-release/Nightly-release/Official-release PyTorch
77-
run: |
78-
pip3 install numpy
79-
# Add version requirement to PyTorch except nightly release
80-
if [[ ${{ inputs.pytorch_version }} ]]; then
81-
PYTORCH_VERSION=torch==${{ inputs.pytorch_version }}
82-
else
83-
PYTORCH_VERSION=torch
84-
fi
85-
86-
PIP_CHANNEL=${{ needs.get_release_type.outputs.type }}
87-
88-
if [[ $PIP_CHANNEL == 'official' ]]; then
89-
pip3 install "$PYTORCH_VERSION"
90-
else
91-
pip3 install --pre "$PYTORCH_VERSION" -f "https://download.pytorch.org/whl/$PIP_CHANNEL/cpu/torch_$PIP_CHANNEL.html"
92-
fi
9374
- name: Checkout Source Repository
9475
uses: actions/checkout@v2
9576
with:
9677
ref: ${{ inputs.branch }}
97-
- name: Get Hash of the Last Commit from Release
98-
if: |
99-
needs.get_release_type.outputs.type == 'nightly' ||
100-
needs.get_release_type.outputs.type == 'test'
101-
run: |
102-
pip3 install -r requirements.txt
103-
# Using --no-deps here to make sure correct version of PyTorch Core
104-
pip3 install --pre torchdata -f "https://download.pytorch.org/whl/${{ needs.get_release_type.outputs.type }}/cpu/torch_${{ needs.get_release_type.outputs.type }}.html" --no-deps
105-
pushd ~
106-
RELEASE_COMMIT=$(python -c 'import torchdata; print(torchdata.version.git_version)')
107-
echo "::set-output name=hash::$RELEASE_COMMIT"
108-
popd
109-
pip3 uninstall -y torchdata
110-
id: release_commit
111-
- name: Get Hash of the Last Commit from Source
112-
if: |
113-
needs.get_release_type.outputs.type == 'nightly' ||
114-
needs.get_release_type.outputs.type == 'test'
115-
run: |
116-
SOURCE_COMMIT=$(git rev-parse HEAD)
117-
echo "::set-output name=hash::$SOURCE_COMMIT"
118-
id: source_commit
119-
- name: Check if Build New TorchData Wheel
120-
run: |
121-
if [[ ${{ needs.get_release_type.outputs.type }} == 'official' || ( ${{ steps.release_commit.outputs.hash }} != ${{ steps.source_commit.outputs.hash }} ) ]]; then
122-
echo 1 > torchdata_${{ matrix.os }}_${{ matrix.python-version }}_whl.txt
123-
echo "::set-output name=value::true"
124-
else
125-
echo 0 > torchdata_${{ matrix.os }}_${{ matrix.python-version }}_whl.txt
126-
echo "::set-output name=value::false"
127-
fi
128-
id: trigger_build
129-
# The following steps for pre-release will be skipped if the last commit
130-
# from branch is the same as the last commit in release wheel
131-
- name: Build and Install TorchData Wheel
132-
if: steps.trigger_build.outputs.value == 'true'
78+
- name: Install PyTorch and Build TorchData Wheel
79+
shell: bash
13380
env:
81+
PYTHON_VERSION: ${{ matrix.python-version }}
13482
PYTORCH_VERSION: ${{ inputs.pytorch_version }}
135-
run: |
136-
pip3 install wheel
137-
if [[ ${{ needs.get_release_type.outputs.type }} == 'nightly' ]]; then
138-
python setup.py bdist_wheel --nightly
139-
else
140-
python setup.py bdist_wheel --release
141-
fi
142-
pip3 install dist/torchdata*.whl
83+
run: packaging/build_wheel.sh
84+
- name: Install TorchData Wheel
85+
shell: bash
86+
run: pip3 install dist/torchdata*.whl
14387
- name: Validate TorchData Wheel
144-
if: steps.trigger_build.outputs.value == 'true'
88+
shell: bash
14589
run: |
14690
pip3 install pkginfo
14791
for pkg in dist/torchdata*.whl; do
14892
echo "PkgInfo of $pkg:"
14993
pkginfo $pkg
15094
done
15195
- name: Install Test Requirements
152-
if: steps.trigger_build.outputs.value == 'true'
15396
run: pip3 install expecttest fsspec iopath==0.1.9 numpy pytest rarfile
15497
- name: Run DataPipes Tests with pytest
155-
if: steps.trigger_build.outputs.value == 'true'
15698
run:
15799
pytest --no-header -v test --ignore=test/test_period.py --ignore=test/test_text_examples.py
158100
--ignore=test/test_audio_examples.py
159-
- name: Upload Wheel and Flag File to Github # Flag File is used to prevent no-file error for download-artifact
101+
- name: Upload Wheels to Github
160102
uses: actions/upload-artifact@v2
161103
with:
162104
name: torchdata-artifact
163-
path: |
164-
dist/torchdata*.whl
165-
torchdata_*_whl.txt
105+
path: dist/torchdata*.whl
166106

167-
upload_wheel:
168-
needs: [get_release_type, build_test]
107+
wheel_upload:
108+
if: always() && ${{ needs.get_release_type.outputs.type }}
109+
needs: [get_release_type, wheel_build_test]
169110
runs-on: ubuntu-latest
170-
container: continuumio/miniconda3
111+
outputs:
112+
upload: ${{ steps.trigger_upload.outputs.value }}
171113
steps:
172-
- name: Download Wheels from Github
114+
- name: Download Artifacts from Github
115+
continue-on-error: true
173116
uses: actions/download-artifact@v2
174117
with:
175118
name: torchdata-artifact
176-
- name: Determine if Uploading is needed
119+
- name: Determine if Wheel Uploading is needed
177120
run: |
178121
upload=false
179-
for txt in torchdata_*_whl.txt; do
180-
v=`cat $txt`
181-
if [ $v -eq 1 ]; then
182-
upload=true
183-
break
184-
fi
122+
for txt in torchdata*.whl; do
123+
upload=true
124+
break
185125
done
186126
echo "::set-output name=value::$upload"
187127
id: trigger_upload
188128
- name: Display All TorchData Wheels
189129
if: steps.trigger_upload.outputs.value == 'true'
190-
run: ls -lh
191-
working-directory: dist
192-
- name: Upload Wheels to S3 Storage (Nightly or RC)
193-
if: |
194-
steps.trigger_upload.outputs.value == 'true' &&
195-
( needs.get_release_type.outputs.type == 'nightly' ||
196-
needs.get_release_type.outputs.type == 'test' )
130+
run: ls -lh torchdata*.whl
131+
- name: Upload Wheels to S3 Storage
132+
if: steps.trigger_upload.outputs.value == 'true'
197133
env:
198134
AWS_ACCESS_KEY_ID: ${{ secrets.PYTORCH_BINARY_AWS_ACCESS_KEY_ID }}
199135
AWS_SECRET_ACCESS_KEY: ${{ secrets.PYTORCH_BINARY_AWS_SECRET_ACCESS_KEY }}
@@ -205,7 +141,7 @@ jobs:
205141
fi
206142
pip3 install awscli
207143
set -x
208-
for pkg in dist/torchdata*.whl; do
144+
for pkg in torchdata*.whl; do
209145
aws s3 cp "$pkg" "$S3_PATH" --acl public-read
210146
done
211147
- name: Upload Official Wheels to PYPI
@@ -220,25 +156,91 @@ jobs:
220156
--username __token__ \
221157
--password "$PYPI_TOKEN" \
222158
dist/torchdata*.whl
223-
- name: Upload Wheels to Conda (Nightly or Official)
224-
if: |
225-
steps.trigger_upload.outputs.value == 'true' &&
226-
( needs.get_release_type.outputs.type == 'nightly' ||
227-
needs.get_release_type.outputs.type == 'official' )
159+
160+
conda_build_test:
161+
if: ${{ needs.get_release_type.outputs.type }}
162+
needs: get_release_type
163+
runs-on: ${{ matrix.os }}
164+
strategy:
165+
fail-fast: false
166+
matrix:
167+
os:
168+
- macos-latest
169+
- ubuntu-latest
170+
- windows-latest
171+
python-version:
172+
- 3.7
173+
- 3.8
174+
- 3.9
175+
- "3.10"
176+
steps:
177+
- name: Create Conda Env
178+
uses: conda-incubator/setup-miniconda@v2
179+
with:
180+
python-version: ${{ matrix.python-version }}
181+
activate-environment: conda_build_env
182+
- name: Checkout Source Repository
183+
uses: actions/checkout@v2
184+
with:
185+
ref: ${{ inputs.branch }}
186+
- name: Build TorchData for Conda
187+
shell: bash -l {0}
188+
env:
189+
PYTHON_VERSION: ${{ matrix.python-version }}
190+
PYTORCH_VERSION: ${{ inputs.pytorch_version }}
191+
run: |
192+
conda activate conda_build_env
193+
conda install -yq conda-build -c conda-forge
194+
packaging/build_conda.sh
195+
- name: Upload Conda Package to Github
196+
uses: actions/upload-artifact@v2
197+
with:
198+
name: torchdata-artifact
199+
path: conda-bld/*/torchdata-*.tar.bz2
200+
201+
conda_upload:
202+
if: always() && ${{ needs.get_release_type.outputs.type }}
203+
needs: [get_release_type, conda_build_test]
204+
runs-on: ubuntu-latest
205+
container: continuumio/miniconda3
206+
outputs:
207+
upload: ${{ steps.trigger_upload.outputs.value }}
208+
steps:
209+
- name: Download Artifacts from Github
210+
continue-on-error: true
211+
uses: actions/download-artifact@v2
212+
with:
213+
name: torchdata-artifact
214+
- name: Determine if Conda Uploading is needed
215+
run: |
216+
upload=false
217+
for pkg in ./*/torchdata-*.tar.bz2; do
218+
upload=true
219+
break
220+
done
221+
echo "::set-output name=value::$upload"
222+
id: trigger_upload
223+
- name: Display All TorchData Conda Package
224+
if: steps.trigger_upload.outputs.value == 'true'
225+
run: ls -lh ./*/torchdata-*.tar.bz2
226+
- name: Build & Upload Wheels to Conda
227+
if: steps.trigger_upload.outputs.value == 'true'
228+
shell: bash
228229
env:
229230
CONDA_PYTORCHBOT_TOKEN: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
230231
run: |
231232
conda install -yq anaconda-client
232-
if [ ${{ needs.get_release_type.outputs.type }} == nightly ]; then
233-
CONDA_CHANNEL=pytorch-nightly
234-
else
233+
if [[ ${{ needs.get_release_type.outputs.type }} == 'official' ]]; then
235234
CONDA_CHANNEL=pytorch
235+
else
236+
CONDA_CHANNEL=pytorch-${{ needs.get_release_type.outputs.type }}
236237
fi
237238
set -x
238-
# anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload dist/*tar.bz2 -u "$CONDA_CHANNEL" --label main --no-progress --force
239+
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ./*/torchdata-*.tar.bz2 -u "$CONDA_CHANNEL" --label main --no-progress --force
239240
240241
build_docs:
241-
needs: [get_release_type, build_test]
242+
if: always() && ( needs.wheel_upload.outputs.upload == 'true' || needs.conda_upload.outputs.upload == 'true' )
243+
needs: [get_release_type, wheel_upload, conda_upload]
242244
runs-on: ubuntu-latest
243245
steps:
244246
- name: Setup Python 3.8
@@ -257,35 +259,31 @@ jobs:
257259
python3 -m pip install setuptools
258260
python3 -m pip install matplotlib
259261
sudo apt-get install -y yarn
260-
- name: Install Pre-release/Nightly-release/Official-release PyTorch
262+
- name: Install PyTorch & TorchData
261263
run: |
262264
pip3 install numpy
263265
# Add version requirement to PyTorch except nightly release
264-
if [[ ${{ inputs.pytorch_version }} ]]; then
265-
PYTORCH_VERSION=torch==${{ inputs.pytorch_version }}
266-
else
266+
if [[ -z "${{ inputs.pytorch_version }}" ]]; then
267267
PYTORCH_VERSION=torch
268+
else
269+
PYTORCH_VERSION=torch==${{ inputs.pytorch_version }}
268270
fi
269271
270272
PIP_CHANNEL=${{ needs.get_release_type.outputs.type }}
271-
272273
if [[ $PIP_CHANNEL == 'official' ]]; then
273-
pip3 install "$PYTORCH_VERSION"
274+
pip3 install "$PYTORCH_VERSION" -f https://download.pytorch.org/whl/torch_stable.html
274275
else
275-
pip3 install --pre "$PYTORCH_VERSION" -f "https://download.pytorch.org/whl/$PIP_CHANNEL/cpu/torch_$PIP_CHANNEL.html"
276+
pip3 install --pre "$PYTORCH_VERSION" -f "https://download.pytorch.org/whl/$PIP_CHANNEL/torch_$PIP_CHANNEL.html"
276277
fi
277278
278-
if [[ ${{ needs.get_release_type.outputs.type }} == 'nightly' ]]; then
279-
python setup.py install --nightly
280-
else
281-
python setup.py install --release
282-
fi
279+
pip3 install -r requirements.txt
280+
python3 setup.py install
283281
- name: Check env
284282
run: echo `which spinx-build`
285283
- name: Build the docset
286284
run: |
287285
cd ./docs
288-
pip install -r requirements.txt
286+
pip3 install -r requirements.txt
289287
make html
290288
cd ..
291289
- name: Export Target Folder

.github/workflows/nightly_release.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
name: Push Nightly Release
22

33
on:
4-
# [ Note: Manually Trigger the Workflow ]
5-
# 1. Go to Actions under pytorch/data repo
6-
# 2. In the left sidebar, click the workflow you want to run
7-
# 3. Above the list of workflow runs, select Run workflow
8-
# 4. Use the Branch dropdown to select the release/* branch
9-
# 5. Click Run workflow
10-
workflow_dispatch:
11-
# TODO: Automatically trigger nightly release
12-
# schedule:
13-
# - cron: 30 23 * * *
4+
schedule:
5+
- cron: 30 23 * * *
146

157
jobs:
168
build_test_upload:
179
uses: ./.github/workflows/_build_test_upload.yml
1810
with:
19-
branch: ""
11+
branch: "main"
2012
pre_dev_release: true
2113
pytorch_version: ""
2214
secrets:
2315
PYTORCH_BINARY_AWS_ACCESS_KEY_ID: ${{ secrets.PYTORCH_BINARY_AWS_ACCESS_KEY_ID }}
2416
PYTORCH_BINARY_AWS_SECRET_ACCESS_KEY: ${{ secrets.PYTORCH_BINARY_AWS_SECRET_ACCESS_KEY }}
17+
CONDA_PYTORCHBOT_TOKEN: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}

0 commit comments

Comments
 (0)