Skip to content

Commit

Permalink
Drop support for NetworkX 3.0 and 3.1 (#27)
Browse files Browse the repository at this point in the history
I successfully ran tests locally for networkx versions 3.3, 3.4, 3.4.1, and 3.4.2. I'm seeing failures for 3.2 and 3.2.1, but these failures are not introduced by this PR. I'll investigate further, but getting these to pass are probably "nice to have" for this release.

We should consider adding tests (perhaps nightly tests) to test against different networkx versions, such as minimum supported version and dev versions.

Closes rapidsai/cugraph#4760

Authors:
  - Erik Welch (https://github.com/eriknw)

Approvers:
  - Rick Ratzel (https://github.com/rlratzel)
  - Ray Douglass (https://github.com/raydouglass)

URL: #27
  • Loading branch information
eriknw authored Nov 20, 2024
1 parent a75e921 commit ea10f21
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 278 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nx-cugraph requires the following:
* NVIDIA GPU, Volta architecture or later, with [compute capability](https://developer.nvidia.com/cuda-gpus) 7.0+
* CUDA 11.4-11.8 or 12.0-12.5
* Python version 3.10, 3.11, or 3.12
* NetworkX >= version 3.0 (version 3.4 or higher recommended)
* NetworkX >= version 3.2 (version 3.4 or higher recommended)

More details about system requirements can be found in the [RAPIDS System Requirements documentation](https://docs.rapids.ai/install#system-req).

Expand Down
3 changes: 1 addition & 2 deletions _nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@


def get_info():
"""Target of ``networkx.plugin_info`` entry point.
"""Target of ``networkx.backend_info`` entry point.
This tells NetworkX about the cugraph backend without importing nx_cugraph.
"""
Expand Down Expand Up @@ -330,7 +330,6 @@ def update_env_var(varname):
update_env_var("NETWORKX_BACKEND_PRIORITY")
# And for older NetworkX versions
update_env_var("NETWORKX_AUTOMATIC_BACKENDS") # For NetworkX 3.2
update_env_var("NETWORKX_GRAPH_CONVERT") # For NetworkX 3.0 and 3.1
# Automatically create nx-cugraph Graph from graph generators
update_env_var("NETWORKX_BACKEND_PRIORITY_GENERATORS")
# Run default NetworkX implementation (in >=3.4) if not implemented by nx-cugraph
Expand Down
51 changes: 1 addition & 50 deletions benchmarks/nx-cugraph/pytest-based/bench_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@

import nx_cugraph as nxcg

# Attempt to import the NetworkX dispatching module, which is only needed when
# testing with NX <3.2 in order to dynamically switch backends. NX >=3.2 allows
# the backend to be specified directly in the API call.
try:
from networkx.classes import backends # NX <3.2
except ImportError:
backends = None


################################################################################
# Fixtures and params

Expand Down Expand Up @@ -133,45 +124,10 @@ def nx_graph_from_dataset(dataset_obj):
return G


def get_legacy_backend_wrapper(backend_name):
"""
Returns a callable that wraps an algo function with either the default
dispatcher (which dispatches based on input graph type), or the "testing"
dispatcher (which autoconverts and unconditionally dispatches).
This is only supported for NetworkX <3.2
"""
backends.plugin_name = "cugraph"
orig_dispatch = backends._dispatch
testing_dispatch = backends.test_override_dispatch

if backend_name == "cugraph":
dispatch = testing_dispatch
else:
dispatch = orig_dispatch

def wrap_callable_for_dispatch(func, exhaust_returned_iterator=False):
# Networkx <3.2 registers functions when the dispatch decorator is
# applied (called) and errors if re-registered, so clear bookkeeping to
# allow it to be called repeatedly.
backends._registered_algorithms = {}
actual_func = dispatch(func) # returns the func the dispatcher picks

def wrapper(*args, **kwargs):
retval = actual_func(*args, **kwargs)
if exhaust_returned_iterator:
retval = list(retval)
return retval

return wrapper

return wrap_callable_for_dispatch


def get_backend_wrapper(backend_name):
"""
Returns a callable that wraps an algo function in order to set the
"backend" kwarg on it.
This is only supported for NetworkX >= 3.2
"""

def wrap_callable_for_dispatch(func, exhaust_returned_iterator=False):
Expand Down Expand Up @@ -210,12 +166,7 @@ def backend_wrapper(request):
if backend_name == "cugraph-preconverted":
actual_backend_name = "cugraph"

# NX <3.2 does not support the backends= kwarg, so the backend must be
# enabled differently
if backends is not None:
wrapper = get_legacy_backend_wrapper(actual_backend_name)
else:
wrapper = get_backend_wrapper(actual_backend_name)
wrapper = get_backend_wrapper(actual_backend_name)

wrapper.backend_name = backend_name
return wrapper
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- graphviz
- ipython
- nbsphinx
- networkx>=3.0
- networkx>=3.2
- numpy>=1.23,<3.0a0
- numpydoc
- pandas
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-125_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- graphviz
- ipython
- nbsphinx
- networkx>=3.0
- networkx>=3.2
- numpy>=1.23,<3.0a0
- numpydoc
- pandas
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/nx-cugraph/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ requirements:
- setuptools>=61.0.0
run:
- pylibcugraph ={{ minor_version }}
- networkx >=3.0
- networkx >=3.2
- cupy >=12.0.0
- python

Expand Down
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ dependencies:
common:
- output_types: [conda, pyproject]
packages:
- networkx>=3.0
- networkx>=3.2
- &numpy numpy>=1.23,<3.0a0
test_python_nx_cugraph:
common:
Expand Down
2 changes: 1 addition & 1 deletion docs/nx-cugraph/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Required hardware/software for cuGraph and `RAPIDS <https://docs.rapids.ai/user-
* NVIDIA GPU, Volta architecture or later, with `compute capability <https://developer.nvidia.com/cuda-gpus> 7.0+`_
* CUDA 11.2-11.8, 12.0-12.5
* Python version 3.10, 3.11, or 3.12
* NetworkX version 3.0 or newer in order to use use the nx-cuGraph backend. NetworkX version 3.4 or newer is recommended. (`see below <#cugraph-using-networkx-code>`).
* NetworkX version 3.2 or newer in order to use use the nx-cuGraph backend. NetworkX version 3.4 or newer is recommended. (`see below <#cugraph-using-networkx-code>`).

Installation
The latest RAPIDS System Requirements documentation is located `here <https://docs.rapids.ai/install#system-req>`_.
Expand Down
2 changes: 1 addition & 1 deletion docs/nx-cugraph/source/nx_cugraph/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This guide describes how to install ``nx-cugraph`` and use it in your workflows.
- **Volta architecture or later NVIDIA GPU, with [compute capability](https://developer.nvidia.com/cuda-gpus) 7.0+**
- **[CUDA](https://docs.nvidia.com/cuda/index.html) 11.2, 11.4, 11.5, 11.8, 12.0, 12.2, or 12.5**
- **Python >= 3.10**
- **[NetworkX](https://networkx.org/documentation/stable/install.html#) >= 3.0 (version 3.2 or higher recommended)**
- **[NetworkX](https://networkx.org/documentation/stable/install.html#) >= 3.2 (version 3.4 or higher recommended)**

More details about system requirements can be found in the [RAPIDS System Requirements Documentation](https://docs.rapids.ai/install#system-req).

Expand Down
6 changes: 2 additions & 4 deletions nx_cugraph/classes/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ def clear(self) -> None:

class Graph(nx.Graph):
# Tell networkx to dispatch calls with this object to nx-cugraph
__networkx_backend__: ClassVar[str] = "cugraph" # nx >=3.2
__networkx_plugin__: ClassVar[str] = "cugraph" # nx <3.2
__networkx_backend__: ClassVar[str] = "cugraph"

# Core attributes of NetowkrX graphs that will be copied and cleared as appropriate.
# These attributes comprise the edge and node data model for NetworkX graphs.
Expand Down Expand Up @@ -513,8 +512,7 @@ def from_dcsc(

class CudaGraph:
# Tell networkx to dispatch calls with this object to nx-cugraph
__networkx_backend__: ClassVar[str] = "cugraph" # nx >=3.2
__networkx_plugin__: ClassVar[str] = "cugraph" # nx <3.2
__networkx_backend__: ClassVar[str] = "cugraph"

# Allow networkx dispatch machinery to cache conversions.
# This means we should clear the cache if we ever mutate the object!
Expand Down
Loading

0 comments on commit ea10f21

Please sign in to comment.