diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 13ef6c7e..c5d78f22 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -18,13 +18,9 @@ build: os: ubuntu-22.04 tools: python: "3.11" - jobs: - post_install: - # Install package dependencies - - pip install -e . python: install: - - requirements: docs/requirements.txt - method: pip path: . + - requirements: docs/requirements.txt diff --git a/docs/source/conf.py b/docs/source/conf.py index f1de2527..cd66f594 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -60,6 +60,17 @@ autodoc_typehints = "description" autodoc_class_signature = "separated" +# Mock imports for heavy dependencies that aren't needed for building docs +autodoc_mock_imports = [ + "torch", + "torch_geometric", + "pytorch_lightning", + "torchmetrics", + "tensorflow", + "keras", + "spektral", +] + # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] diff --git a/tests/test_soccer.py b/tests/test_soccer.py index a7a3cdef..0f2764af 100644 --- a/tests/test_soccer.py +++ b/tests/test_soccer.py @@ -1586,9 +1586,10 @@ def test_efpi_period_442(self, kloppy_polars_sportec_dataset: KloppyPolarsDatase def test_efpi_wrong(self, kloppy_polars_sportec_dataset): import pytest - from polars.exceptions import PanicException - with pytest.raises(pl.exceptions.InvalidOperationError): + with pytest.raises( + (pl.exceptions.PanicException, pl.exceptions.InvalidOperationError) + ): model = EFPI(dataset=kloppy_polars_sportec_dataset) model.fit( formations=["442"], diff --git a/unravel/classifiers/__init__.py b/unravel/classifiers/__init__.py index 5cd34fbc..c771a8e0 100644 --- a/unravel/classifiers/__init__.py +++ b/unravel/classifiers/__init__.py @@ -14,6 +14,17 @@ def __init__(self, *args, **kwargs): __all__ = ["CrystalGraphClassifier"] -from .crystal_graph_pyg import PyGLightningCrystalGraphClassifier +try: + from .crystal_graph_pyg import PyGLightningCrystalGraphClassifier + + __all__.append("PyGLightningCrystalGraphClassifier") +except ImportError: + + class PyGLightningCrystalGraphClassifier: + def __init__(self, *args, **kwargs): + raise ImportError( + "PyGLightningCrystalGraphClassifier requires PyTorch and PyTorch Geometric. " + "Install with: pip install torch torch-geometric pytorch-lightning torchmetrics" + ) -__all__.append("PyGLightningCrystalGraphClassifier") + __all__.append("PyGLightningCrystalGraphClassifier")