Skip to content

Commit

Permalink
Update package smoke test (#3465)
Browse files Browse the repository at this point in the history
Summary:
1. Update smoke test script to change directory so that there is no `torchaudio` directory in CWD when smoke test is being executed.
2. Disable the part of smoke test which requires FFmpeg for wheel. The preparation for pytorch/test-infra#4358

Pull Request resolved: #3465

Reviewed By: nateanl

Differential Revision: D47345117

Pulled By: mthrok

fbshipit-source-id: 95aad0a22922d44ee9a24a05d9ece85166b8c17e
  • Loading branch information
mthrok authored and facebook-github-bot committed Jul 10, 2023
1 parent 9c7bf1b commit 589de10
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-wheels-m1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
cache-key: macos-m1-ffmpeg
pre-script: packaging/pre_build_script.sh
post-script: packaging/post_build_script.sh
smoke-test-script: test/smoke_test/smoke_test.py
smoke-test-script: test/smoke_test/smoke_test_no_ffmpeg.py
package-name: torchaudio
name: ${{ matrix.repository }}
uses: pytorch/test-infra/.github/workflows/build_wheels_macos.yml@main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
cache-key: linux-ffmpeg
pre-script: packaging/pre_build_script.sh
post-script: packaging/post_build_script.sh
smoke-test-script: test/smoke_test/smoke_test.py
smoke-test-script: test/smoke_test/smoke_test_no_ffmpeg.py
package-name: torchaudio
name: ${{ matrix.repository }}
uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
cache-key: macos-ffmpeg
pre-script: packaging/pre_build_script.sh
post-script: packaging/post_build_script.sh
smoke-test-script: test/smoke_test/smoke_test.py
smoke-test-script: test/smoke_test/smoke_test_no_ffmpeg.py
package-name: torchaudio
name: ${{ matrix.repository }}
uses: pytorch/test-infra/.github/workflows/build_wheels_macos.yml@main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
cache-key: windows-ffmpeg
wheel-build-params: "--plat-name win_amd64"
post-script: ""
smoke-test-script: test/smoke_test/smoke_test.py
smoke-test-script: test/smoke_test/smoke_test_no_ffmpeg.py
package-name: torchaudio
name: ${{ matrix.repository }}
uses: pytorch/test-infra/.github/workflows/build_wheels_windows.yml@main
Expand Down
12 changes: 0 additions & 12 deletions test/smoke_test/run_smoke_test.sh

This file was deleted.

35 changes: 27 additions & 8 deletions test/smoke_test/smoke_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
"""Run smoke tests"""
import argparse
import logging
Expand All @@ -19,26 +20,44 @@ def ffmpeg_test():
from torchaudio.io import StreamReader # noqa: F401


def main() -> None:
options = _parse_args()
def _run_smoke_test(check_ffmpeg):
base_smoke_test()

if not check_ffmpeg:
print("Skipping ffmpeg test.")
else:
ffmpeg_test()

print("Smoke test passed.")


def main(args=None) -> None:
options = _parse_args(args)

if options.debug:
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.DEBUG)

base_smoke_test()
if options.ffmpeg:
ffmpeg_test()
print("Smoke test passed.")
_chdir()
_run_smoke_test(options.ffmpeg)


def _parse_args():
def _parse_args(args):
parser = argparse.ArgumentParser()

# Warning: Please note this option should not be widely used, only use it when absolutely necessary
parser.add_argument("--no-ffmpeg", dest="ffmpeg", action="store_false")
parser.add_argument("--debug", action="store_true", help="Enable debug logging.")

return parser.parse_args()
return parser.parse_args(args)


def _chdir():
# smoke test should not be performed on the root directory of checked out source code.
import os
from pathlib import Path

os.chdir(Path(__file__).parent)
assert "torchaudio" not in os.listdir(os.getcwd())


if __name__ == "__main__":
Expand Down
3 changes: 3 additions & 0 deletions test/smoke_test/smoke_test_no_ffmpeg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from smoke_test import main

main(["--no-ffmpeg"])

0 comments on commit 589de10

Please sign in to comment.