Skip to content

Commit c4230bb

Browse files
authored
Allow cugraph to be imported in an SG env for SG algorithms (#2241)
This PR aims to directly resolve #2113, and allows for cugraph to be imported without errors in environments with only a single GPU What this PR does: - Moves `comms` module into the `dask` module, renaming imports across `cugraph` accordingly - Adds mock class in case ucp is not available or usable in SG-only environments (note ucp requires libnuma.so) - Renames `tests/dask` to `tests/mg` to better reflect the fact that those tests are for mg algs and utils - Separates symmetrize testing into `tests/mg` and `tests` for separation of SG and MG testing Authors: - https://github.com/betochimas Approvers: - Rick Ratzel (https://github.com/rlratzel) - AJ Schmidt (https://github.com/ajschmidt8) URL: #2241
1 parent 473b03c commit c4230bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+288
-138
lines changed

ci/test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ echo "Ran Python pytest for pylibcugraph : return code was: $?, test script exit
9191

9292
echo "Python pytest for cuGraph (single-GPU only)..."
9393
cd ${CUGRAPH_ROOT}/python/cugraph/cugraph
94-
pytest --cache-clear --junitxml=${CUGRAPH_ROOT}/junit-cugraph-pytests.xml -v --cov-config=.coveragerc --cov=cugraph --cov-report=xml:${WORKSPACE}/python/cugraph/cugraph-coverage.xml --cov-report term --ignore=raft --ignore=tests/dask --benchmark-disable
94+
# rmat is not tested because of MG testing
95+
pytest --cache-clear --junitxml=${CUGRAPH_ROOT}/junit-cugraph-pytests.xml -v --cov-config=.coveragerc --cov=cugraph --cov-report=xml:${WORKSPACE}/python/cugraph/cugraph-coverage.xml --cov-report term -k "not mg and not rmat" --benchmark-disable
9596
echo "Ran Python pytest for cugraph : return code was: $?, test script exit code is now: $EXITCODE"
9697

9798
echo "Python benchmarks for cuGraph (running as tests)..."

docs/cugraph/source/api_docs/dask-cugraph.rst

Lines changed: 1 addition & 1 deletion

docs/cugraph/source/api_docs/helper_functions.rst

Lines changed: 10 additions & 10 deletions

python/cugraph/cugraph/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
from cugraph.linear_assignment import hungarian, dense_hungarian
106106
from cugraph.layout import force_atlas2
107107
from raft import raft_include_test
108-
from cugraph.comms import comms
108+
from cugraph.dask.comms import comms
109109

110110
from cugraph.sampling import random_walks, rw_path, node2vec
111111

python/cugraph/cugraph/centrality/betweenness_centrality_wrapper.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020-2021, NVIDIA CORPORATION.
1+
# Copyright (c) 2020-2022, NVIDIA CORPORATION.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -22,7 +22,7 @@ from libc.stdint cimport uintptr_t
2222
from libcpp cimport bool
2323
import cudf
2424
import numpy as np
25-
import cugraph.comms.comms as Comms
25+
import cugraph.dask.comms.comms as Comms
2626
from cugraph.dask.common.mg_utils import get_client
2727
import dask.distributed
2828

python/cugraph/cugraph/centrality/edge_betweenness_centrality_wrapper.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020-2021, NVIDIA CORPORATION.
1+
# Copyright (c) 2020-2022, NVIDIA CORPORATION.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -24,7 +24,7 @@ from libcpp cimport bool
2424
import cudf
2525
import numpy as np
2626
from cugraph.dask.common.mg_utils import get_client
27-
import cugraph.comms.comms as Comms
27+
import cugraph.dask.comms.comms as Comms
2828
import dask.distributed
2929

3030

python/cugraph/cugraph/dask/centrality/katz_centrality.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
get_vertex_partition_offsets)
1919
from cugraph.dask.centrality import\
2020
mg_katz_centrality_wrapper as mg_katz_centrality
21-
import cugraph.comms.comms as Comms
21+
import cugraph.dask.comms.comms as Comms
2222
import dask_cudf
2323

2424

python/cugraph/cugraph/dask/common/input_utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,17 @@
1919
from dask_cudf.core import DataFrame as dcDataFrame
2020
from dask_cudf.core import Series as daskSeries
2121

22-
import cugraph.comms.comms as Comms
23-
from raft.dask.common.utils import get_client
22+
import cugraph.dask.comms.comms as Comms
23+
# FIXME: this raft import breaks the library if ucx-py is
24+
# not available. They are necessary only when doing MG work.
25+
from cugraph.dask.common.read_utils import MissingUCXPy
26+
try:
27+
from raft.dask.common.utils import get_client
28+
except ModuleNotFoundError as err:
29+
if err.name == "ucp":
30+
get_client = MissingUCXPy()
31+
else:
32+
raise
2433
from cugraph.dask.common.part_utils import _extract_partitions
2534
from dask.distributed import default_client
2635
from toolz import first

python/cugraph/cugraph/dask/common/mg_utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@
1818
from dask_cuda import LocalCUDACluster
1919
from dask.distributed import Client
2020

21-
from raft.dask.common.utils import default_client
21+
# FIXME: this raft import breaks the library if ucx-py is
22+
# not available. They are necessary only when doing MG work.
23+
from cugraph.dask.common.read_utils import MissingUCXPy
24+
try:
25+
from raft.dask.common.utils import default_client
26+
except ModuleNotFoundError as err:
27+
if err.name == "ucp":
28+
default_client = MissingUCXPy()
29+
else:
30+
raise
2231
# FIXME: cugraph/__init__.py also imports the comms module, but
2332
# depending on the import environment, cugraph/comms/__init__.py
2433
# may be imported instead. The following imports the comms.py
2534
# module directly
26-
from cugraph.comms import comms as Comms
35+
from cugraph.dask.comms import comms as Comms
2736

2837

2938
# FIXME: We currently look for the default client from dask, as such is the

python/cugraph/cugraph/dask/common/part_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from dask_cudf.core import DataFrame as daskDataFrame
2222
from dask_cudf.core import Series as daskSeries
2323
from functools import reduce
24-
import cugraph.comms.comms as Comms
24+
import cugraph.dask.comms.comms as Comms
2525
from dask.delayed import delayed
2626
import cudf
2727

0 commit comments

Comments
 (0)