Skip to content

Commit

Permalink
Skip certain cugraph-pyg tests when torch-sparse is not available (#…
Browse files Browse the repository at this point in the history
…3970)

A follow-up PR to fix the test failure again on rockylinux (see [log](https://github.com/rapidsai/cugraph/actions/runs/6718664898/job/18258783035#step:7:9297)).

`import_optional` only catches `ModuleNotFoundError`, however, it threw an `OSError` on rockylinux. Let's just catch all exceptions during imports in this case.

Closes rapidsai/graph_dl#373

Authors:
  - Tingyu Wang (https://github.com/tingyu66)

Approvers:
  - Rick Ratzel (https://github.com/rlratzel)
  - Brad Rees (https://github.com/BradReesWork)

URL: #3970
  • Loading branch information
tingyu66 authored Nov 3, 2023
1 parent f4bcdc2 commit 2bdb735
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions python/cugraph-pyg/cugraph_pyg/tests/test_cugraph_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@

torch = import_optional("torch")
torch_geometric = import_optional("torch_geometric")
torch_sparse = import_optional("torch_sparse")
trim_to_layer = import_optional("torch_geometric.utils.trim_to_layer")

try:
import torch_sparse # noqa: F401

HAS_TORCH_SPARSE = True
except: # noqa: E722
HAS_TORCH_SPARSE = False


@pytest.mark.skipif(isinstance(torch, MissingModule), reason="torch not available")
def test_cugraph_loader_basic(karate_gnn):
Expand Down Expand Up @@ -201,9 +207,7 @@ def test_cugraph_loader_from_disk_subset():


@pytest.mark.skipif(isinstance(torch, MissingModule), reason="torch not available")
@pytest.mark.skipif(
isinstance(torch_sparse, MissingModule), reason="torch-sparse not available"
)
@pytest.mark.skipif(not HAS_TORCH_SPARSE, reason="torch-sparse not available")
def test_cugraph_loader_from_disk_subset_csr():
m = [2, 9, 99, 82, 11, 13]
n = torch.arange(1, 1 + len(m), dtype=torch.int32)
Expand Down Expand Up @@ -336,9 +340,7 @@ def test_cugraph_loader_e2e_coo():


@pytest.mark.skipif(isinstance(torch, MissingModule), reason="torch not available")
@pytest.mark.skipif(
isinstance(torch_sparse, MissingModule), reason="torch-sparse not available"
)
@pytest.mark.skipif(not HAS_TORCH_SPARSE, reason="torch-sparse not available")
@pytest.mark.parametrize("framework", ["pyg", "cugraph-ops"])
def test_cugraph_loader_e2e_csc(framework):
m = [2, 9, 99, 82, 9, 3, 18, 1, 12]
Expand Down

0 comments on commit 2bdb735

Please sign in to comment.