Skip to content

Update package smoke test #3465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be test/smoke_test/smoke_test.py --no-ffmpeg instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"])