Skip to content

Commit 01f9dc0

Browse files
committed
Add test job on Windows.
1 parent d896211 commit 01f9dc0

File tree

1 file changed

+140
-76
lines changed

1 file changed

+140
-76
lines changed

.github/workflows/windows_wheel.yaml

Lines changed: 140 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -61,83 +61,147 @@ jobs:
6161
# set in vc_env_helper.bat Couldn't find a way to set it from here.
6262
build-command: "python -m build --wheel -vvv --no-isolation"
6363

64-
install-and-test:
65-
runs-on: windows-latest
64+
# install-and-test:
65+
# runs-on: windows-latest
66+
# strategy:
67+
# fail-fast: false
68+
# matrix:
69+
# python-version: ['3.9']
70+
# ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1']
71+
# needs: build
72+
# steps:
73+
# - uses: actions/download-artifact@v4
74+
# with:
75+
# name: pytorch_torchcodec__${{ matrix.python-version }}_cpu_x64
76+
# path: pytorch/torchcodec/dist/
77+
# - name: Setup conda env
78+
# uses: conda-incubator/setup-miniconda@v2
79+
# with:
80+
# auto-update-conda: true
81+
# miniconda-version: "latest"
82+
# activate-environment: test
83+
# python-version: ${{ matrix.python-version }}
84+
# - name: Update pip
85+
# run: python -m pip install --upgrade pip
86+
# - name: Install PyTorch
87+
# run: |
88+
# python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
89+
# - name: Install torchcodec from the wheel
90+
# run: |
91+
# wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"`
92+
# echo Installing $wheel_path
93+
# python -m pip install $wheel_path -vvv
94+
# - name: Check out repo
95+
# uses: actions/checkout@v3
96+
# - name: Install ffmpeg, post build
97+
# run: |
98+
# # Ideally we would have checked for that before installing the wheel,
99+
# # but we need to checkout the repo to access this file, and we don't
100+
# # want to checkout the repo before installing the wheel to avoid any
101+
# # side-effect. It's OK.
102+
# source packaging/helpers.sh
103+
# assert_ffmpeg_not_installed
104+
# conda install "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" -c conda-forge
105+
# ffmpeg -version
106+
# # On Windows, ensure the conda Library/bin directory is in PATH
107+
# # This is needed for Windows DLL loading to find FFmpeg DLLs
108+
# if [[ "$RUNNER_OS" == "Windows" ]]; then
109+
# conda_env_path=$(conda info --base)/envs/test
110+
# library_bin_path="$conda_env_path/Library/bin"
111+
# echo "Adding conda Library/bin to PATH: $library_bin_path"
112+
# echo "$library_bin_path" >> $GITHUB_PATH
113+
# # Verify FFmpeg DLLs are accessible
114+
# echo "Checking if FFmpeg DLLs are in PATH:"
115+
# where avutil.dll || echo "avutil.dll not found in PATH"
116+
# where avcodec.dll || echo "avcodec.dll not found in PATH"
117+
# where avformat.dll || echo "avformat.dll not found in PATH"
118+
# fi
119+
# - name: Test torchcodec import after FFmpeg installation
120+
# run: |
121+
# echo "Testing torchcodec import after FFmpeg is installed and PATH is updated..."
122+
# python -c "import torchcodec; print('TorchCodec import successful!')"
123+
# - name: Install test dependencies
124+
# run: |
125+
# # Ideally we would find a way to get those dependencies from pyproject.toml
126+
# python -m pip install numpy pytest pillow
127+
# - name: Delete the src/ folder just for fun
128+
# run: |
129+
# # The only reason we checked-out the repo is to get access to the
130+
# # tests. We don't care about the rest. Out of precaution, we delete
131+
# # the src/ folder to be extra sure that we're running the code from
132+
# # the installed wheel rather than from the source.
133+
# # This is just to be extra cautious and very overkill because a)
134+
# # there's no way the `torchcodec` package from src/ can be found from
135+
# # the PythonPath: the main point of `src/` is precisely to protect
136+
# # against that and b) if we ever were to execute code from
137+
# # `src/torchcodec`, it would fail loudly because the built .so files
138+
# # aren't present there.
139+
# rm -r src/
140+
# ls
141+
# - name: Run Python tests
142+
# run: |
143+
# pytest test -vvv
144+
145+
install-and-test-on-test-infra:
66146
strategy:
67-
fail-fast: false
68147
matrix:
69-
python-version: ['3.9']
148+
python-version:
149+
- "3.9"
150+
# - "3.10"
151+
# - "3.11"
152+
# - "3.12"
153+
runner: ["windows.4xlarge"]
154+
gpu-arch-type: ["cpu"]
70155
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1']
156+
# TODO: put GPU testing back
157+
# include:
158+
# - python-version: "3.9"
159+
# runner: windows.g5.4xlarge.nvidia.gpu
160+
# gpu-arch-type: cuda
161+
# gpu-arch-version: "11.8"
162+
fail-fast: false
71163
needs: build
72-
steps:
73-
- uses: actions/download-artifact@v4
74-
with:
75-
name: pytorch_torchcodec__${{ matrix.python-version }}_cpu_x64
76-
path: pytorch/torchcodec/dist/
77-
- name: Setup conda env
78-
uses: conda-incubator/setup-miniconda@v2
79-
with:
80-
auto-update-conda: true
81-
miniconda-version: "latest"
82-
activate-environment: test
83-
python-version: ${{ matrix.python-version }}
84-
- name: Update pip
85-
run: python -m pip install --upgrade pip
86-
- name: Install PyTorch
87-
run: |
88-
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
89-
- name: Install torchcodec from the wheel
90-
run: |
91-
wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"`
92-
echo Installing $wheel_path
93-
python -m pip install $wheel_path -vvv
94-
- name: Check out repo
95-
uses: actions/checkout@v3
96-
- name: Install ffmpeg, post build
97-
run: |
98-
# Ideally we would have checked for that before installing the wheel,
99-
# but we need to checkout the repo to access this file, and we don't
100-
# want to checkout the repo before installing the wheel to avoid any
101-
# side-effect. It's OK.
102-
source packaging/helpers.sh
103-
assert_ffmpeg_not_installed
104-
conda install "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" -c conda-forge
105-
ffmpeg -version
106-
# On Windows, ensure the conda Library/bin directory is in PATH
107-
# This is needed for Windows DLL loading to find FFmpeg DLLs
108-
if [[ "$RUNNER_OS" == "Windows" ]]; then
109-
conda_env_path=$(conda info --base)/envs/test
110-
library_bin_path="$conda_env_path/Library/bin"
111-
echo "Adding conda Library/bin to PATH: $library_bin_path"
112-
echo "$library_bin_path" >> $GITHUB_PATH
113-
# Verify FFmpeg DLLs are accessible
114-
echo "Checking if FFmpeg DLLs are in PATH:"
115-
where avutil.dll || echo "avutil.dll not found in PATH"
116-
where avcodec.dll || echo "avcodec.dll not found in PATH"
117-
where avformat.dll || echo "avformat.dll not found in PATH"
118-
fi
119-
- name: Test torchcodec import after FFmpeg installation
120-
run: |
121-
echo "Testing torchcodec import after FFmpeg is installed and PATH is updated..."
122-
python -c "import torchcodec; print('TorchCodec import successful!')"
123-
- name: Install test dependencies
124-
run: |
125-
# Ideally we would find a way to get those dependencies from pyproject.toml
126-
python -m pip install numpy pytest pillow
127-
- name: Delete the src/ folder just for fun
128-
run: |
129-
# The only reason we checked-out the repo is to get access to the
130-
# tests. We don't care about the rest. Out of precaution, we delete
131-
# the src/ folder to be extra sure that we're running the code from
132-
# the installed wheel rather than from the source.
133-
# This is just to be extra cautious and very overkill because a)
134-
# there's no way the `torchcodec` package from src/ can be found from
135-
# the PythonPath: the main point of `src/` is precisely to protect
136-
# against that and b) if we ever were to execute code from
137-
# `src/torchcodec`, it would fail loudly because the built .so files
138-
# aren't present there.
139-
rm -r src/
140-
ls
141-
- name: Run Python tests
142-
run: |
143-
pytest test -vvv
164+
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
165+
permissions:
166+
id-token: write
167+
contents: read
168+
with:
169+
repository: pytorch/torchcodec
170+
runner: ${{ matrix.runner }}
171+
gpu-arch-type: ${{ matrix.gpu-arch-type }}
172+
gpu-arch-version: ${{ matrix.gpu-arch-version }}
173+
timeout: 120
174+
test-infra-ref: main
175+
script: |
176+
set -euxo pipefail
177+
178+
export PYTHON_VERSION=${{ matrix.python-version }}
179+
export VC_YEAR=2022
180+
export VSDEVCMD_ARGS=""
181+
export GPU_ARCH_TYPE=${{ matrix.gpu-arch-type }}
182+
export GPU_ARCH_VERSION=${{ matrix.gpu-arch-version }}
183+
export FFMPEG_VERSION_FOR_TESTS=${{ matrix.ffmpeg-version-for-tests }}
184+
185+
# Download and install wheel
186+
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
187+
wheel_path=$(find pytorch/torchcodec/dist -type f -name "*${{ matrix.python-version }}*.whl" | head -1)
188+
echo "Installing $wheel_path"
189+
python -m pip install "$wheel_path" -vvv
190+
191+
# Install FFmpeg and test dependencies
192+
conda install "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" -c conda-forge
193+
conda_env_path=$(conda info --base)/envs/test
194+
library_bin_path="$conda_env_path/Library/bin"
195+
echo "$library_bin_path" >> $GITHUB_PATH
196+
197+
# Install test dependencies
198+
python -m pip install numpy pytest pillow
199+
200+
# Test torchcodec import
201+
python -c "import torchcodec; print('TorchCodec import successful!')"
202+
203+
# Remove source to ensure testing against wheel
204+
rm -rf src/
205+
206+
# Run tests
207+
pytest test -vvv

0 commit comments

Comments
 (0)