Skip to content

Commit f225c94

Browse files
committed
Update smoke test
Delay the import ot torchaudio untill the CLI options are parsed. Add option to set loglevel to DEBUG so that it's easy to see the issue with external libraries.
1 parent 72d3fe0 commit f225c94

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

test/smoke_test/smoke_test.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
11
"""Run smoke tests"""
2-
32
import argparse
3+
import logging
4+
45

5-
import torchaudio # noqa: F401
6-
import torchaudio.compliance.kaldi # noqa: F401
7-
import torchaudio.datasets # noqa: F401
8-
import torchaudio.functional # noqa: F401
9-
import torchaudio.models # noqa: F401
10-
import torchaudio.pipelines # noqa: F401
11-
import torchaudio.sox_effects # noqa: F401
12-
import torchaudio.transforms # noqa: F401
13-
import torchaudio.utils # noqa: F401
6+
def base_smoke_test():
7+
import torchaudio # noqa: F401
8+
import torchaudio.compliance.kaldi # noqa: F401
9+
import torchaudio.datasets # noqa: F401
10+
import torchaudio.functional # noqa: F401
11+
import torchaudio.models # noqa: F401
12+
import torchaudio.pipelines # noqa: F401
13+
import torchaudio.sox_effects # noqa: F401
14+
import torchaudio.transforms # noqa: F401
15+
import torchaudio.utils # noqa: F401
1416

1517

1618
def ffmpeg_test():
1719
from torchaudio.io import StreamReader # noqa: F401
1820

1921

2022
def main() -> None:
23+
options = _parse_args()
24+
25+
if options.debug:
26+
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
27+
28+
base_smoke_test()
29+
if options.ffmpeg:
30+
ffmpeg_test()
31+
print("Smoke test passed.")
32+
33+
34+
def _parse_args():
2135
parser = argparse.ArgumentParser()
2236

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

26-
options = parser.parse_args()
27-
if options.ffmpeg:
28-
ffmpeg_test()
41+
return parser.parse_args()
2942

3043

3144
if __name__ == "__main__":

0 commit comments

Comments
 (0)