From f3b3ae4b57832c14a81eef6d4ecdb3d2475a0c5e Mon Sep 17 00:00:00 2001
From: atalman <atalman@fb.com>
Date: Wed, 23 Aug 2023 13:52:00 -0700
Subject: [PATCH 1/2] Add torchonly option to validation workflows

---
 .github/scripts/validate_binaries.sh              |  9 +++++++--
 .../workflows/validate-aarch64-linux-binaries.yml | 11 +++++++++++
 .github/workflows/validate-binaries.yml           | 15 +++++++++++++++
 .github/workflows/validate-linux-binaries.yml     | 11 +++++++++++
 .../workflows/validate-macos-arm64-binaries.yml   | 11 +++++++++++
 .github/workflows/validate-macos-binaries.yml     | 11 +++++++++++
 .github/workflows/validate-windows-binaries.yml   | 11 +++++++++++
 7 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/.github/scripts/validate_binaries.sh b/.github/scripts/validate_binaries.sh
index e1d0ec75b..a40648012 100755
--- a/.github/scripts/validate_binaries.sh
+++ b/.github/scripts/validate_binaries.sh
@@ -6,6 +6,11 @@ else
     conda create -y -n ${ENV_NAME} python=${MATRIX_PYTHON_VERSION} numpy ffmpeg
     conda activate ${ENV_NAME}
     INSTALLATION=${MATRIX_INSTALLATION/"conda install"/"conda install -y"}
+    TEST_SUFFIX=""
+    if [[ ${TORCHONLY} == 'true' ]]; then
+        INSTALLATION=${INSTALLATION/"torchvision torchaudio"/""}
+        TEST_SUFFIX=" --package torchonly"
+    fi
 
     export OLD_PATH=${PATH}
     # Workaround macos-arm64 runners. Issue: https://github.com/pytorch/test-infra/issues/4342
@@ -26,11 +31,11 @@ else
     fi
 
     if [[ ${TARGET_OS} == 'windows' ]]; then
-        python  ./test/smoke_test/smoke_test.py
+        python  ./test/smoke_test/smoke_test.py ${TEST_SUFFIX}
     elif [[ ${TARGET_OS} == 'linux-aarch64'  ]]; then
         python3  ./test/smoke_test/smoke_test.py  --package=torchonly
     else
-        python3  ./test/smoke_test/smoke_test.py
+        python3  ./test/smoke_test/smoke_test.py ${TEST_SUFFIX}
     fi
 
     if [[ ${TARGET_OS} == 'macos-arm64' ]]; then
diff --git a/.github/workflows/validate-aarch64-linux-binaries.yml b/.github/workflows/validate-aarch64-linux-binaries.yml
index 4b1f06720..92b5e48ea 100644
--- a/.github/workflows/validate-aarch64-linux-binaries.yml
+++ b/.github/workflows/validate-aarch64-linux-binaries.yml
@@ -12,6 +12,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
   workflow_dispatch:
     inputs:
       channel:
@@ -28,6 +33,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
 
 jobs:
   generate-aarch64-linux-matrix:
@@ -55,6 +65,7 @@ jobs:
         set -ex
         export ENV_NAME="conda-env-${{ github.run_id }}"
         export TARGET_OS="linux-aarch64"
+        export TORCH_ONLY=${{ inputs.torchonly }}
         eval "$(conda shell.bash hook)"
 
         # Standart case: Validate binaries
diff --git a/.github/workflows/validate-binaries.yml b/.github/workflows/validate-binaries.yml
index 7a679a267..9c877f4ed 100644
--- a/.github/workflows/validate-binaries.yml
+++ b/.github/workflows/validate-binaries.yml
@@ -22,6 +22,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
   workflow_dispatch:
     inputs:
       os:
@@ -50,6 +55,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
 
 jobs:
   win:
@@ -58,6 +68,7 @@ jobs:
     with:
       channel: ${{ inputs.channel }}
       ref: ${{ inputs.ref || github.ref }}
+      torchonly: ${{ inputs.torchonly }}
 
   linux:
     if:  inputs.os == 'linux' || inputs.os == 'all'
@@ -65,6 +76,7 @@ jobs:
     with:
       channel: ${{ inputs.channel }}
       ref: ${{ inputs.ref || github.ref }}
+      torchonly: ${{ inputs.torchonly }}
 
   linux-aarch64:
     if:  inputs.os == 'linux-aarch64'
@@ -72,6 +84,7 @@ jobs:
     with:
       channel: ${{ inputs.channel }}
       ref: ${{ inputs.ref || github.ref }}
+      torchonly: ${{ inputs.torchonly }}
 
   mac:
     if:  inputs.os == 'macos' || inputs.os == 'all'
@@ -79,6 +92,7 @@ jobs:
     with:
       channel: ${{ inputs.channel }}
       ref: ${{ inputs.ref || github.ref }}
+      torchonly: ${{ inputs.torchonly }}
 
   mac-arm64:
     if:  inputs.os == 'macos' || inputs.os == 'all'
@@ -86,3 +100,4 @@ jobs:
     with:
       channel: ${{ inputs.channel }}
       ref: ${{ inputs.ref || github.ref }}
+      torchonly: ${{ inputs.torchonly }}
diff --git a/.github/workflows/validate-linux-binaries.yml b/.github/workflows/validate-linux-binaries.yml
index 13d980488..937f0e95f 100644
--- a/.github/workflows/validate-linux-binaries.yml
+++ b/.github/workflows/validate-linux-binaries.yml
@@ -12,6 +12,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
   workflow_dispatch:
     inputs:
       channel:
@@ -28,6 +33,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
 
 jobs:
   generate-linux-matrix:
@@ -53,6 +63,7 @@ jobs:
       script: |
         set -ex
         export ENV_NAME="conda-env-${{ github.run_id }}"
+        export TORCH_ONLY=${{ inputs.torchonly }}
         export TARGET_OS="linux"
         eval "$(conda shell.bash hook)"
 
diff --git a/.github/workflows/validate-macos-arm64-binaries.yml b/.github/workflows/validate-macos-arm64-binaries.yml
index f321022d4..f23dec3f6 100644
--- a/.github/workflows/validate-macos-arm64-binaries.yml
+++ b/.github/workflows/validate-macos-arm64-binaries.yml
@@ -12,6 +12,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
   workflow_dispatch:
     inputs:
       channel:
@@ -28,6 +33,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
 
 jobs:
   generate-macos-arm64-matrix:
@@ -53,4 +63,5 @@ jobs:
         set -ex
         export ENV_NAME="conda-env-${{ github.run_id }}"
         export TARGET_OS="macos-arm64"
+        export TORCH_ONLY=${{ inputs.torchonly }}
         source ./.github/scripts/validate_binaries.sh
diff --git a/.github/workflows/validate-macos-binaries.yml b/.github/workflows/validate-macos-binaries.yml
index 0e3f38ff8..0926dbe93 100644
--- a/.github/workflows/validate-macos-binaries.yml
+++ b/.github/workflows/validate-macos-binaries.yml
@@ -12,6 +12,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
   workflow_dispatch:
     inputs:
       channel:
@@ -28,6 +33,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
 
 jobs:
   generate-macos-matrix:
@@ -53,4 +63,5 @@ jobs:
         set -ex
         export ENV_NAME="conda-env-${{ github.run_id }}"
         export TARGET_OS="macos"
+        export TORCH_ONLY=${{ inputs.torchonly }}
         source ./.github/scripts/validate_binaries.sh
diff --git a/.github/workflows/validate-windows-binaries.yml b/.github/workflows/validate-windows-binaries.yml
index 463626c5a..96d2b281e 100644
--- a/.github/workflows/validate-windows-binaries.yml
+++ b/.github/workflows/validate-windows-binaries.yml
@@ -12,6 +12,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
   workflow_dispatch:
     inputs:
       channel:
@@ -28,6 +33,11 @@ on:
         default: ""
         required: false
         type: string
+      torchonly:
+        description: 'Validate torchonly'
+        default: false
+        required: false
+        type: boolean
 
 jobs:
   generate-windows-matrix:
@@ -55,6 +65,7 @@ jobs:
         set -ex
         export ENV_NAME="conda-env-${{ github.run_id }}"
         export TARGET_OS="windows"
+        export TORCH_ONLY=${{ inputs.torchonly }}
         source /c/Jenkins/Miniconda3/etc/profile.d/conda.sh
         if [[ ${MATRIX_GPU_ARCH_VERSION} == "12.1" ]]; then
           ./windows/internal/driver_update.bat

From 65e64b6b14564a5670d0da6b6c3f095d29366ecd Mon Sep 17 00:00:00 2001
From: atalman <atalman@fb.com>
Date: Wed, 23 Aug 2023 13:57:01 -0700
Subject: [PATCH 2/2] fix typo

---
 .github/scripts/validate_binaries.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/scripts/validate_binaries.sh b/.github/scripts/validate_binaries.sh
index a40648012..6b4bccd6b 100755
--- a/.github/scripts/validate_binaries.sh
+++ b/.github/scripts/validate_binaries.sh
@@ -7,7 +7,7 @@ else
     conda activate ${ENV_NAME}
     INSTALLATION=${MATRIX_INSTALLATION/"conda install"/"conda install -y"}
     TEST_SUFFIX=""
-    if [[ ${TORCHONLY} == 'true' ]]; then
+    if [[ ${TORCH_ONLY} == 'true' ]]; then
         INSTALLATION=${INSTALLATION/"torchvision torchaudio"/""}
         TEST_SUFFIX=" --package torchonly"
     fi