Skip to content

Commit daf857d

Browse files
Add RAPIDS Doctor Check for cuGraph-PyG and pylibwholegraph (#418)
Adds a RAPIDS Doctor check for cuGraph-PyG and pylibwholegraph. Authors: - Alex Barghi (https://github.com/alexbarghi-nv) Approvers: - https://github.com/linhu-nv - Tingyu Wang (https://github.com/tingyu66) - Bradley Dice (https://github.com/bdice) URL: #418
1 parent 2c0eb8f commit daf857d

4 files changed

Lines changed: 135 additions & 0 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
"""
5+
Smoke check for `rapids doctor` (RAPIDS CLI).
6+
7+
See: https://github.com/rapidsai/rapids-cli#check-plugins
8+
"""
9+
10+
from unittest.mock import patch
11+
12+
13+
def cugraph_pyg_smoke_check(**kwargs):
14+
"""
15+
A quick check to ensure cugraph-pyg can be imported and its core
16+
submodules are loadable.
17+
"""
18+
try:
19+
import cugraph_pyg
20+
21+
# Ensure core submodules load (touches pylibwholegraph, torch-geometric, etc.)
22+
import cugraph_pyg.data
23+
import cugraph_pyg.tensor
24+
25+
except ImportError as e:
26+
raise ImportError(
27+
"cugraph-pyg or its dependencies could not be imported. "
28+
"Tip: install with `pip install --extra-index-url=https://pypi.nvidia.com cugraph-pyg-cu13` or use a RAPIDS conda environment."
29+
) from e
30+
31+
if not hasattr(cugraph_pyg, "__version__") or not cugraph_pyg.__version__:
32+
raise AssertionError(
33+
"cugraph-pyg smoke check failed: __version__ not found or empty"
34+
)
35+
36+
from cugraph_pyg.utils.imports import import_optional, MissingModule
37+
38+
torch = import_optional("torch")
39+
40+
if isinstance(torch, MissingModule) or not torch.cuda.is_available():
41+
import warnings
42+
43+
warnings.warn(
44+
"PyTorch with CUDA support is required to use cuGraph-PyG. "
45+
"Please install PyTorch from PyPI or Conda-Forge."
46+
)
47+
else:
48+
import os
49+
from cugraph_pyg.data import GraphStore
50+
51+
initialized = False
52+
try:
53+
env_values = {
54+
"MASTER_ADDR": "localhost",
55+
"MASTER_PORT": "29505",
56+
"LOCAL_RANK": "0",
57+
"WORLD_SIZE": "1",
58+
"LOCAL_WORLD_SIZE": "1",
59+
"RANK": "0",
60+
}
61+
with patch.dict(os.environ, env_values, clear=False):
62+
try:
63+
torch.distributed.init_process_group("nccl")
64+
initialized = True
65+
except Exception as e:
66+
raise RuntimeError(
67+
"Failed to initialize distributed process group. Please check your PyTorch and NCCL installation."
68+
) from e
69+
70+
graph_store = GraphStore()
71+
graph_store.put_edge_index(
72+
torch.tensor([[0, 1], [1, 2]]),
73+
("person", "knows", "person"),
74+
"coo",
75+
False,
76+
(3, 3),
77+
)
78+
edge_index = graph_store.get_edge_index(
79+
("person", "knows", "person"), "coo"
80+
)
81+
82+
if edge_index.shape != torch.Size([2, 2]):
83+
raise AssertionError(
84+
"cugraph-pyg smoke check failed: edge index shape "
85+
f"is not [2, 2], got {edge_index.shape}"
86+
)
87+
finally:
88+
if initialized:
89+
torch.distributed.destroy_process_group()

python/cugraph-pyg/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ dependencies = [
4141
"torch-geometric>=2.5,<2.8",
4242
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
4343

44+
[project.entry-points."rapids_doctor_check"]
45+
cugraph_pyg_smoke_check = "cugraph_pyg._doctor_check:cugraph_pyg_smoke_check"
46+
4447
[project.urls]
4548
Homepage = "https://github.com/rapidsai/cugraph-gnn"
4649
Documentation = "https://docs.rapids.ai/api/cugraph/stable/"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
"""
5+
Smoke check for `rapids doctor` (RAPIDS CLI).
6+
7+
See: https://github.com/rapidsai/rapids-cli#check-plugins
8+
"""
9+
10+
11+
def pylibwholegraph_smoke_check(**kwargs):
12+
"""
13+
A quick check to ensure pylibwholegraph can be imported and the
14+
native library loads correctly.
15+
"""
16+
try:
17+
import pylibwholegraph
18+
except ImportError as e:
19+
raise ImportError(
20+
"pylibwholegraph or its dependencies could not be imported. "
21+
"Tip: install with `pip install --extra-index-url=https://pypi.nvidia.com pylibwholegraph-cu13` or use a RAPIDS conda environment."
22+
) from e
23+
24+
if not hasattr(pylibwholegraph, "__version__") or not pylibwholegraph.__version__:
25+
raise AssertionError(
26+
"pylibwholegraph smoke check failed: __version__ not found or empty"
27+
)
28+
29+
try:
30+
import torch
31+
32+
assert torch.cuda.is_available()
33+
34+
except (ImportError, AssertionError):
35+
import warnings
36+
37+
warnings.warn(
38+
"PyTorch with CUDA or its dependencies could not be imported. "
39+
"PyTorch is required to use pylibwholegraph. "
40+
"Please install PyTorch from PyPI or Conda-Forge."
41+
)

python/pylibwholegraph/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ dependencies = [
3030
"numpy>=1.23,<3.0",
3131
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
3232

33+
[project.entry-points."rapids_doctor_check"]
34+
pylibwholegraph_smoke_check = "pylibwholegraph._doctor_check:pylibwholegraph_smoke_check"
3335

3436
[project.optional-dependencies]
3537
test = [

0 commit comments

Comments
 (0)