Skip to content

Remove comparison dependencies and skipIfs #4031

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

Merged
merged 15 commits into from
Aug 12, 2025
Merged
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
4 changes: 2 additions & 2 deletions .github/scripts/unittest-linux/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ if [[ "$(python --version)" = *3.9* || "$(python --version)" = *3.10* ]]; then
fi
(
set -x
conda install -y -c conda-forge ${NUMBA_DEV_CHANNEL} sox libvorbis parameterized 'requests>=2.20'
pip install kaldi-io SoundFile librosa coverage pytest pytest-cov scipy expecttest unidecode inflect Pillow sentencepiece pytorch-lightning 'protobuf<4.21.0' demucs tinytag pyroomacoustics flashlight-text git+https://github.com/kpu/kenlm
conda install -y -c conda-forge ${NUMBA_DEV_CHANNEL} libvorbis parameterized 'requests>=2.20'
pip install SoundFile coverage pytest pytest-cov scipy expecttest unidecode inflect Pillow sentencepiece pytorch-lightning 'protobuf<4.21.0' demucs tinytag pyroomacoustics flashlight-text git+https://github.com/kpu/kenlm

# TODO: might be better to fix the single call to `pip install` above
pip install pillow scipy "numpy>=1.26"
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/unittest-linux/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ fi

(
cd test
pytest torchaudio_unittest -k "not backend and not /io/ and not prototype and not sox and not ffmpeg and not fairseq and not hdemucs and not (torchscript and rnnt) and not torchscript_consistency"
pytest torchaudio_unittest -k "not backend and not (sox and not compatibility) and not /io/ and not prototype and not ffmpeg and not fairseq and not hdemucs and not (torchscript and rnnt) and not torchscript_consistency"
)
1 change: 0 additions & 1 deletion .github/scripts/unittest-windows/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dependencies:
- scipy >= 1.4.1
- pip
- pip:
- kaldi-io
- PySoundFile
- future
- parameterized
Expand Down
4 changes: 1 addition & 3 deletions .github/scripts/unittest-windows/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ case "$(python --version)" in
NUMBA_DEV_CHANNEL="-c numba/label/dev"
;;
esac
# Note: installing librosa via pip fail because it will try to compile numba.
(
conda install -y -c conda-forge ${NUMBA_DEV_CHANNEL} 'librosa==0.10.0' parameterized 'requests>=2.20'
conda install -y -c conda-forge ${NUMBA_DEV_CHANNEL} parameterized 'requests>=2.20'
# Need to disable shell check since this'll fail out if SENTENCEPIECE_DEPENDENCY is empty
# shellcheck disable=SC2086
pip install \
Expand All @@ -76,7 +75,6 @@ esac
coverage \
expecttest \
inflect \
kaldi-io \
pytest \
pytest-cov \
pytorch-lightning \
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/unittest-linux-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ jobs:
export PYTHON_VERSION="${{ matrix.python_version }}"
export CU_VERSION="${{ matrix.cuda_arch_version }}"
export CUDATOOLKIT="pytorch-cuda=${CU_VERSION}"
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_APPLY_CMVN_SLIDING=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_FBANK_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_KALDI_PITCH_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_MFCC_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_CMD_COMPUTE_SPECTROGRAM_FEATS=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_CUDA_SMALL_MEMORY=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310=true
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_TEMPORARY_DISABLED=true
Expand Down Expand Up @@ -82,9 +77,8 @@ jobs:
# --quiet --yes \
# -c conda-forge \
# -c numba/label/dev \
# sox libvorbis 'librosa==0.10.0' parameterized 'requests>=2.20'
# libvorbis parameterized 'requests>=2.20'
# pip3 install --progress-bar off \
# kaldi-io \
# SoundFile \
# coverage \
# pytest \
Expand All @@ -105,7 +99,7 @@ jobs:
# git+https://github.com/pytorch/fairseq.git@e47a4c8
pip3 install parameterized requests
pip3 install kaldi-io SoundFile librosa coverage pytest pytest-cov scipy expecttest unidecode inflect Pillow sentencepiece pytorch-lightning 'protobuf<4.21.0' demucs tinytag
pip3 install SoundFile coverage pytest pytest-cov scipy expecttest unidecode inflect Pillow sentencepiece pytorch-lightning 'protobuf<4.21.0' demucs tinytag
pip3 install pillow scipy "numpy>=1.26"
echo "::endgroup::"
Expand Down
2 changes: 1 addition & 1 deletion examples/hubert/utils/kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from typing import Tuple

import torch
from sklearn.cluster import MiniBatchKMeans
from torch import Tensor

from .common_utils import _get_feat_lens_paths, _get_model_path
Expand Down Expand Up @@ -102,6 +101,7 @@ def learn_kmeans(
"""
if not km_dir.exists():
km_dir.mkdir()
from sklearn.cluster import MiniBatchKMeans

km_model = MiniBatchKMeans(
n_clusters=n_clusters,
Expand Down
5 changes: 4 additions & 1 deletion src/torchaudio/_internal/module_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def decorator(func):
{func.__doc__}
"""

UNSUPPORTED.append(wrapped)
# This is a temporary fix to avoid depending on sox during testing.
# It will be removed once the sox dependency is removed from the rest of the codebase.
if 'sox' not in func.__module__:
UNSUPPORTED.append(wrapped)
return wrapped

return decorator
Expand Down
Binary file not shown.
Binary file not shown.
6 changes: 0 additions & 6 deletions test/torchaudio_unittest/common_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
skipIfNoModule,
skipIfNoQengine,
skipIfNoRIR,
skipIfNoSox,
skipIfNoSoxDecoder,
skipIfNoSoxEncoder,
skipIfPy310,
skipIfRocm,
TempDirMixin,
Expand Down Expand Up @@ -63,9 +60,6 @@ def inject_request(self, request):
"skipIfNoMacOS",
"skipIfNoModule",
"skipIfNoRIR",
"skipIfNoSox",
"skipIfNoSoxDecoder",
"skipIfNoSoxEncoder",
"skipIfRocm",
"skipIfNoQengine",
"skipIfNoFFmpeg",
Expand Down
22 changes: 0 additions & 22 deletions test/torchaudio_unittest/common_utils/case_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,28 +206,6 @@ def skipIfNoModule(module, display_name=None):
reason="CUDA does not have enough memory.",
key="CUDA_SMALL_MEMORY",
)
skipIfNoSox = _skipIf(
not _IS_SOX_AVAILABLE,
reason="Sox features are not available.",
key="NO_SOX",
)


def skipIfNoSoxDecoder(ext):
return _skipIf(
not _IS_SOX_AVAILABLE or ext not in torchaudio.utils.sox_utils.list_read_formats(),
f'sox does not handle "{ext}" for read.',
key="NO_SOX_DECODER",
)


def skipIfNoSoxEncoder(ext):
return _skipIf(
not _IS_SOX_AVAILABLE or ext not in torchaudio.utils.sox_utils.list_write_formats(),
f'sox does not handle "{ext}" for write.',
key="NO_SOX_ENCODER",
)


skipIfNoRIR = _skipIf(
not torchaudio._extension._IS_RIR_AVAILABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
get_asset_path,
load_params,
load_wav,
skipIfNoExec,
TempDirMixin,
TestBaseMixin,
RequestMixin
Expand All @@ -19,7 +18,6 @@ def assert_equal(self, output, *, expected, rtol=None, atol=None):
self.assertEqual(output, expected, rtol=rtol, atol=atol)

@parameterized.expand(load_params("kaldi_test_fbank_args.jsonl"))
@skipIfNoExec("compute-fbank-feats")
def test_fbank(self, kwargs):
"""fbank should be numerically compatible with compute-fbank-feats"""
wave_file = get_asset_path("kaldi_file.wav")
Expand All @@ -30,7 +28,6 @@ def test_fbank(self, kwargs):
self.assert_equal(result, expected=kaldi_result, rtol=1e-4, atol=1e-8)

@parameterized.expand(load_params("kaldi_test_spectrogram_args.jsonl"))
@skipIfNoExec("compute-spectrogram-feats")
def test_spectrogram(self, kwargs):
"""spectrogram should be numerically compatible with compute-spectrogram-feats"""
wave_file = get_asset_path("kaldi_file.wav")
Expand All @@ -41,7 +38,6 @@ def test_spectrogram(self, kwargs):
self.assert_equal(result, expected=kaldi_result, rtol=1e-4, atol=1e-6)

@parameterized.expand(load_params("kaldi_test_mfcc_args.jsonl"))
@skipIfNoExec("compute-mfcc-feats")
def test_mfcc(self, kwargs):
"""mfcc should be numerically compatible with compute-mfcc-feats"""
wave_file = get_asset_path("kaldi_file.wav")
Expand Down
8 changes: 3 additions & 5 deletions test/torchaudio_unittest/deprecation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import torch

from torchaudio._internal.module_utils import UNSUPPORTED
from torchaudio.sox_effects import apply_effects_tensor
from torchaudio.prototype.functional import exp_sigmoid

# Importing prototype modules is needed to trigger the registration of the
# corresponding APIs in the UNSUPPORTED register.
Expand All @@ -25,10 +25,8 @@ def test_deprecations(func):
# deprecated for years.
@pytest.mark.parametrize("scripted", (True, False))
def test_torchscript_fails(scripted):
f = apply_effects_tensor
f = exp_sigmoid
if scripted:
pytest.xfail("Deprecation decorator breaks torchscript")
f = torch.jit.script(f)
_, out_sample_rate = f(torch.rand(2, 1000), sample_rate=16_000, effects=[["rate", "8000"]])
assert out_sample_rate == 8000

f(torch.rand(2, 1000))
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torchaudio.functional as F
from parameterized import parameterized
import unittest
from torchaudio_unittest.common_utils import PytorchTestCase, skipIfNoSox, TorchaudioTestCase
from torchaudio_unittest.common_utils import PytorchTestCase, TorchaudioTestCase

from .functional_impl import Functional, FunctionalCPUOnly

Expand All @@ -24,7 +24,6 @@ class TestFunctionalFloat64(Functional, PytorchTestCase):


@unittest.skip("deprecated")
@skipIfNoSox
class TestApplyCodec(TorchaudioTestCase):
def _smoke_test(self, format, compression, check_num_frames):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import torch
import torchaudio.functional as F
from torchaudio_unittest.common_utils import skipIfNoExec, TempDirMixin, TestBaseMixin, RequestMixin
from torchaudio_unittest.common_utils import TempDirMixin, TestBaseMixin, RequestMixin
from torchaudio_unittest.common_utils.kaldi_utils import convert_args, run_kaldi


Expand All @@ -9,7 +9,6 @@ def assert_equal(self, output, *, expected, rtol=None, atol=None):
expected = expected.to(dtype=self.dtype, device=self.device)
self.assertEqual(output, expected, rtol=rtol, atol=atol)

@skipIfNoExec("apply-cmvn-sliding")
def test_sliding_window_cmn(self):
"""sliding_window_cmn should be numerically compatible with apply-cmvn-sliding"""
kwargs = {
Expand All @@ -19,7 +18,8 @@ def test_sliding_window_cmn(self):
"norm_vars": False,
}

tensor = torch.randn(40, 10, dtype=self.dtype, device=self.device)
torch.manual_seed(0)
tensor = torch.randn(40, 10, dtype=self.dtype).to(self.device)
result = F.sliding_window_cmn(tensor, **kwargs)
command = ["apply-cmvn-sliding"] + convert_args(**kwargs) + ["ark:-", "ark:-"]
kaldi_result = run_kaldi(self.request, command, "ark", tensor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
get_whitenoise,
load_wav,
save_wav,
skipIfNoExec,
skipIfNoSox,
sox_utils,
TempDirMixin,
TorchaudioTestCase,
RequestMixin
)


@skipIfNoSox
@skipIfNoExec("sox")
class TestFunctionalFiltering(TempDirMixin, TorchaudioTestCase, RequestMixin):
def run_sox_effect(self, input_file, effect):
output_file = self.get_temp_path("expected.wav")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@
get_whitenoise,
load_wav,
save_wav,
skipIfNoExec,
skipIfNoSox,
sox_utils,
TempDirMixin,
TorchaudioTestCase,
RequestMixin
)


@skipIfNoSox
@skipIfNoExec("sox")
class TestFunctionalFiltering(TempDirMixin, TorchaudioTestCase, RequestMixin):
def run_sox_effect(self, input_file, effect):
output_file = self.get_temp_path("expected.wav")
Expand Down
3 changes: 1 addition & 2 deletions test/torchaudio_unittest/utils/sox_utils_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from torchaudio.utils import sox_utils
from torchaudio_unittest.common_utils import PytorchTestCase, skipIfNoSox
from torchaudio_unittest.common_utils import PytorchTestCase


@skipIfNoSox
class TestSoxUtils(PytorchTestCase):
"""Smoke tests for sox_util module"""

Expand Down
Loading