From e9b1c1868b9f032db98be7929d21c715abc09e9a Mon Sep 17 00:00:00 2001 From: acostadon Date: Thu, 7 Apr 2022 09:41:41 -0700 Subject: [PATCH 01/17] added check and test for directed graph --- .../cugraph/cugraph/link_prediction/jaccard.py | 5 ++--- python/cugraph/cugraph/tests/test_jaccard.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/python/cugraph/cugraph/link_prediction/jaccard.py b/python/cugraph/cugraph/link_prediction/jaccard.py index 8c9ad6754db..2c4846626cc 100644 --- a/python/cugraph/cugraph/link_prediction/jaccard.py +++ b/python/cugraph/cugraph/link_prediction/jaccard.py @@ -108,9 +108,8 @@ def jaccard(input_graph, vertex_pair=None): >>> df = cugraph.jaccard(G) """ - if type(input_graph) is not Graph: - raise TypeError("input graph must a Graph") - + if input_graph.is_directed(): + raise TypeError("Input graph must a non-directed Graph.") if type(vertex_pair) == cudf.DataFrame: vertex_pair = renumber_vertex_pair(input_graph, vertex_pair) elif vertex_pair is not None: diff --git a/python/cugraph/cugraph/tests/test_jaccard.py b/python/cugraph/cugraph/tests/test_jaccard.py index 50bffe71fff..a3447a04dd4 100644 --- a/python/cugraph/cugraph/tests/test_jaccard.py +++ b/python/cugraph/cugraph/tests/test_jaccard.py @@ -155,6 +155,24 @@ def test_jaccard(read_csv, gpubenchmark): assert err == 0 +def test_directed_graph_check(read_csv): + M, _ = read_csv + + cu_M = cudf.DataFrame() + cu_M["src_0"] = cudf.Series(M["0"]) + cu_M["dst_0"] = cudf.Series(M["1"]) + cu_M["src_1"] = cu_M["src_0"] + 1000 + cu_M["dst_1"] = cu_M["dst_0"] + 1000 + G1 = cugraph.Graph(directed=True) + G1.from_cudf_edgelist(cu_M, source=["src_0", "src_1"], + destination=["dst_0", "dst_1"]) + + vertex_pair = cu_M[["src_0", "src_1", "dst_0", "dst_1"]] + vertex_pair = vertex_pair[:5] + with pytest.raises(TypeError): + df_res = cugraph.jaccard(G1,vertex_pair) + print(df_res) + def test_nx_jaccard_time(read_csv, gpubenchmark): M, _ = read_csv From c3736029bfd2956a950f24235c44462e9a13a936 Mon Sep 17 00:00:00 2001 From: acostadon Date: Thu, 7 Apr 2022 09:44:03 -0700 Subject: [PATCH 02/17] corrected error text --- python/cugraph/cugraph/link_prediction/jaccard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cugraph/cugraph/link_prediction/jaccard.py b/python/cugraph/cugraph/link_prediction/jaccard.py index 2c4846626cc..d1f504aac60 100644 --- a/python/cugraph/cugraph/link_prediction/jaccard.py +++ b/python/cugraph/cugraph/link_prediction/jaccard.py @@ -109,7 +109,7 @@ def jaccard(input_graph, vertex_pair=None): """ if input_graph.is_directed(): - raise TypeError("Input graph must a non-directed Graph.") + raise TypeError("Input must an undirected Graph.") if type(vertex_pair) == cudf.DataFrame: vertex_pair = renumber_vertex_pair(input_graph, vertex_pair) elif vertex_pair is not None: From 5ba7553b5bddc52b8d6f8768f28c2a2eafc15ff5 Mon Sep 17 00:00:00 2001 From: acostadon Date: Thu, 7 Apr 2022 10:01:43 -0700 Subject: [PATCH 03/17] fix style problems --- python/cugraph/cugraph/link_prediction/jaccard.py | 1 - python/cugraph/cugraph/tests/test_jaccard.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/cugraph/cugraph/link_prediction/jaccard.py b/python/cugraph/cugraph/link_prediction/jaccard.py index d1f504aac60..f538b60089f 100644 --- a/python/cugraph/cugraph/link_prediction/jaccard.py +++ b/python/cugraph/cugraph/link_prediction/jaccard.py @@ -12,7 +12,6 @@ # limitations under the License. import cudf -from cugraph.structure.graph_classes import Graph from cugraph.link_prediction import jaccard_wrapper from cugraph.utilities import (ensure_cugraph_obj_for_nx, df_edge_score_to_dictionary, diff --git a/python/cugraph/cugraph/tests/test_jaccard.py b/python/cugraph/cugraph/tests/test_jaccard.py index a3447a04dd4..a6fa499cb4c 100644 --- a/python/cugraph/cugraph/tests/test_jaccard.py +++ b/python/cugraph/cugraph/tests/test_jaccard.py @@ -170,9 +170,10 @@ def test_directed_graph_check(read_csv): vertex_pair = cu_M[["src_0", "src_1", "dst_0", "dst_1"]] vertex_pair = vertex_pair[:5] with pytest.raises(TypeError): - df_res = cugraph.jaccard(G1,vertex_pair) + df_res = cugraph.jaccard(G1, vertex_pair) print(df_res) + def test_nx_jaccard_time(read_csv, gpubenchmark): M, _ = read_csv From bd7c1ac233384c659040d7d3f216f289dfacfa56 Mon Sep 17 00:00:00 2001 From: acostadon Date: Fri, 8 Apr 2022 10:31:28 -0700 Subject: [PATCH 04/17] removed the check for directed graph only added test to bfs --- python/cugraph/cugraph/dask/traversal/bfs.py | 4 +- .../simpleDistributedGraph.py | 2 - .../cugraph/cugraph/tests/dask/test_mg_bfs.py | 65 +++++++++++++++++++ 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/python/cugraph/cugraph/dask/traversal/bfs.py b/python/cugraph/cugraph/dask/traversal/bfs.py index 539d385effd..43883073730 100644 --- a/python/cugraph/cugraph/dask/traversal/bfs.py +++ b/python/cugraph/cugraph/dask/traversal/bfs.py @@ -66,10 +66,10 @@ def bfs(input_graph, Parameters ---------- - input_graph : directed cugraph.Graph + input_graph : cugraph.Graph cuGraph graph instance, should contain the connectivity information as dask cudf edge list dataframe(edge weights are not used for this - algorithm). Undirected Graph not currently supported. + algorithm). start : Integer Specify starting vertex for breadth-first search; this function diff --git a/python/cugraph/cugraph/structure/graph_implementation/simpleDistributedGraph.py b/python/cugraph/cugraph/structure/graph_implementation/simpleDistributedGraph.py index 01616e397cf..203efd1bcb7 100644 --- a/python/cugraph/cugraph/structure/graph_implementation/simpleDistributedGraph.py +++ b/python/cugraph/cugraph/structure/graph_implementation/simpleDistributedGraph.py @@ -64,8 +64,6 @@ def __from_edgelist( ): if not isinstance(input_ddf, dask_cudf.DataFrame): raise TypeError("input should be a dask_cudf dataFrame") - if self.properties.directed is False: - raise TypeError("Undirected distributed graph not supported") s_col = source d_col = destination diff --git a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py index 19e345f1ee1..52c0db83c65 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py @@ -83,6 +83,71 @@ def modify_dataset(df): ): err = err + 1 assert err == 0 + print(dg) + + +@pytest.mark.skipif( + is_single_gpu(), reason="skipping MG testing on Single GPU system" +) +def test_dask_bfs_undirected(dask_client): + gc.collect() + + input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / + "netscience.csv").as_posix() + + print(f"dataset={input_data_path}") + chunksize = dcg.get_chunksize(input_data_path) + + ddf = dask_cudf.read_csv( + input_data_path, + chunksize=chunksize, + delimiter=" ", + names=["src", "dst", "value"], + dtype=["int32", "int32", "float32"], + ) + + def modify_dataset(df): + temp_df = cudf.DataFrame() + temp_df['src'] = df['src']+1000 + temp_df['dst'] = df['dst']+1000 + temp_df['value'] = df['value'] + return cudf.concat([df, temp_df]) + + meta = ddf._meta + ddf = ddf.map_partitions(modify_dataset, meta=meta) + + df = cudf.read_csv( + input_data_path, + delimiter=" ", + names=["src", "dst", "value"], + dtype=["int32", "int32", "float32"], + ) + + df = modify_dataset(df) + + g = cugraph.Graph(directed=False) + g.from_cudf_edgelist(df, "src", "dst") + + dg = cugraph.Graph(directed=False) + dg.from_dask_cudf_edgelist(ddf, "src", "dst") + expected_dist = cugraph.bfs(g, [0, 1000]) + result_dist = dcg.bfs(dg, [0, 1000]) + result_dist = result_dist.compute() + + compare_dist = expected_dist.merge( + result_dist, on="vertex", suffixes=["_local", "_dask"] + ) + + err = 0 + + for i in range(len(compare_dist)): + if ( + compare_dist["distance_local"].iloc[i] + != compare_dist["distance_dask"].iloc[i] + ): + err = err + 1 + assert err == 0 + assert dg.is_directed() == False @pytest.mark.skipif( From 80a8263f55d908711e983222b89452872f558617 Mon Sep 17 00:00:00 2001 From: acostadon Date: Fri, 8 Apr 2022 10:53:50 -0700 Subject: [PATCH 05/17] fixed style issue --- python/cugraph/cugraph/tests/dask/test_mg_bfs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py index 52c0db83c65..25321f097c4 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py @@ -147,7 +147,7 @@ def modify_dataset(df): ): err = err + 1 assert err == 0 - assert dg.is_directed() == False + assert dg.is_directed() @pytest.mark.skipif( From bf3cd44e71787f89ef9d71a0b6e95d9b9c2d1823 Mon Sep 17 00:00:00 2001 From: acostadon Date: Fri, 8 Apr 2022 11:24:17 -0700 Subject: [PATCH 06/17] removed print line --- python/cugraph/cugraph/tests/dask/test_mg_bfs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py index 25321f097c4..09850b4156d 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py @@ -83,7 +83,6 @@ def modify_dataset(df): ): err = err + 1 assert err == 0 - print(dg) @pytest.mark.skipif( @@ -147,7 +146,7 @@ def modify_dataset(df): ): err = err + 1 assert err == 0 - assert dg.is_directed() + assert not dg.is_directed() @pytest.mark.skipif( From 252ad49c7ca6dbe8ff295f8f056f2832d213063d Mon Sep 17 00:00:00 2001 From: acostadon Date: Fri, 8 Apr 2022 11:49:11 -0700 Subject: [PATCH 07/17] corrected copyright --- python/cugraph/cugraph/tests/dask/test_mg_bfs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py index 09850b4156d..3a82798bc6f 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at From 558306e8f49cd07e9c410a37721b30be1be3513d Mon Sep 17 00:00:00 2001 From: acostadon Date: Fri, 8 Apr 2022 11:53:59 -0700 Subject: [PATCH 08/17] fixed copyright --- python/cugraph/cugraph/tests/test_jaccard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cugraph/cugraph/tests/test_jaccard.py b/python/cugraph/cugraph/tests/test_jaccard.py index a6fa499cb4c..c76689442e7 100644 --- a/python/cugraph/cugraph/tests/test_jaccard.py +++ b/python/cugraph/cugraph/tests/test_jaccard.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at From d07c37598d421e415f1d4502cdea2f9766523fe0 Mon Sep 17 00:00:00 2001 From: acostadon Date: Mon, 18 Apr 2022 05:34:26 -0700 Subject: [PATCH 09/17] removed gc call from test --- python/cugraph/cugraph/tests/dask/test_mg_bfs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py index 3a82798bc6f..cd47ee1ae58 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py @@ -25,7 +25,6 @@ is_single_gpu(), reason="skipping MG testing on Single GPU system" ) def test_dask_bfs(dask_client): - gc.collect() input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / "netscience.csv").as_posix() From 51f55b48ea73a8b77f2a5dd739d28901e06ade03 Mon Sep 17 00:00:00 2001 From: acostadon Date: Wed, 20 Apr 2022 06:02:44 -0700 Subject: [PATCH 10/17] responded to review comments --- .../cugraph/link_prediction/jaccard.py | 2 +- .../cugraph/cugraph/tests/dask/test_mg_bfs.py | 19 ++++++++++++++++--- python/cugraph/cugraph/tests/test_jaccard.py | 5 ++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/python/cugraph/cugraph/link_prediction/jaccard.py b/python/cugraph/cugraph/link_prediction/jaccard.py index f538b60089f..10bfd35f252 100644 --- a/python/cugraph/cugraph/link_prediction/jaccard.py +++ b/python/cugraph/cugraph/link_prediction/jaccard.py @@ -108,7 +108,7 @@ def jaccard(input_graph, vertex_pair=None): """ if input_graph.is_directed(): - raise TypeError("Input must an undirected Graph.") + raise ValueError("Input must be an undirected Graph.") if type(vertex_pair) == cudf.DataFrame: vertex_pair = renumber_vertex_pair(input_graph, vertex_pair) elif vertex_pair is not None: diff --git a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py index 2c21ffee34d..5a3508ad007 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest import cugraph.dask as dcg import gc # import pytest @@ -20,11 +21,23 @@ # from cugraph.dask.common.mg_utils import is_single_gpu from cugraph.tests.utils import RAPIDS_DATASET_ROOT_DIR_PATH +# ============================================================================= +# Pytest Setup / Teardown - called for each test function +# ============================================================================= + + +def setup_function(): + gc.collect() + + +IS_DIRECTED = [True, False] + # @pytest.mark.skipif( # is_single_gpu(), reason="skipping MG testing on Single GPU system" # ) -def test_dask_bfs(dask_client): +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_dask_bfs(dask_client, directed): input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / "netscience.csv").as_posix() @@ -59,10 +72,10 @@ def modify_dataset(df): df = modify_dataset(df) - g = cugraph.Graph(directed=True) + g = cugraph.Graph(directed=directed) g.from_cudf_edgelist(df, "src", "dst") - dg = cugraph.Graph(directed=True) + dg = cugraph.Graph(directed=directed) dg.from_dask_cudf_edgelist(ddf, "src", "dst") expected_dist = cugraph.bfs(g, [0, 1000]) diff --git a/python/cugraph/cugraph/tests/test_jaccard.py b/python/cugraph/cugraph/tests/test_jaccard.py index c76689442e7..b7ce514d5f9 100644 --- a/python/cugraph/cugraph/tests/test_jaccard.py +++ b/python/cugraph/cugraph/tests/test_jaccard.py @@ -169,9 +169,8 @@ def test_directed_graph_check(read_csv): vertex_pair = cu_M[["src_0", "src_1", "dst_0", "dst_1"]] vertex_pair = vertex_pair[:5] - with pytest.raises(TypeError): - df_res = cugraph.jaccard(G1, vertex_pair) - print(df_res) + with pytest.raises(ValueError): + cugraph.jaccard(G1, vertex_pair) def test_nx_jaccard_time(read_csv, gpubenchmark): From 152ebdb4a286b1197c539c5767f3596b4392ec62 Mon Sep 17 00:00:00 2001 From: acostadon Date: Thu, 21 Apr 2022 10:09:00 -0700 Subject: [PATCH 11/17] Added parameterization for directed/undirected graphs --- .../cugraph/cugraph/tests/dask/test_mg_bfs.py | 9 +++---- .../cugraph/tests/dask/test_mg_comms.py | 24 ++++++++++++++----- .../tests/dask/test_mg_connectivity.py | 20 ++++++++++++---- .../cugraph/tests/dask/test_mg_degree.py | 19 +++++++++++---- .../cugraph/tests/dask/test_mg_hits.py | 16 +++++++++---- .../tests/dask/test_mg_katz_centrality.py | 18 +++++++++++--- .../dask/test_mg_neighborhood_sampling.py | 21 ++++++++++------ .../cugraph/tests/dask/test_mg_pagerank.py | 8 ++++--- .../cugraph/tests/dask/test_mg_renumber.py | 20 ++++++++++------ .../cugraph/tests/dask/test_mg_sssp.py | 20 ++++++++++++---- .../cugraph/tests/dask/test_mg_utility.py | 10 +++++--- 11 files changed, 136 insertions(+), 49 deletions(-) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py index 5a3508ad007..4d02f8ca17f 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py @@ -34,7 +34,7 @@ def setup_function(): # @pytest.mark.skipif( -# is_single_gpu(), reason="skipping MG testing on Single GPU system" +# is_single_gpu(), reason="skipping MG testing on Single GconPU system" # ) @pytest.mark.parametrize("directed", IS_DIRECTED) def test_dask_bfs(dask_client, directed): @@ -100,7 +100,8 @@ def modify_dataset(df): # @pytest.mark.skipif( # is_single_gpu(), reason="skipping MG testing on Single GPU system" # ) -def test_dask_bfs_multi_column_depthlimit(dask_client): +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_dask_bfs_multi_column_depthlimit(dask_client, directed): gc.collect() input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / @@ -127,10 +128,10 @@ def test_dask_bfs_multi_column_depthlimit(dask_client): df['src_b'] = df['src_a'] + 1000 df['dst_b'] = df['dst_a'] + 1000 - g = cugraph.Graph(directed=True) + g = cugraph.Graph(directed=directed) g.from_cudf_edgelist(df, ["src_a", "src_b"], ["dst_a", "dst_b"]) - dg = cugraph.Graph(directed=True) + dg = cugraph.Graph(directed=directed) dg.from_dask_cudf_edgelist(ddf, ["src_a", "src_b"], ["dst_a", "dst_b"]) start = cudf.DataFrame() diff --git a/python/cugraph/cugraph/tests/dask/test_mg_comms.py b/python/cugraph/cugraph/tests/dask/test_mg_comms.py index 2c02779f199..cb3dfdc3eb7 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_comms.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_comms.py @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest import cugraph.dask as dcg import gc # import pytest @@ -20,12 +21,23 @@ # from cugraph.dask.common.mg_utils import is_single_gpu from cugraph.tests.utils import RAPIDS_DATASET_ROOT_DIR_PATH +# ============================================================================= +# Pytest Setup / Teardown - called for each test function +# ============================================================================= + + +def setup_function(): + gc.collect() + + +IS_DIRECTED = [True, False] + # @pytest.mark.skipif( # is_single_gpu(), reason="skipping MG testing on Single GPU system" # ) -def test_dask_pagerank(dask_client): - gc.collect() +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_dask_pagerank(dask_client, directed): # Initialize and run pagerank on two distributed graphs # with same communicator @@ -48,7 +60,7 @@ def test_dask_pagerank(dask_client): dtype=["int32", "int32", "float32"], ) - dg1 = cugraph.Graph(directed=True) + dg1 = cugraph.Graph(directed=directed) dg1.from_dask_cudf_edgelist(ddf1, "src", "dst") result_pr1 = dcg.pagerank(dg1).compute() @@ -61,7 +73,7 @@ def test_dask_pagerank(dask_client): dtype=["int32", "int32", "float32"], ) - dg2 = cugraph.Graph(directed=True) + dg2 = cugraph.Graph(directed=directed) dg2.from_dask_cudf_edgelist(ddf2, "src", "dst") result_pr2 = dcg.pagerank(dg2).compute() @@ -74,7 +86,7 @@ def test_dask_pagerank(dask_client): dtype=["int32", "int32", "float32"], ) - g1 = cugraph.Graph(directed=True) + g1 = cugraph.Graph(directed=directed) g1.from_cudf_edgelist(df1, "src", "dst") expected_pr1 = cugraph.pagerank(g1) @@ -85,7 +97,7 @@ def test_dask_pagerank(dask_client): dtype=["int32", "int32", "float32"], ) - g2 = cugraph.Graph(directed=True) + g2 = cugraph.Graph(directed=directed) g2.from_cudf_edgelist(df2, "src", "dst") expected_pr2 = cugraph.pagerank(g2) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_connectivity.py b/python/cugraph/cugraph/tests/dask/test_mg_connectivity.py index 9427b18aa92..fbe04da6348 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_connectivity.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_connectivity.py @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest import cugraph.dask as dcg import gc # import pytest @@ -20,12 +21,23 @@ # from cugraph.dask.common.mg_utils import is_single_gpu from cugraph.tests.utils import RAPIDS_DATASET_ROOT_DIR_PATH +# ============================================================================= +# Pytest Setup / Teardown - called for each test function +# ============================================================================= + + +def setup_function(): + gc.collect() + + +IS_DIRECTED = [True, False] + # @pytest.mark.skipif( # is_single_gpu(), reason="skipping MG testing on Single GPU system" # ) -def test_dask_wcc(dask_client): - gc.collect() +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_dask_wcc(dask_client, directed): input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / "netscience.csv").as_posix() @@ -47,10 +59,10 @@ def test_dask_wcc(dask_client): dtype=["int32", "int32", "float32"], ) - g = cugraph.Graph(directed=True) + g = cugraph.Graph(directed=directed) g.from_cudf_edgelist(df, "src", "dst", renumber=True) - dg = cugraph.Graph(directed=True) + dg = cugraph.Graph(directed=directed) dg.from_dask_cudf_edgelist(ddf, "src", "dst") expected_dist = cugraph.weakly_connected_components(g) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_degree.py b/python/cugraph/cugraph/tests/dask/test_mg_degree.py index b0b46e93d10..ce27c6e6c95 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_degree.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_degree.py @@ -21,12 +21,23 @@ from cugraph.dask.common.mg_utils import is_single_gpu from cugraph.tests.utils import RAPIDS_DATASET_ROOT_DIR_PATH +# ============================================================================= +# Pytest Setup / Teardown - called for each test function +# ============================================================================= + + +def setup_function(): + gc.collect() + + +IS_DIRECTED = [True, False] + @pytest.mark.skipif( is_single_gpu(), reason="skipping MG testing on Single GPU system" ) -def test_dask_mg_degree(dask_client): - gc.collect() +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_dask_mg_degree(dask_client, directed): input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / "karate-asymmetric.csv").as_posix() @@ -49,10 +60,10 @@ def test_dask_mg_degree(dask_client): dtype=["int32", "int32", "float32"], ) - dg = cugraph.Graph(directed=True) + dg = cugraph.Graph(directed=directed) dg.from_dask_cudf_edgelist(ddf, "src", "dst") - g = cugraph.Graph(directed=True) + g = cugraph.Graph(directed=directed) g.from_cudf_edgelist(df, "src", "dst") merge_df_in = ( diff --git a/python/cugraph/cugraph/tests/dask/test_mg_hits.py b/python/cugraph/cugraph/tests/dask/test_mg_hits.py index 124bc5066cb..dde91690b7a 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_hits.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_hits.py @@ -19,6 +19,7 @@ # from cugraph.dask.common.mg_utils import is_single_gpu from cugraph.tests import utils + # ============================================================================= # Pytest Setup / Teardown - called for each test function # ============================================================================= @@ -28,6 +29,9 @@ def setup_function(): gc.collect() +IS_DIRECTED = [True, False] + + # ============================================================================= # Pytest fixtures # ============================================================================= @@ -38,6 +42,7 @@ def setup_function(): fixture_params = utils.genFixtureParamsProduct((datasets, "graph_file"), ([50], "max_iter"), ([1.0e-6], "tol"), + (IS_DIRECTED, "directed") ) @@ -47,7 +52,10 @@ def input_combo(request): Simply return the current combination of params as a dictionary for use in tests or other parameterized fixtures. """ - parameters = dict(zip(("graph_file", "max_iter", "tol"), request.param)) + parameters = dict(zip(("graph_file", + "max_iter", + "tol", + "directed"), request.param)) return parameters @@ -60,9 +68,9 @@ def input_expected_output(input_combo): """ input_data_path = input_combo["graph_file"] - + directed = input_combo["directed"] G = utils.generate_cugraph_graph_from_file( - input_data_path) + input_data_path, directed=directed) sg_cugraph_hits = cugraph.hits( G, input_combo["max_iter"], @@ -83,7 +91,7 @@ def input_expected_output(input_combo): dtype=["int32", "int32", "float32"], ) - dg = cugraph.Graph(directed=True) + dg = cugraph.Graph(directed=directed) dg.from_dask_cudf_edgelist( ddf, source='src', destination='dst', edge_attr='value', renumber=True) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_katz_centrality.py b/python/cugraph/cugraph/tests/dask/test_mg_katz_centrality.py index 1b0f89c1fd7..76cb6551a29 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_katz_centrality.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_katz_centrality.py @@ -22,11 +22,23 @@ from cugraph.tests.utils import RAPIDS_DATASET_ROOT_DIR_PATH +# ============================================================================= +# Pytest Setup / Teardown - called for each test function +# ============================================================================= + + +def setup_function(): + gc.collect() + + +IS_DIRECTED = [True, False] + + @pytest.mark.skipif( is_single_gpu(), reason="skipping MG testing on Single GPU system" ) -def test_dask_katz_centrality(dask_client): - gc.collect() +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_dask_katz_centrality(dask_client, directed): input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / "karate.csv").as_posix() @@ -56,7 +68,7 @@ def test_dask_katz_centrality(dask_client): from cugraph.tests import utils NM = utils.read_csv_for_nx(input_data_path) Gnx = nx.from_pandas_edgelist( - NM, create_using=nx.DiGraph(), source="0", target="1" + NM, create_using=nx.Graph(directed=directed), source="0", target="1" ) nk = nx.katz_centrality(Gnx, alpha=katz_alpha) import pandas as pd diff --git a/python/cugraph/cugraph/tests/dask/test_mg_neighborhood_sampling.py b/python/cugraph/cugraph/tests/dask/test_mg_neighborhood_sampling.py index 25838445e11..e77e8564020 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_neighborhood_sampling.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_neighborhood_sampling.py @@ -28,6 +28,9 @@ def setup_function(): gc.collect() +IS_DIRECTED = [True, False] + + # datasets = utils.RAPIDS_DATASET_ROOT_DIR_PATH/"karate.csv" datasets = utils.DATASETS_SMALL fixture_params = utils.genFixtureParamsProduct((datasets, "graph_file")) @@ -43,10 +46,12 @@ def _get_param_args(param_name, param_values): [pytest.param(v, id=f"{param_name}={v}") for v in param_values]) -@pytest.mark.skipif( - is_single_gpu(), reason="skipping MG testing on Single GPU system" -) -def test_mg_neighborhood_sampling_simple(dask_client): +#@pytest.mark.skipif( +# is_single_gpu(), reason="skipping MG testing on Single GPU system" +#) +@pytest.mark.skip(reason="Currently hangs, awaiting fix in algo") +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_mg_neighborhood_sampling_simple(dask_client, directed): from cugraph.experimental.dask import uniform_neighborhood_sampling @@ -60,7 +65,7 @@ def test_mg_neighborhood_sampling_simple(dask_client): }) ddf = dask_cudf.from_cudf(df, npartitions=2) - G = cugraph.Graph(directed=True) + G = cugraph.Graph(directed=directed) G.from_dask_cudf_edgelist(ddf, "src", "dst", "value") # TODO: Incomplete, include more testing for tree graph as well as @@ -90,7 +95,9 @@ def test_mg_neighborhood_sampling_simple(dask_client): @pytest.mark.skipif( is_single_gpu(), reason="skipping MG testing on Single GPU system" ) -def test_mg_neighborhood_sampling_tree(dask_client): +@pytest.mark.parametrize("directed", IS_DIRECTED) +@pytest.mark.skip(reason="Currently hangs, awaiting fix in algo") +def test_mg_neighborhood_sampling_tree(dask_client, directed): from cugraph.experimental.dask import uniform_neighborhood_sampling @@ -106,7 +113,7 @@ def test_mg_neighborhood_sampling_tree(dask_client): dtype=["int32", "int32", "float32"], ) - G = cugraph.Graph(directed=True) + G = cugraph.Graph(directed=directed) G.from_dask_cudf_edgelist(ddf, "src", "dst", "value") # TODO: Incomplete, include more testing for tree graph as well as diff --git a/python/cugraph/cugraph/tests/dask/test_mg_pagerank.py b/python/cugraph/cugraph/tests/dask/test_mg_pagerank.py index 957e9a7747e..f03a77a46f6 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_pagerank.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_pagerank.py @@ -48,13 +48,15 @@ def personalize(vertices, personalization_perc): PERSONALIZATION_PERC = [0, 10, 50] +IS_DIRECTED = [True, False] # @pytest.mark.skipif( # is_single_gpu(), reason="skipping MG testing on Single GPU system" # ) @pytest.mark.parametrize("personalization_perc", PERSONALIZATION_PERC) -def test_dask_pagerank(dask_client, personalization_perc): +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_dask_pagerank(dask_client, personalization_perc, directed): gc.collect() input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / @@ -77,10 +79,10 @@ def test_dask_pagerank(dask_client, personalization_perc): dtype=["int32", "int32", "float32"], ) - g = cugraph.Graph(directed=True) + g = cugraph.Graph(directed=directed) g.from_cudf_edgelist(df, "src", "dst") - dg = cugraph.Graph(directed=True) + dg = cugraph.Graph(directed=directed) dg.from_dask_cudf_edgelist(ddf, "src", "dst") personalization = None diff --git a/python/cugraph/cugraph/tests/dask/test_mg_renumber.py b/python/cugraph/cugraph/tests/dask/test_mg_renumber.py index a0e428d1d65..2235c9394ae 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_renumber.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_renumber.py @@ -38,6 +38,9 @@ def setup_function(): gc.collect() +IS_DIRECTED = [True, False] + + @pytest.mark.skipif( is_single_gpu(), reason="skipping MG testing on Single GPU system" ) @@ -130,7 +133,8 @@ def test_mg_renumber_add_internal_vertex_id(graph_file, dask_client): @pytest.mark.skipif( is_single_gpu(), reason="skipping MG testing on Single GPU system" ) -def test_dask_pagerank(dask_client): +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_dask_pagerank(dask_client, directed): pandas.set_option("display.max_rows", 10000) input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / @@ -152,10 +156,10 @@ def test_dask_pagerank(dask_client): dtype=["int32", "int32", "float32"], ) - g = cugraph.Graph(directed=True) + g = cugraph.Graph(directed=directed) g.from_cudf_edgelist(df, "src", "dst") - dg = cugraph.Graph(directed=True) + dg = cugraph.Graph(directed=directed) dg.from_dask_cudf_edgelist(ddf, "src", "dst") expected_pr = cugraph.pagerank(g) @@ -185,7 +189,8 @@ def test_dask_pagerank(dask_client): is_single_gpu(), reason="skipping MG testing on Single GPU system" ) @pytest.mark.parametrize("renumber", [False]) -def test_directed_graph_renumber_false(renumber, dask_client): +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_directed_graph_renumber_false(renumber, dask_client, directed): input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / "karate.csv").as_posix() chunksize = dcg.get_chunksize(input_data_path) @@ -197,7 +202,7 @@ def test_directed_graph_renumber_false(renumber, dask_client): names=["src", "dst", "value"], dtype=["int32", "int32", "float32"], ) - dg = cugraph.Graph(directed=True) + dg = cugraph.Graph(directed=directed) with pytest.raises(ValueError): dg.from_dask_cudf_edgelist(ddf, "src", "dst", renumber=renumber) @@ -207,7 +212,8 @@ def test_directed_graph_renumber_false(renumber, dask_client): is_single_gpu(), reason="skipping MG testing on Single GPU system" ) @pytest.mark.parametrize("renumber", [False]) -def test_multi_directed_graph_renumber_false(renumber, dask_client): +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_multi_directed_graph_renumber_false(renumber, dask_client, directed): input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / "karate_multi_edge.csv").as_posix() chunksize = dcg.get_chunksize(input_data_path) @@ -219,7 +225,7 @@ def test_multi_directed_graph_renumber_false(renumber, dask_client): names=["src", "dst", "value"], dtype=["int32", "int32", "float32"], ) - dg = cugraph.MultiGraph(directed=True) + dg = cugraph.MultiGraph(directed=directed) with pytest.raises(ValueError): dg.from_dask_cudf_edgelist(ddf, "src", "dst", renumber=renumber) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_sssp.py b/python/cugraph/cugraph/tests/dask/test_mg_sssp.py index 656c91d1754..c8a2361b6ad 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_sssp.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_sssp.py @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest import cugraph.dask as dcg import gc # import pytest @@ -20,12 +21,23 @@ # from cugraph.dask.common.mg_utils import is_single_gpu from cugraph.tests.utils import RAPIDS_DATASET_ROOT_DIR_PATH +# ============================================================================= +# Pytest Setup / Teardown - called for each test function +# ============================================================================= + + +def setup_function(): + gc.collect() + + +IS_DIRECTED = [True, False] + # @pytest.mark.skipif( # is_single_gpu(), reason="skipping MG testing on Single GPU system" # ) -def test_dask_sssp(dask_client): - gc.collect() +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_dask_sssp(dask_client, directed): input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / "netscience.csv").as_posix() @@ -47,10 +59,10 @@ def test_dask_sssp(dask_client): dtype=["int32", "int32", "float32"], ) - g = cugraph.Graph(directed=True) + g = cugraph.Graph(directed=directed) g.from_cudf_edgelist(df, "src", "dst", "value", renumber=True) - dg = cugraph.Graph(directed=True) + dg = cugraph.Graph(directed=directed) dg.from_dask_cudf_edgelist(ddf, "src", "dst", "value") expected_dist = cugraph.sssp(g, 0) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_utility.py b/python/cugraph/cugraph/tests/dask/test_mg_utility.py index 732c785df68..4aec0ba93c1 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_utility.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_utility.py @@ -35,10 +35,14 @@ def setup_function(): gc.collect() +IS_DIRECTED = [True, False] + + # @pytest.mark.skipif( # is_single_gpu(), reason="skipping MG testing on Single GPU system" # ) -def test_from_edgelist(dask_client): +@pytest.mark.parametrize("directed", IS_DIRECTED) +def test_from_edgelist(dask_client, directed): input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / "karate.csv").as_posix() print(f"dataset={input_data_path}") @@ -53,9 +57,9 @@ def test_from_edgelist(dask_client): dg1 = cugraph.from_edgelist( ddf, source="src", destination="dst", edge_attr="value", - create_using=cugraph.Graph(directed=True)) + create_using=cugraph.Graph(directed=directed)) - dg2 = cugraph.Graph(directed=True) + dg2 = cugraph.Graph(directed=directed) dg2.from_dask_cudf_edgelist( ddf, source="src", destination="dst", edge_attr="value" ) From 8cea2bdb64e42424f6e9989691d9dc87cce92f87 Mon Sep 17 00:00:00 2001 From: acostadon Date: Sun, 24 Apr 2022 09:27:19 -0700 Subject: [PATCH 12/17] fixed style check problem --- .../cugraph/tests/dask/test_mg_neighborhood_sampling.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_neighborhood_sampling.py b/python/cugraph/cugraph/tests/dask/test_mg_neighborhood_sampling.py index e77e8564020..4dcba8d6ee9 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_neighborhood_sampling.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_neighborhood_sampling.py @@ -46,9 +46,9 @@ def _get_param_args(param_name, param_values): [pytest.param(v, id=f"{param_name}={v}") for v in param_values]) -#@pytest.mark.skipif( +# @pytest.mark.skipif( # is_single_gpu(), reason="skipping MG testing on Single GPU system" -#) +# ) @pytest.mark.skip(reason="Currently hangs, awaiting fix in algo") @pytest.mark.parametrize("directed", IS_DIRECTED) def test_mg_neighborhood_sampling_simple(dask_client, directed): From 55b7a5deaf922e00f9623cd4ff6f7065b214f715 Mon Sep 17 00:00:00 2001 From: acostadon Date: Sun, 24 Apr 2022 17:54:45 -0700 Subject: [PATCH 13/17] removed digraph specific comments and created undirected test for louvain --- .../dask/centrality/katz_centrality.py | 2 +- .../cugraph/dask/link_analysis/pagerank.py | 2 +- .../dask/sampling/neighborhood_sampling.py | 2 +- python/cugraph/cugraph/dask/traversal/sssp.py | 3 +- .../cugraph/tests/dask/test_mg_louvain.py | 54 +++++++++++++++++-- 5 files changed, 55 insertions(+), 8 deletions(-) diff --git a/python/cugraph/cugraph/dask/centrality/katz_centrality.py b/python/cugraph/cugraph/dask/centrality/katz_centrality.py index 1fd3602593e..2897450a7ae 100644 --- a/python/cugraph/cugraph/dask/centrality/katz_centrality.py +++ b/python/cugraph/cugraph/dask/centrality/katz_centrality.py @@ -72,7 +72,7 @@ def katz_centrality(input_graph, ---------- input_graph : cuGraph.Graph cuGraph graph descriptor with connectivity information. The graph can - contain either directed (DiGraph) or undirected edges (Graph). + contain either directed or undirected edges. alpha : float, optional (default=None) Attenuation factor. If alpha is not specified then diff --git a/python/cugraph/cugraph/dask/link_analysis/pagerank.py b/python/cugraph/cugraph/dask/link_analysis/pagerank.py index fda70deb2ac..6805d8690ce 100644 --- a/python/cugraph/cugraph/dask/link_analysis/pagerank.py +++ b/python/cugraph/cugraph/dask/link_analysis/pagerank.py @@ -74,7 +74,7 @@ def pagerank(input_graph, input_graph : cugraph.DiGraph cuGraph graph descriptor, should contain the connectivity information as dask cudf edge list dataframe(edge weights are not used for this - algorithm). Undirected Graph not currently supported. + algorithm). alpha : float, optional (default=0.85) The damping factor alpha represents the probability to follow an diff --git a/python/cugraph/cugraph/dask/sampling/neighborhood_sampling.py b/python/cugraph/cugraph/dask/sampling/neighborhood_sampling.py index b7e842c6f31..fb79ada22fd 100644 --- a/python/cugraph/cugraph/dask/sampling/neighborhood_sampling.py +++ b/python/cugraph/cugraph/dask/sampling/neighborhood_sampling.py @@ -95,7 +95,7 @@ def EXPERIMENTAL__uniform_neighborhood(input_graph, Parameters ---------- - input_graph : cugraph.DiGraph + input_graph : cugraph.Graph cuGraph graph, which contains connectivity information as dask cudf edge list dataframe diff --git a/python/cugraph/cugraph/dask/traversal/sssp.py b/python/cugraph/cugraph/dask/traversal/sssp.py index dddd390fb9e..d174f02dc4a 100644 --- a/python/cugraph/cugraph/dask/traversal/sssp.py +++ b/python/cugraph/cugraph/dask/traversal/sssp.py @@ -63,10 +63,9 @@ def sssp(input_graph, source): Parameters ---------- - input_graph : directed cugraph.Graph + input_graph : cugraph.Graph cuGraph graph descriptor, should contain the connectivity information as dask cudf edge list dataframe. - Undirected Graph not currently supported. source : Integer Specify source vertex diff --git a/python/cugraph/cugraph/tests/dask/test_mg_louvain.py b/python/cugraph/cugraph/tests/dask/test_mg_louvain.py index fbf3dab90e2..de22bba2077 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_louvain.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_louvain.py @@ -49,6 +49,7 @@ def setFixtureParamNames(*args, **kwargs): def daskGraphFromDataset(request, dask_client): """ Returns a new dask dataframe created from the dataset file param. + This creates un undirected Graph. """ # Since parameterized fixtures do not assign param names to param values, # manually call the helper to do so. @@ -69,15 +70,43 @@ def daskGraphFromDataset(request, dask_client): return dg +@pytest.fixture(scope="module", + params=utils.DATASETS_UNDIRECTED, + ids=[f"dataset={d.as_posix()}" + for d in utils.DATASETS_UNDIRECTED]) +def uddaskGraphFromDataset(request, dask_client): + """ + Returns a new dask dataframe created from the dataset file param. + This creates un undirected Graph. + """ + # Since parameterized fixtures do not assign param names to param + # values, manually call the helper to do so. + setFixtureParamNames(request, ["dataset"]) + dataset = request.param + + chunksize = dcg.get_chunksize(dataset) + ddf = dask_cudf.read_csv( + dataset, + chunksize=chunksize, + delimiter=" ", + names=["src", "dst", "value"], + dtype=["int32", "int32", "float32"], + ) + + dg = cugraph.Graph(directed=False) + dg.from_dask_cudf_edgelist(ddf, "src", "dst") + return dg + + ############################################################################### # Tests # @pytest.mark.skipif( # is_single_gpu(), reason="skipping MG testing on Single GPU system" # ) def test_mg_louvain_with_edgevals(daskGraphFromDataset): - # FIXME: daskGraphFromDataset returns a DiGraph, which Louvain is currently - # accepting. In the future, an MNMG symmeterize will need to be called to - # create a Graph for Louvain. + # FIXME: daskGraphFromDataset returns a Directed graph, which Louvain is + # currently accepting. In the future, an MNMG symmeterize will need to + # be called to create a Graph for Louvain. parts, mod = dcg.louvain(daskGraphFromDataset) # FIXME: either call Nx with the same dataset and compare results, or @@ -86,3 +115,22 @@ def test_mg_louvain_with_edgevals(daskGraphFromDataset): print(parts.compute()) print(mod) print() + + +############################################################################### +# Tests +# @pytest.mark.skipif( +# is_single_gpu(), reason="skipping MG testing on Single GPU system" +# ) +def test_mg_udlouvain_with_edgevals(uddaskGraphFromDataset): + # FIXME: uddaskGraphFromDataset returns an undirected Graph, which Louvain + # is currently accepting. In the future, an MNMG symmeterize will + # need to be called to create a Graph for Louvain. + parts, mod = dcg.louvain(uddaskGraphFromDataset) + + # FIXME: either call Nx with the same dataset and compare results, or + # hardcode golden results to compare to. + print() + print(parts.compute()) + print(mod) + print() From eff8a0c077a7ed70cf5b8d53934a8399844a092a Mon Sep 17 00:00:00 2001 From: acostadon Date: Wed, 27 Apr 2022 11:42:17 -0700 Subject: [PATCH 14/17] corrected a typo --- python/cugraph/cugraph/tests/dask/test_mg_bfs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py index 4d02f8ca17f..f5aa1a05b98 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_bfs.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_bfs.py @@ -34,7 +34,7 @@ def setup_function(): # @pytest.mark.skipif( -# is_single_gpu(), reason="skipping MG testing on Single GconPU system" +# is_single_gpu(), reason="skipping MG testing on Single GPU system" # ) @pytest.mark.parametrize("directed", IS_DIRECTED) def test_dask_bfs(dask_client, directed): From 827f6bd18d0e6ceba513c7306d96075bacfdedee Mon Sep 17 00:00:00 2001 From: acostadon Date: Sun, 1 May 2022 17:45:45 -0700 Subject: [PATCH 15/17] fixed test to use digraph and graph instead of directed param per comment --- .../cugraph/tests/dask/test_mg_katz_centrality.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_katz_centrality.py b/python/cugraph/cugraph/tests/dask/test_mg_katz_centrality.py index 76cb6551a29..97b5b56fe9a 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_katz_centrality.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_katz_centrality.py @@ -67,9 +67,14 @@ def test_dask_katz_centrality(dask_client, directed): import networkx as nx from cugraph.tests import utils NM = utils.read_csv_for_nx(input_data_path) - Gnx = nx.from_pandas_edgelist( - NM, create_using=nx.Graph(directed=directed), source="0", target="1" - ) + if directed: + Gnx = nx.from_pandas_edgelist( + NM, create_using=nx.DiGraph(), source="0", target="1" + ) + else: + Gnx = nx.from_pandas_edgelist( + NM, create_using=nx.Graph(), source="0", target="1" + ) nk = nx.katz_centrality(Gnx, alpha=katz_alpha) import pandas as pd pdf = pd.DataFrame(nk.items(), columns=['vertex', 'katz_centrality']) From a67e9bdd5ce3dc08600878b5bb4ec5678ba308f4 Mon Sep 17 00:00:00 2001 From: acostadon Date: Sun, 1 May 2022 18:18:02 -0700 Subject: [PATCH 16/17] removed FIXME, changed test name per comments --- python/cugraph/cugraph/tests/dask/test_mg_louvain.py | 3 --- python/cugraph/cugraph/tests/dask/test_mg_renumber.py | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_louvain.py b/python/cugraph/cugraph/tests/dask/test_mg_louvain.py index de22bba2077..43389c0f679 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_louvain.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_louvain.py @@ -123,9 +123,6 @@ def test_mg_louvain_with_edgevals(daskGraphFromDataset): # is_single_gpu(), reason="skipping MG testing on Single GPU system" # ) def test_mg_udlouvain_with_edgevals(uddaskGraphFromDataset): - # FIXME: uddaskGraphFromDataset returns an undirected Graph, which Louvain - # is currently accepting. In the future, an MNMG symmeterize will - # need to be called to create a Graph for Louvain. parts, mod = dcg.louvain(uddaskGraphFromDataset) # FIXME: either call Nx with the same dataset and compare results, or diff --git a/python/cugraph/cugraph/tests/dask/test_mg_renumber.py b/python/cugraph/cugraph/tests/dask/test_mg_renumber.py index 2235c9394ae..31fed280004 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_renumber.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_renumber.py @@ -190,7 +190,7 @@ def test_dask_pagerank(dask_client, directed): ) @pytest.mark.parametrize("renumber", [False]) @pytest.mark.parametrize("directed", IS_DIRECTED) -def test_directed_graph_renumber_false(renumber, dask_client, directed): +def test_graph_renumber_false(renumber, dask_client, directed): input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / "karate.csv").as_posix() chunksize = dcg.get_chunksize(input_data_path) @@ -213,7 +213,7 @@ def test_directed_graph_renumber_false(renumber, dask_client, directed): ) @pytest.mark.parametrize("renumber", [False]) @pytest.mark.parametrize("directed", IS_DIRECTED) -def test_multi_directed_graph_renumber_false(renumber, dask_client, directed): +def test_multi_graph_renumber_false(renumber, dask_client, directed): input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH / "karate_multi_edge.csv").as_posix() chunksize = dcg.get_chunksize(input_data_path) From 5952991db310b041e7d898302ca09e224fe39884 Mon Sep 17 00:00:00 2001 From: acostadon Date: Tue, 3 May 2022 09:15:41 -0700 Subject: [PATCH 17/17] added comment to explain that the test will always throw ValueError with renumber False --- python/cugraph/cugraph/tests/dask/test_mg_renumber.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/cugraph/cugraph/tests/dask/test_mg_renumber.py b/python/cugraph/cugraph/tests/dask/test_mg_renumber.py index 31fed280004..d21b96cf4c5 100644 --- a/python/cugraph/cugraph/tests/dask/test_mg_renumber.py +++ b/python/cugraph/cugraph/tests/dask/test_mg_renumber.py @@ -227,6 +227,8 @@ def test_multi_graph_renumber_false(renumber, dask_client, directed): ) dg = cugraph.MultiGraph(directed=directed) + # ValueError always thrown since renumber must be True with + # MNMG algorithms with pytest.raises(ValueError): dg.from_dask_cudf_edgelist(ddf, "src", "dst", renumber=renumber)