Skip to content

Commit 35f0146

Browse files
committed
Use MATRIX_* variables instead of redeefining new var each time
1 parent 2a3f8b8 commit 35f0146

9 files changed

+41
-82
lines changed

.github/scripts/validate_binaries.sh

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
1-
#!/usr/bin/env bash
2-
set -ex
3-
4-
if [[ ${TARGET_OS} == 'windows' ]]; then
5-
source /c/Jenkins/Miniconda3/etc/profile.d/conda.sh
6-
else
7-
eval "$(conda shell.bash hook)"
8-
fi
9-
10-
if [[ ${PACKAGE_TYPE} == "libtorch" ]]; then
11-
curl ${INSTALLATION} -o libtorch.zip
1+
if [[ ${MATRIX_PACKAGE_TYPE} == "libtorch" ]]; then
2+
curl ${MATRIX_INSTALLATION} -o libtorch.zip
123
unzip libtorch.zip
134
else
14-
if [ $DESIRED_PYTHON == '3.11' ]; then
5+
if [ $MATRIX_PYTHON_VERSION == '3.11' ]; then
156
export CPYTHON_VERSIONS=3.11.0
167
sudo yum -y install openssl-devel libssl-dev bzip2-devel libffi-devel
178
sudo yum -y groupinstall "Development Tools"
189
export PYTHON_PATH="/opt/_internal/cpython-3.11.0/bin"
1910
export PIP_PATH="${PYTHON_PATH}/pip"
20-
export PIP_INSTALLATION="${INSTALLATION/pip3/"$PIP_PATH"}"
11+
export PIP_INSTALLATION="${MATRIX_INSTALLATION/pip3/"$PIP_PATH"}"
2112
export WITH_OPENSSL="/opt/openssl"
2213
./common/install_cpython.sh
2314
eval ${PYTHON_PATH}/python --version
2415
eval ${PIP_INSTALLATION}
2516
eval ${PYTHON_PATH}/python ./test/smoke_test/smoke_test.py --package torchonly
2617
else
27-
conda create -y -n ${ENV_NAME} python=${DESIRED_PYTHON} numpy pillow
18+
conda create -y -n ${ENV_NAME} python=${MATRIX_PYTHON_VERSION} numpy pillow
2819
conda activate ${ENV_NAME}
29-
export CONDA_LIBRARY_PATH="$(dirname $(which python))/../lib"
30-
export LD_LIBRARY_PATH=$CONDA_LIBRARY_PATH:$LD_LIBRARY_PATH
31-
INSTALLATION=${INSTALLATION/"conda install"/"conda install -y"}
20+
INSTALLATION=${MATRIX_INSTALLATION/"conda install"/"conda install -y"}
3221
eval $INSTALLATION
33-
python ./test/smoke_test/smoke_test.py
34-
if [[ ${TARGET_OS} != 'macos' && ${TARGET_OS} != 'windows' ]]; then
22+
23+
if [[ ${TARGET_OS} == 'linux' ]]; then
24+
export CONDA_LIBRARY_PATH="$(dirname $(which python))/../lib"
25+
export LD_LIBRARY_PATH=$CONDA_LIBRARY_PATH:$LD_LIBRARY_PATH
3526
${PWD}/check_binary.sh
3627
fi
28+
29+
python ./test/smoke_test/smoke_test.py
3730
fi
3831
fi

.github/workflows/validate-domain-library.yml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,7 @@ jobs:
8989
script: |
9090
set -ex
9191
export ENV_NAME="conda-env-${{ github.run_id }}"
92-
export DESIRED_PYTHON="${{ matrix.python_version }}"
93-
export PACKAGE_TYPE="${{ matrix.package_type }}"
94-
export CHANNEL="${{ matrix.channel }}"
9592
export SMOKE_TEST="${{ inputs.smoke_test }}"
96-
export GPU_ARCH_VER="${{ matrix.gpu_arch_version }}"
97-
export GPU_ARCH_TYPE="${{ matrix.gpu_arch_type }}"
98-
export DESIRED_CUDA="${{ matrix.desired_cuda }}"
9993
eval $SMOKE_TEST
10094
validate-windows:
10195
if: (inputs.os == 'windows' || inputs.os == 'all')
@@ -113,13 +107,7 @@ jobs:
113107
script: |
114108
set -ex
115109
export ENV_NAME="conda-env-${{ github.run_id }}"
116-
export DESIRED_PYTHON="${{ matrix.python_version }}"
117-
export PACKAGE_TYPE="${{ matrix.package_type }}"
118-
export CHANNEL="${{ matrix.channel }}"
119110
export SMOKE_TEST="${{ inputs.smoke_test }}"
120-
export GPU_ARCH_VER="${{ matrix.gpu_arch_version }}"
121-
export GPU_ARCH_TYPE="${{ matrix.gpu_arch_type }}"
122-
export DESIRED_CUDA="${{ matrix.desired_cuda }}"
123111
export TARGET_OS="windows"
124112
eval $SMOKE_TEST
125113
validate-macos:
@@ -138,13 +126,8 @@ jobs:
138126
script: |
139127
set -ex
140128
export ENV_NAME="conda-env-${{ github.run_id }}"
141-
export DESIRED_PYTHON="${{ matrix.python_version }}"
142-
export PACKAGE_TYPE="${{ matrix.package_type }}"
143-
export CHANNEL="${{ matrix.channel }}"
129+
export TARGET_OS="macos"
144130
export SMOKE_TEST="${{ inputs.smoke_test }}"
145-
export GPU_ARCH_VER="${{ matrix.gpu_arch_version }}"
146-
export GPU_ARCH_TYPE="${{ matrix.gpu_arch_type }}"
147-
export DESIRED_CUDA="${{ matrix.desired_cuda }}"
148131
eval $SMOKE_TEST
149132
validate-macos-arm64:
150133
if: (inputs.os == 'macos-arm64' || inputs.os == 'all')
@@ -162,11 +145,5 @@ jobs:
162145
script: |
163146
set -ex
164147
export ENV_NAME="conda-env-${{ github.run_id }}"
165-
export DESIRED_PYTHON="${{ matrix.python_version }}"
166-
export PACKAGE_TYPE="${{ matrix.package_type }}"
167-
export CHANNEL="${{ matrix.channel }}"
168-
export SMOKE_TEST="${{ inputs.smoke_test }}"
169-
export GPU_ARCH_VER="${{ matrix.gpu_arch_version }}"
170-
export GPU_ARCH_TYPE="${{ matrix.gpu_arch_type }}"
171-
export DESIRED_CUDA="${{ matrix.desired_cuda }}"
148+
export TARGET_OS="macos-arm64"
172149
eval $SMOKE_TEST

.github/workflows/validate-linux-binaries.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,10 @@ jobs:
5050
repository: "pytorch/builder"
5151
ref: ${{ inputs.ref || github.ref }}
5252
job-name: ${{ matrix.build_name }}
53+
binary-matrix: ${{ toJSON(matrix) }}
5354
script: |
5455
set -ex
5556
export ENV_NAME="conda-env-${{ github.run_id }}"
56-
export GPU_ARCH_VER="${{ matrix.gpu_arch_version }}"
57-
export GPU_ARCH_TYPE="${{ matrix.gpu_arch_type }}"
58-
export INSTALLATION="${{ matrix.installation }}"
59-
export CUDA_VER="${{ matrix.desired_cuda }}"
60-
export DESIRED_PYTHON="${{ matrix.python_version }}"
61-
export DESIRED_CUDA="${{ matrix.desired_cuda }}"
62-
export DESIRED_DEVTOOLSET="${{ matrix.devtoolset }}"
63-
export PACKAGE_TYPE="${{ matrix.package_type }}"
6457
export TARGET_OS="linux"
65-
./.github/scripts/validate_binaries.sh
58+
eval "$(conda shell.bash hook)"
59+
source ./.github/scripts/validate_binaries.sh

.github/workflows/validate-macos-arm64-binaries.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,9 @@ jobs:
4848
repository: "pytorch/builder"
4949
ref: ${{ inputs.ref || github.ref }}
5050
job-name: ${{ matrix.build_name }}
51+
binary-matrix: ${{ toJSON(matrix) }}
5152
script: |
5253
set -ex
5354
export ENV_NAME="conda-env-${{ github.run_id }}"
54-
export GPU_ARCH_VER="${{ matrix.gpu_arch_version }}"
55-
export GPU_ARCH_TYPE="${{ matrix.gpu_arch_type }}"
56-
export INSTALLATION="${{ matrix.installation }}"
57-
export CUDA_VER="${{ matrix.desired_cuda }}"
58-
export DESIRED_PYTHON="${{ matrix.python_version }}"
59-
export DESIRED_CUDA="${{ matrix.desired_cuda }}"
60-
export PACKAGE_TYPE="${{ matrix.package_type }}"
6155
export TARGET_OS="macos-arm64"
62-
./.github/scripts/validate_binaries.sh
56+
source ./.github/scripts/validate_binaries.sh

.github/workflows/validate-macos-binaries.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,9 @@ jobs:
4848
repository: "pytorch/builder"
4949
ref: ${{ inputs.ref || github.ref }}
5050
job-name: ${{ matrix.build_name }}
51+
binary-matrix: ${{ toJSON(matrix) }}
5152
script: |
5253
set -ex
5354
export ENV_NAME="conda-env-${{ github.run_id }}"
54-
export GPU_ARCH_VER="${{ matrix.gpu_arch_version }}"
55-
export GPU_ARCH_TYPE="${{ matrix.gpu_arch_type }}"
56-
export INSTALLATION="${{ matrix.installation }}"
57-
export CUDA_VER="${{ matrix.desired_cuda }}"
58-
export DESIRED_PYTHON="${{ matrix.python_version }}"
59-
export DESIRED_CUDA="${{ matrix.desired_cuda }}"
60-
export DESIRED_DEVTOOLSET="${{ matrix.devtoolset }}"
61-
export PACKAGE_TYPE="${{ matrix.package_type }}"
6255
export TARGET_OS="macos"
63-
./.github/scripts/validate_binaries.sh
56+
source ./.github/scripts/validate_binaries.sh

.github/workflows/validate-nightly-binaries.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ on:
2424
- .github/workflows/validate-windows-binaries.yml
2525
- .github/workflows/validate-macos-binaries.yml
2626
- .github/workflows/validate-macos-arm64-binaries.yml
27+
- .github/scripts/validate_binaries.sh
2728
- test/smoke_test/*
2829
jobs:
2930
nightly:

.github/workflows/validate-windows-binaries.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,11 @@ jobs:
4949
repository: "pytorch/builder"
5050
ref: ${{ inputs.ref || github.ref }}
5151
job-name: ${{ matrix.build_name }}
52+
binary-matrix: ${{ toJSON(matrix) }}
5253
timeout: 60
5354
script: |
5455
set -ex
5556
export ENV_NAME="conda-env-${{ github.run_id }}"
56-
export GPU_ARCH_VER="${{ matrix.gpu_arch_version }}"
57-
export GPU_ARCH_TYPE="${{ matrix.gpu_arch_type }}"
58-
export INSTALLATION="${{ matrix.installation }}"
59-
export CUDA_VER="${{ matrix.desired_cuda }}"
60-
export DESIRED_PYTHON="${{ matrix.python_version }}"
61-
export DESIRED_CUDA="${{ matrix.desired_cuda }}"
62-
export DESIRED_DEVTOOLSET="${{ matrix.devtoolset }}"
63-
export PACKAGE_TYPE="${{ matrix.package_type }}"
6457
export TARGET_OS="windows"
65-
./.github/scripts/validate_binaries.sh
58+
source /c/Jenkins/Miniconda3/etc/profile.d/conda.sh
59+
source ./.github/scripts/validate_binaries.sh

check_binary.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ set -eux -o pipefail
2222
# libtorch package.
2323

2424

25+
if [[ -z ${DESIRED_PYTHON:-} ]]; then
26+
export DESIRED_PYTHON=${MATRIX_PYTHON_VERSION:-}
27+
fi
28+
if [[ -z ${DESIRED_CUDA:-} ]]; then
29+
export DESIRED_CUDA=${MATRIX_DESIRED_CUDA:-}
30+
fi
31+
if [[ -z ${DESIRED_DEVTOOLSET:-} ]]; then
32+
export DESIRED_DEVTOOLSET=${MATRIX_DESIRED_DEVTOOLSET:-}
33+
fi
34+
if [[ -z ${PACKAGE_TYPE:-} ]]; then
35+
export PACKAGE_TYPE=${MATRIX_PACKAGE_TYPE:-}
36+
fi
37+
2538
# The install root depends on both the package type and the os
2639
# All MacOS packages use conda, even for the wheel packages.
2740
if [[ "$PACKAGE_TYPE" == libtorch ]]; then

test/smoke_test/smoke_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import importlib
99
import subprocess
1010

11-
gpu_arch_ver = os.getenv("GPU_ARCH_VER")
12-
gpu_arch_type = os.getenv("GPU_ARCH_TYPE")
11+
gpu_arch_ver = os.getenv("MATRIX_GPU_ARCH_VERSION")
12+
gpu_arch_type = os.getenv("MATRIX_GPU_ARCH_TYPE")
1313
# use installation env variable to tell if it is nightly channel
14-
installation_str = os.getenv("INSTALLATION")
14+
installation_str = os.getenv("MATRIX_INSTALLATION")
1515
is_cuda_system = gpu_arch_type == "cuda"
1616
SCRIPT_DIR = Path(__file__).parent
1717
NIGHTLY_ALLOWED_DELTA = 3

0 commit comments

Comments
 (0)