Skip to content

Commit

Permalink
Merge branch 'branch-24.06' into run_nx_example
Browse files Browse the repository at this point in the history
  • Loading branch information
acostadon authored May 8, 2024
2 parents 21c4e4f + 9e3f745 commit 63a76fa
Show file tree
Hide file tree
Showing 26 changed files with 142 additions and 66 deletions.
4 changes: 4 additions & 0 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,9 @@ sed_runner "s/branch-.*/branch-${NEXT_SHORT_TAG}/g" python/nx-cugraph/README.md
find .devcontainer/ -type f -name devcontainer.json -print0 | while IFS= read -r -d '' filename; do
sed_runner "s@rapidsai/devcontainers:[0-9.]*@rapidsai/devcontainers:${NEXT_SHORT_TAG}@g" "${filename}"
sed_runner "s@rapidsai/devcontainers/features/ucx:[0-9.]*@rapidsai/devcontainers/features/ucx:${NEXT_SHORT_TAG_PEP440}@" "${filename}"
sed_runner "s@rapidsai/devcontainers/features/cuda:[0-9.]*@rapidsai/devcontainers/features/cuda:${NEXT_SHORT_TAG_PEP440}@" "${filename}"
sed_runner "s@rapidsai/devcontainers/features/rapids-build-utils:[0-9.]*@rapidsai/devcontainers/features/rapids-build-utils:${NEXT_SHORT_TAG_PEP440}@" "${filename}"
done

sed_runner "s/:[0-9][0-9]\.[0-9][0-9]/:${NEXT_SHORT_TAG}/" ./notebooks/README.md
sed_runner "s/branch-[0-9][0-9].[0-9][0-9]/branch-${NEXT_SHORT_TAG}/" ./docs/cugraph/source/nx_cugraph/nx_cugraph.md
5 changes: 4 additions & 1 deletion conda/recipes/cugraph-pyg/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ cuda_compiler:
cmake_version:
- ">=3.26.4"

sysroot_version:
c_stdlib:
- sysroot

c_stdlib_version:
- "2.17"
2 changes: 1 addition & 1 deletion conda/recipes/cugraph-pyg/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ build:

requirements:
build:
- sysroot_{{ target_platform }} {{ sysroot_version }}
- {{ stdlib("c") }}
host:
- cython >=3.0.0
- python
Expand Down
5 changes: 4 additions & 1 deletion conda/recipes/cugraph/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ cuda11_compiler:
cmake_version:
- ">=3.26.4"

sysroot_version:
c_stdlib:
- sysroot

c_stdlib_version:
- "2.17"

ucx_py_version:
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/cugraph/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ requirements:
- cuda-version ={{ cuda_version }}
- cmake {{ cmake_version }}
- ninja
- sysroot_{{ target_platform }} {{ sysroot_version }}
- {{ stdlib("c") }}
host:
- cuda-version ={{ cuda_version }}
{% if cuda_major == "11" %}
Expand Down
5 changes: 4 additions & 1 deletion conda/recipes/libcugraph/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ doxygen_version:
nccl_version:
- ">=2.9.9"

sysroot_version:
c_stdlib:
- sysroot

c_stdlib_version:
- "2.17"

# The CTK libraries below are missing from the conda-forge::cudatoolkit
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/libcugraph/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ requirements:
- cmake {{ cmake_version }}
- ninja
- openmpi # Required for building cpp-mgtests (multi-GPU tests)
- sysroot_{{ target_platform }} {{ sysroot_version }}
- {{ stdlib("c") }}
host:
{% if cuda_major == "11" %}
- cudatoolkit
Expand Down
5 changes: 4 additions & 1 deletion conda/recipes/pylibcugraph/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ cuda11_compiler:
cmake_version:
- ">=3.26.4"

sysroot_version:
c_stdlib:
- sysroot

c_stdlib_version:
- "2.17"

ucx_py_version:
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/pylibcugraph/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ requirements:
- cuda-version ={{ cuda_version }}
- cmake {{ cmake_version }}
- ninja
- sysroot_{{ target_platform }} {{ sysroot_version }}
- {{ stdlib("c") }}
host:
- cuda-version ={{ cuda_version }}
{% if cuda_major == "11" %}
Expand Down
7 changes: 7 additions & 0 deletions cpp/src/community/leiden_impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,13 @@ std::pair<std::unique_ptr<Dendrogram<vertex_t>>, weight_t> leiden(
louvain_of_refined_graph.size(),
false);
}
} else {
// Reset dendrogram.
// FIXME: Revisit how dendrogram is populated
detail::sequence_fill(handle.get_stream(),
dendrogram->current_level_begin(),
dendrogram->current_level_size(),
current_graph_view.local_vertex_partition_range_first());
}

copied_louvain_partition.resize(0, handle.get_stream());
Expand Down
12 changes: 7 additions & 5 deletions python/cugraph/cugraph/datasets/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def get_edgelist(self, download=False, reader="cudf"):
reader : 'cudf' or 'pandas' (default='cudf')
The library used to read a CSV and return an edgelist DataFrame.
"""
if self._edgelist is None:
if self._edgelist is None or not isinstance(self._edgelist, cudf.DataFrame):
full_path = self.get_path()
if not full_path.is_file():
if download:
Expand Down Expand Up @@ -223,7 +223,9 @@ def get_dask_edgelist(self, download=False):
Automatically download the dataset from the 'url' location within
the YAML file.
"""
if self._edgelist is None:
if self._edgelist is None or not isinstance(
self._edgelist, dask_cudf.DataFrame
):
full_path = self.get_path()
if not full_path.is_file():
if download:
Expand Down Expand Up @@ -286,7 +288,7 @@ def get_graph(
for certain algorithms, such as pagerank.
"""
if self._edgelist is None:
self.get_edgelist(download)
self.get_edgelist(download=download)

if create_using is None:
G = Graph()
Expand Down Expand Up @@ -351,7 +353,7 @@ def get_dask_graph(
for certain algorithms.
"""
if self._edgelist is None:
self.get_dask_edgelist(download)
self.get_dask_edgelist(download=download)

if create_using is None:
G = Graph()
Expand All @@ -367,7 +369,7 @@ def get_dask_graph(
f"{type(create_using)}"
)

if len(self.metadata["col_names"]) > 2 and not (ignore_weights):
if len(self.metadata["col_names"]) > 2 and not ignore_weights:
G.from_dask_cudf_edgelist(
self._edgelist,
source=self.metadata["col_names"][0],
Expand Down
50 changes: 24 additions & 26 deletions python/cugraph/cugraph/tests/utils/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
import pytest

import cudf
import cugraph
import dask_cudf
from cugraph import datasets
from cugraph.dask.common.mg_utils import is_single_gpu
from cugraph.datasets import karate
from cugraph.structure import Graph
from cugraph.testing import (
RAPIDS_DATASET_ROOT_DIR_PATH,
Expand All @@ -29,15 +33,15 @@
SMALL_DATASETS,
BENCHMARKING_DATASETS,
)
from cugraph import datasets
from cugraph.dask.common.mg_utils import is_single_gpu


# Add the sg marker to all tests in this module.
pytestmark = pytest.mark.sg


###############################################################################
# Fixtures
###############################################################################


# module fixture - called once for this module
Expand Down Expand Up @@ -201,21 +205,26 @@ def test_reader_dask(dask_client, dataset):
@pytest.mark.parametrize("dataset", ALL_DATASETS)
def test_get_edgelist(dataset):
E = dataset.get_edgelist(download=True)

assert E is not None
assert isinstance(E, cudf.DataFrame)


@pytest.mark.skipif(is_single_gpu(), reason="skipping MG testing on Single GPU system")
@pytest.mark.skip(reason="MG not supported on CI")
@pytest.mark.parametrize("dataset", ALL_DATASETS)
def test_get_dask_edgelist(dask_client, dataset):
E = dataset.get_dask_edgelist(download=True)

assert E is not None
assert isinstance(E, dask_cudf.DataFrame)


@pytest.mark.parametrize("dataset", ALL_DATASETS)
def test_get_graph(dataset):
G = dataset.get_graph(download=True)
assert G is not None
assert isinstance(G, cugraph.Graph)


@pytest.mark.skipif(is_single_gpu(), reason="skipping MG testing on Single GPU system")
Expand All @@ -224,12 +233,14 @@ def test_get_graph(dataset):
def test_get_dask_graph(dask_client, dataset):
G = dataset.get_dask_graph(download=True)
assert G is not None
# TODO Check G is a DistributedGraph


@pytest.mark.parametrize("dataset", ALL_DATASETS)
def test_metadata(dataset):
M = dataset.metadata
assert M is not None
assert isinstance(M, dict)


@pytest.mark.parametrize("dataset", ALL_DATASETS)
Expand Down Expand Up @@ -346,32 +357,19 @@ def test_ctor_with_datafile():
assert ds.get_path() == karate_csv


def test_unload():
email_csv = RAPIDS_DATASET_ROOT_DIR_PATH / "email-Eu-core.csv"
@pytest.mark.parametrize("dataset", [karate])
def test_unload(dataset):
assert dataset._edgelist is None

ds = datasets.Dataset(
csv_file=email_csv.as_posix(),
csv_col_names=["src", "dst", "wgt"],
csv_col_dtypes=["int32", "int32", "float32"],
)
dataset.get_edgelist()
assert dataset._edgelist is not None
dataset.unload()
assert dataset._edgelist is None

# FIXME: another (better?) test would be to check free memory and assert
# the memory use increases after get_*(), then returns to the pre-get_*()
# level after unload(). However, that type of test may fail for several
# reasons (the device being monitored is accidentally also being used by
# another process, and the use of memory pools to name two). Instead, just
# test that the internal members get cleared on unload().
assert ds._edgelist is None

ds.get_edgelist()
assert ds._edgelist is not None
ds.unload()
assert ds._edgelist is None

ds.get_graph()
assert ds._edgelist is not None
ds.unload()
assert ds._edgelist is None
dataset.get_graph()
assert dataset._edgelist is not None
dataset.unload()
assert dataset._edgelist is None


@pytest.mark.parametrize("dataset", ALL_DATASETS)
Expand Down
4 changes: 0 additions & 4 deletions python/nx-cugraph/_nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@
"eigenvector_centrality": "`nstart` parameter is not used, but it is checked for validity.",
"from_pandas_edgelist": "cudf.DataFrame inputs also supported; value columns with str is unsuppported.",
"generic_bfs_edges": "`neighbors` and `sort_neighbors` parameters are not yet supported.",
"k_truss": (
"Currently raises `NotImplementedError` for graphs with more than one connected\n"
"component when k >= 3. We expect to fix this soon."
),
"katz_centrality": "`nstart` isn't used (but is checked), and `normalized=False` is not supported.",
"louvain_communities": "`seed` parameter is currently ignored, and self-loops are not yet supported.",
"pagerank": "`dangling` parameter is not supported, but it is checked for validity.",
Expand Down
16 changes: 8 additions & 8 deletions python/nx-cugraph/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -31,7 +31,7 @@ repos:
- id: validate-pyproject
name: Validate pyproject.toml
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.0
rev: v2.3.1
hooks:
- id: autoflake
args: [--in-place]
Expand All @@ -40,17 +40,17 @@ repos:
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.1
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/psf/black
rev: 24.2.0
rev: 24.4.2
hooks:
- id: black
# - id: black-jupyter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
rev: v0.4.2
hooks:
- id: ruff
args: [--fix-only, --show-fixes] # --unsafe-fixes]
Expand All @@ -62,7 +62,7 @@ repos:
additional_dependencies: &flake8_dependencies
# These versions need updated manually
- flake8==7.0.0
- flake8-bugbear==24.2.6
- flake8-bugbear==24.4.21
- flake8-simplify==0.21.0
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
Expand All @@ -77,11 +77,11 @@ repos:
additional_dependencies: [tomli]
files: ^(nx_cugraph|docs)/
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
rev: v0.4.2
hooks:
- id: ruff
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: no-commit-to-branch
args: [-p, "^branch-2....$"]
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ def complete_bipartite_graph(n1, n2, create_using=None):
nodes.extend(range(n2) if nodes2 is None else nodes2)
if len(set(nodes)) != len(nodes):
raise nx.NetworkXError("Inputs n1 and n2 must contain distinct nodes")
if nx.__version__[:3] <= "3.3":
name = f"complete_bipartite_graph({orig_n1}, {orig_n2})"
else:
name = f"complete_bipartite_graph({n1}, {n2})"
G = graph_class.from_coo(
n1 + n2,
src_indices,
dst_indices,
node_values={"bipartite": bipartite},
id_to_key=nodes,
name=f"complete_bipartite_graph({orig_n1}, {orig_n2})",
name=name,
)
if inplace:
return create_using._become(G)
Expand Down
15 changes: 15 additions & 0 deletions python/nx-cugraph/nx_cugraph/algorithms/centrality/degree_alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def degree_centrality(G):
return G._nodearray_to_dict(centrality)


@degree_centrality._should_run
def _(G):
return "Fast algorithm; not worth converting."


@not_implemented_for("undirected")
@networkx_algorithm(version_added="23.12")
def in_degree_centrality(G):
Expand All @@ -37,6 +42,11 @@ def in_degree_centrality(G):
return G._nodearray_to_dict(centrality)


@in_degree_centrality._should_run
def _(G):
return "Fast algorithm; not worth converting."


@not_implemented_for("undirected")
@networkx_algorithm(version_added="23.12")
def out_degree_centrality(G):
Expand All @@ -46,3 +56,8 @@ def out_degree_centrality(G):
deg = G._out_degrees_array()
centrality = deg * (1 / (len(G) - 1))
return G._nodearray_to_dict(centrality)


@out_degree_centrality._should_run
def _(G):
return "Fast algorithm; not worth converting."
Loading

0 comments on commit 63a76fa

Please sign in to comment.