/ pyod / test / conftest.py
conftest.py
 1  """Pytest configuration for PyOD tests.
 2  
 3  Conditional collection skip for torch-dependent test modules when
 4  torch is not installed.
 5  
 6  Rationale: on macOS CI we deliberately do NOT install PyTorch because
 7  of the upstream NNPACK slowdown on Apple Silicon
 8  (https://github.com/pytorch/pytorch/issues/107534), which makes
 9  conv-heavy torch tests run roughly 36x slower than on Linux or
10  Windows and exhausts any reasonable GitHub Actions job timeout.
11  Ubuntu and Windows CI install torch and exercise the full torch test
12  surface, so the macOS skip is a coverage relocation, not a coverage
13  regression.
14  
15  This file is a no-op whenever ``import torch`` succeeds, so it does
16  not affect local development, Linux CI, Windows CI, or any future
17  environment where torch imports cleanly. When PyTorch fixes NNPACK
18  on Apple Silicon upstream, restore the unified install step in
19  .github/workflows/testing.yml and this file automatically becomes
20  inert.
21  
22  TODO: remove both this shim and the macOS-specific install step in
23  .github/workflows/testing.yml once
24  https://github.com/pytorch/pytorch/issues/107534 is resolved and a
25  fixed PyTorch wheel is released.
26  """
27  
28  collect_ignore_glob = []
29  
30  try:
31      import torch  # noqa: F401
32  except ImportError:
33      # Test modules that import torch (or torch_geometric) at module
34      # load time. Keep this list in sync with torch-dependent tests.
35      collect_ignore_glob = [
36          # Deep learning detectors (torch-based)
37          "test_auto_encoder.py",
38          "test_vae.py",
39          "test_deepsvdd.py",
40          "test_so_gaal.py",
41          "test_so_gaal_new.py",
42          "test_mo_gaal.py",
43          "test_anogan.py",
44          "test_alad.py",
45          "test_ae1svm.py",
46          "test_devnet.py",
47          "test_dif.py",
48          "test_lunar.py",
49          "test_embedding.py",
50          # Shared deep learning machinery
51          "test_base_dl.py",
52          "test_torch_utility.py",
53          # Torch-based time series detectors
54          "test_ts_lstm.py",
55          "test_ts_anomaly_transformer.py",
56          # PyG graph detectors (all require torch_geometric)
57          "test_pyg_*.py",
58      ]