From a1f48b959ebfcf24bf0d924e316b953e77e6a857 Mon Sep 17 00:00:00 2001 From: BradReesWork Date: Tue, 30 Nov 2021 15:00:42 -0500 Subject: [PATCH 1/9] updated ignore list --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index a2f8cab424b..ae27b8e5047 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ __pycache__ .cache .coverage .vscode +.lock *.swp *.pytest_cache DartConfiguration.tcl @@ -32,6 +33,9 @@ dist/ cugraph.egg-info/ python/build python/cugraph/bindings/*.cpp + +## pylibcugraph build directories & artifacts +python/pylibcugraph/pylibcugraph.egg-info ## Patching *.diff @@ -82,6 +86,8 @@ python/_external_repositories/ # created by Dask tests python/dask-worker-space +python/cugraph/cugraph/dask-worker-space +python/cugraph/cugraph/tests/dask-worker-space # Sphinx docs & build artifacts docs/cugraph/source/api_docs/api/* From e3e371060400a329fc33a9e71fafade6e9ac797c Mon Sep 17 00:00:00 2001 From: BradReesWork Date: Wed, 1 Dec 2021 10:25:15 -0500 Subject: [PATCH 2/9] improved ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ae27b8e5047..fa75800401a 100644 --- a/.gitignore +++ b/.gitignore @@ -86,6 +86,7 @@ python/_external_repositories/ # created by Dask tests python/dask-worker-space +python/cugraph/dask-worker-space python/cugraph/cugraph/dask-worker-space python/cugraph/cugraph/tests/dask-worker-space From 7b50875e17ef3df6cb5164be6c8c0bfb8f881d44 Mon Sep 17 00:00:00 2001 From: BradReesWork Date: Wed, 1 Dec 2021 10:25:26 -0500 Subject: [PATCH 3/9] added reference to cuda 11.5 --- SOURCEBUILD.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/SOURCEBUILD.md b/SOURCEBUILD.md index 8e170dc8706..650934ae09e 100644 --- a/SOURCEBUILD.md +++ b/SOURCEBUILD.md @@ -52,6 +52,8 @@ conda env create --name cugraph_dev --file conda/environments/cugraph_dev_cuda11 # for CUDA 11.4 conda env create --name cugraph_dev --file conda/environments/cugraph_dev_cuda11.4.yml +# for CUDA 11.5 +conda env create --name cugraph_dev --file conda/environments/cugraph_dev_cuda11.5.yml # activate the environment conda activate cugraph_dev @@ -65,11 +67,8 @@ conda deactivate ```bash -# for CUDA 11.0 -conda env update --name cugraph_dev --file conda/environments/cugraph_dev_cuda11.0.yml - -# for CUDA 11.2 -conda env update --name cugraph_dev --file conda/environments/cugraph_dev_cuda11.2.yml +# Wherer XXX is the CUDA 11 version +conda env update --name cugraph_dev --file conda/environments/cugraph_dev_cuda11.XXX.yml conda activate cugraph_dev ``` From dcde7e364c2d4ffb6d4cfcd39b9cda43a4b92916 Mon Sep 17 00:00:00 2001 From: BradReesWork Date: Wed, 1 Dec 2021 11:33:12 -0500 Subject: [PATCH 4/9] starting to migrate code away from using DiGraph and to_array --- python/cugraph/cugraph/tests/test_graph.py | 28 +++++++++---------- python/cugraph/cugraph/tests/test_woverlap.py | 4 +-- python/cugraph/cugraph/tests/utils.py | 10 +++---- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/python/cugraph/cugraph/tests/test_graph.py b/python/cugraph/cugraph/tests/test_graph.py index 02286b77b77..9a12f84a6cf 100644 --- a/python/cugraph/cugraph/tests/test_graph.py +++ b/python/cugraph/cugraph/tests/test_graph.py @@ -146,8 +146,8 @@ def has_pair(first_arr, second_arr, first, second): def check_all_two_hops(df, M): num_verts = len(M.indptr) - 1 - first_arr = df["first"].to_array() - second_arr = df["second"].to_array() + first_arr = df["first"].to_numpy() + second_arr = df["second"].to_numpy() for start in range(num_verts): for idx in range(M.indptr[start], M.indptr[start + 1]): mid = M.indices[idx] @@ -173,7 +173,7 @@ def test_add_edge_list_to_adj_list(graph_file): indices_exp = M.indices # cugraph add_egde_list to_adj_list call - G = cugraph.DiGraph() + G = cugraph.Graph(directed=True) G.from_cudf_edgelist(cu_M, source="0", destination="1", renumber=False) offsets_cu, indices_cu, values_cu = G.view_adj_list() compare_series(offsets_cu, offsets_exp) @@ -198,7 +198,7 @@ def test_add_adj_list_to_edge_list(graph_file): destinations_exp = cudf.Series(Mcoo.col) # cugraph add_adj_list to_edge_list call - G = cugraph.DiGraph() + G = cugraph.Graph(directed=True) G.from_cudf_adjlist(offsets, indices, None) edgelist = G.view_edge_list() @@ -219,7 +219,7 @@ def test_view_edge_list_from_adj_list(graph_file): offsets = cudf.Series(Mcsr.indptr) indices = cudf.Series(Mcsr.indices) - G = cugraph.DiGraph() + G = cugraph.Graph(directed=True) G.from_cudf_adjlist(offsets, indices, None) edgelist_df = G.view_edge_list() Mcoo = Mcsr.tocoo() @@ -245,7 +245,7 @@ def test_delete_edge_list_delete_adj_list(graph_file): indices = cudf.Series(Mcsr.indices) # cugraph delete_adj_list delete_edge_list call - G = cugraph.DiGraph() + G = cugraph.Graph(directed=True) G.from_cudf_edgelist(df, source="src", destination="dst") G.delete_edge_list() with pytest.raises(Exception): @@ -273,7 +273,7 @@ def test_add_edge_or_adj_list_after_add_edge_or_adj_list(graph_file): offsets = cudf.Series(Mcsr.indptr) indices = cudf.Series(Mcsr.indices) - G = cugraph.DiGraph() + G = cugraph.Graph(directed=True) # If cugraph has at least one graph representation, adding a new graph # should fail to prevent a single graph object storing two different @@ -370,10 +370,10 @@ def test_view_edge_list_for_Graph(graph_file): # Compare nx and cugraph edges when viewing edgelist # assert cu_edge_list.equals(nx_edge_list) assert ( - cu_edge_list["src"].to_array() == nx_edge_list["src"].to_array() + cu_edge_list["src"].to_numpy() == nx_edge_list["src"].to_numpy() ).all() assert ( - cu_edge_list["dst"].to_array() == nx_edge_list["dst"].to_array() + cu_edge_list["dst"].to_numpy() == nx_edge_list["dst"].to_numpy() ).all() @@ -416,7 +416,7 @@ def test_consolidation(graph_file): def test_two_hop_neighbors(graph_file): cu_M = utils.read_csv_file(graph_file) - G = cugraph.DiGraph() + G = cugraph.Graph(directed=True) G.from_cudf_edgelist(cu_M, source="0", destination="1", edge_attr="2") df = G.get_two_hop_neighbors() @@ -436,7 +436,7 @@ def test_degree_functionality(graph_file): M = utils.read_csv_for_nx(graph_file) cu_M = utils.read_csv_file(graph_file) - G = cugraph.DiGraph() + G = cugraph.Graph(directed=True) G.from_cudf_edgelist(cu_M, source="0", destination="1", edge_attr="2") Gnx = nx.from_pandas_edgelist( @@ -474,7 +474,7 @@ def test_degrees_functionality(graph_file): M = utils.read_csv_for_nx(graph_file) cu_M = utils.read_csv_file(graph_file) - G = cugraph.DiGraph() + G = cugraph.Graph(directed=True) G.from_cudf_edgelist(cu_M, source="0", destination="1", edge_attr="2") Gnx = nx.from_pandas_edgelist( @@ -509,7 +509,7 @@ def test_number_of_vertices(graph_file): raise TypeError("Could not read the input graph") # cugraph add_edge_list - G = cugraph.DiGraph() + G = cugraph.Graph(directed=True) G.from_cudf_edgelist(cu_M, source="0", destination="1") Gnx = nx.from_pandas_edgelist( M, source="0", target="1", create_using=nx.DiGraph() @@ -557,7 +557,7 @@ def test_to_undirected(graph_file): assert len(cu_M) == len(M) # cugraph add_edge_list - DiG = cugraph.DiGraph() + DiG = cugraph.Graph(directed=True) DiG.from_cudf_edgelist(cu_M, source="0", destination="1") DiGnx = nx.from_pandas_edgelist( diff --git a/python/cugraph/cugraph/tests/test_woverlap.py b/python/cugraph/cugraph/tests/test_woverlap.py index 2a4be372517..889303223b8 100644 --- a/python/cugraph/cugraph/tests/test_woverlap.py +++ b/python/cugraph/cugraph/tests/test_woverlap.py @@ -39,14 +39,14 @@ def cugraph_call(benchmark_callable, cu_M, pairs): weights['vertex'] = np.arange(len(weights_arr), dtype=np.int32) weights['weight'] = weights_arr - G = cugraph.DiGraph() + G = cugraph.Graph(directed=True) G.from_cudf_edgelist(cu_M, source="0", destination="1") # cugraph Overlap Call df = benchmark_callable(cugraph.overlap_w, G, weights, pairs) df = df.sort_values(by=["source", "destination"]) - return df["overlap_coeff"].to_array() + return df["overlap_coeff"].to_numpy() def intersection(a, b, M): diff --git a/python/cugraph/cugraph/tests/utils.py b/python/cugraph/cugraph/tests/utils.py index a9171a5caec..4ce5b8afdb2 100755 --- a/python/cugraph/cugraph/tests/utils.py +++ b/python/cugraph/cugraph/tests/utils.py @@ -135,7 +135,7 @@ CUGRAPH_DIR_INPUT_TYPES = [ pytest.param( - cugraph.DiGraph, marks=pytest.mark.cugraph_types, id="cugraph.DiGraph" + cugraph.Graph, marks=pytest.mark.cugraph_types, id="cugraph.DiGraph" ), ] @@ -172,16 +172,16 @@ def read_csv_for_nx(csv_file, read_weights_in_sp=True, read_weights=True): def create_obj_from_csv( - csv_file_name, obj_type, csv_has_weights=True, edgevals=False + csv_file_name, obj_type, csv_has_weights=True, edgevals=False, directed=False ): """ Return an object based on obj_type populated with the contents of csv_file_name """ - if obj_type in [cugraph.Graph, cugraph.DiGraph]: + if obj_type is cugraph.Graph: return generate_cugraph_graph_from_file( csv_file_name, - directed=(obj_type is cugraph.DiGraph), + directed=directed, edgevals=edgevals, ) @@ -319,7 +319,7 @@ def generate_mg_batch_cugraph_graph_from_file(graph_file, directed=True): client = get_client() _ddf = read_dask_cudf_csv_file(graph_file) ddf = client.persist(_ddf) - G = cugraph.DiGraph() if directed else cugraph.Graph() + G = cugraph.Graph(directed=directed) G.from_dask_cudf_edgelist(ddf) return G From 2d1134647b7e47887a0be8dcaeb7e7fb9806ffc0 Mon Sep 17 00:00:00 2001 From: BradReesWork Date: Wed, 1 Dec 2021 11:50:53 -0500 Subject: [PATCH 5/9] BSP prototype dropped, removing test --- python/cugraph/cugraph/tests/test_bfs_bsp.py | 85 -------------------- 1 file changed, 85 deletions(-) delete mode 100644 python/cugraph/cugraph/tests/test_bfs_bsp.py diff --git a/python/cugraph/cugraph/tests/test_bfs_bsp.py b/python/cugraph/cugraph/tests/test_bfs_bsp.py deleted file mode 100644 index 8b355b620c5..00000000000 --- a/python/cugraph/cugraph/tests/test_bfs_bsp.py +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright (c) 2019-2021, 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import gc -import queue -import time - -import numpy as np -import pytest - -import cugraph -from cugraph.tests import utils - -# compute once -_int_max = 2 ** 31 - 1 - - -def cugraph_call(cu_M, start_vertex): - # Device data - df = cu_M[["0", "1"]] - - t1 = time.time() - df = cugraph.bsp.traversal.bfs_df_pregel( - df, start_vertex, src_col="0", dst_col="1" - ) - t2 = time.time() - t1 - print("Time : " + str(t2)) - - # Return distances as np.array() - return df["vertex"].to_array(), df["distance"].to_array() - - -def base_call(M, start_vertex): - - M = M.tocsr() - - offsets = M.indptr - indices = M.indices - num_verts = len(offsets) - 1 - dist = np.zeros(num_verts, dtype=np.int32) - vertex = list(range(num_verts)) - - for i in range(num_verts): - dist[i] = _int_max - - q = queue.Queue() - q.put(start_vertex) - dist[start_vertex] = 0 - while not q.empty(): - u = q.get() - for i_col in range(offsets[u], offsets[u + 1]): - v = indices[i_col] - if dist[v] == _int_max: - dist[v] = dist[u] + 1 - q.put(v) - - return vertex, dist - - -# Test all combinations of default/managed and pooled/non-pooled allocation -@pytest.mark.skip(reason="SG BFS is not yet formally supported") -@pytest.mark.parametrize("graph_file", utils.DATASETS) -def test_bfs(managed, pool, graph_file): - gc.collect() - - M = utils.read_csv_for_nx(graph_file) - cu_M = utils.read_csv_file(graph_file) - - base_vid, base_dist = base_call(M, 0) - cugraph_vid, cugraph_dist = cugraph_call(cu_M, np.int32(0)) - - # Calculating mismatch - num_dist = np.count_nonzero(base_dist != _int_max) - - assert num_dist == len(cugraph_dist) From 27ec571af137310d5280ccfedd4ed97994123818 Mon Sep 17 00:00:00 2001 From: BradReesWork Date: Wed, 1 Dec 2021 12:03:47 -0500 Subject: [PATCH 6/9] dropped use of "to_array" which is depricated in cuDF --- python/cugraph/cugraph/tests/test_balanced_cut.py | 4 ++-- python/cugraph/cugraph/tests/test_bfs.py | 6 +++--- python/cugraph/cugraph/tests/test_jaccard.py | 6 +++--- python/cugraph/cugraph/tests/test_multigraph.py | 2 +- python/cugraph/cugraph/tests/test_overlap.py | 2 +- python/cugraph/cugraph/tests/test_pagerank.py | 4 ++-- python/cugraph/cugraph/tests/test_random_walks.py | 12 ++++++------ python/cugraph/cugraph/tests/test_sorensen.py | 6 +++--- python/cugraph/cugraph/tests/test_sssp.py | 12 ++++++------ python/cugraph/cugraph/tests/utils.py | 4 ++-- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/python/cugraph/cugraph/tests/test_balanced_cut.py b/python/cugraph/cugraph/tests/test_balanced_cut.py index 2492017511a..6549cce07c2 100644 --- a/python/cugraph/cugraph/tests/test_balanced_cut.py +++ b/python/cugraph/cugraph/tests/test_balanced_cut.py @@ -30,7 +30,7 @@ def cugraph_call(G, partitions): score = cugraph.analyzeClustering_edge_cut( G, partitions, df, 'vertex', 'cluster' ) - return set(df["vertex"].to_array()), score + return set(df["vertex"].to_numpy()), score def random_call(G, partitions): @@ -149,7 +149,7 @@ def test_edge_cut_clustering_with_edgevals_nx(graph_file, partitions): G, partitions, gdf, 'vertex', 'cluster' ) - df = set(gdf["vertex"].to_array()) + df = set(gdf["vertex"].to_numpy()) Gcu = cugraph.utilities.convert_from_nx(G) rand_vid, rand_score = random_call(Gcu, partitions) diff --git a/python/cugraph/cugraph/tests/test_bfs.py b/python/cugraph/cugraph/tests/test_bfs.py index a2f16500d47..e3b5ab0b0e4 100644 --- a/python/cugraph/cugraph/tests/test_bfs.py +++ b/python/cugraph/cugraph/tests/test_bfs.py @@ -202,14 +202,14 @@ def _compare_bfs(cugraph_df, nx_distances, source): cu_distances = { vertex: dist for vertex, dist in zip( - cugraph_df["vertex"].to_array(), cugraph_df["distance"].to_array() + cugraph_df["vertex"].to_numpy(), cugraph_df["distance"].to_numpy() ) } cu_predecessors = { vertex: dist for vertex, dist in zip( - cugraph_df["vertex"].to_array(), - cugraph_df["predecessor"].to_array() + cugraph_df["vertex"].to_numpy(), + cugraph_df["predecessor"].to_numpy() ) } diff --git a/python/cugraph/cugraph/tests/test_jaccard.py b/python/cugraph/cugraph/tests/test_jaccard.py index 9e3326a2b26..50bffe71fff 100644 --- a/python/cugraph/cugraph/tests/test_jaccard.py +++ b/python/cugraph/cugraph/tests/test_jaccard.py @@ -82,9 +82,9 @@ def cugraph_call(benchmark_callable, cu_M, edgevals=False): df = df.sort_values(["source", "destination"]).reset_index(drop=True) return ( - df["source"].to_array(), - df["destination"].to_array(), - df["jaccard_coeff"].to_array(), + df["source"].to_numpy(), + df["destination"].to_numpy(), + df["jaccard_coeff"].to_numpy(), ) diff --git a/python/cugraph/cugraph/tests/test_multigraph.py b/python/cugraph/cugraph/tests/test_multigraph.py index 57be3eb34e8..69b47f83142 100644 --- a/python/cugraph/cugraph/tests/test_multigraph.py +++ b/python/cugraph/cugraph/tests/test_multigraph.py @@ -113,7 +113,7 @@ def test_multigraph_sssp(graph_file): ) nx_paths = nx.single_source_dijkstra_path_length(Gnx, 0) - cu_dist = cu_paths.sort_values(by='vertex')['distance'].to_array() + cu_dist = cu_paths.sort_values(by='vertex')['distance'].to_numpy() nx_dist = [i[1] for i in sorted(nx_paths.items())] assert (cu_dist == nx_dist).all() diff --git a/python/cugraph/cugraph/tests/test_overlap.py b/python/cugraph/cugraph/tests/test_overlap.py index abf012ac3b9..e1e7e60b5d4 100644 --- a/python/cugraph/cugraph/tests/test_overlap.py +++ b/python/cugraph/cugraph/tests/test_overlap.py @@ -56,7 +56,7 @@ def cugraph_call(benchmark_callable, cu_M, pairs, edgevals=False): # cugraph Overlap Call df = benchmark_callable(cugraph.overlap, G, pairs) df = df.sort_values(by=["source", "destination"]) - return df["overlap_coeff"].to_array() + return df["overlap_coeff"].to_numpy() def intersection(a, b, M): diff --git a/python/cugraph/cugraph/tests/test_pagerank.py b/python/cugraph/cugraph/tests/test_pagerank.py index 50be1cd5230..fae79f6ce80 100644 --- a/python/cugraph/cugraph/tests/test_pagerank.py +++ b/python/cugraph/cugraph/tests/test_pagerank.py @@ -66,7 +66,7 @@ def cugraph_call(G, max_iter, tol, alpha, personalization, nstart): df = df.sort_values("vertex").reset_index(drop=True) - pr_scores = df["pagerank"].to_array() + pr_scores = df["pagerank"].to_numpy() for i, rank in enumerate(pr_scores): sorted_pr.append((i, rank)) @@ -310,7 +310,7 @@ def test_pagerank_multi_column( df = df.sort_values("0_vertex").reset_index(drop=True) - pr_scores = df["pagerank"].to_array() + pr_scores = df["pagerank"].to_numpy() for i, rank in enumerate(pr_scores): cugraph_pr.append((i, rank)) diff --git a/python/cugraph/cugraph/tests/test_random_walks.py b/python/cugraph/cugraph/tests/test_random_walks.py index f79607b1d97..80baa0b4e2a 100644 --- a/python/cugraph/cugraph/tests/test_random_walks.py +++ b/python/cugraph/cugraph/tests/test_random_walks.py @@ -92,7 +92,7 @@ def check_random_walks(path_data, seeds, df_G=None): offsets_idx = 0 next_path_idx = 0 v_paths = path_data[0] - sizes = path_data[2].to_array().tolist() + sizes = path_data[2].to_numpy().tolist() for s in sizes: for i in range(next_path_idx, next_path_idx+s-1): @@ -156,12 +156,12 @@ def test_random_walks_coalesced( # Check path query output df = cugraph.rw_path(len(seeds), path_data[2]) - v_offsets = [0] + path_data[2].cumsum()[:-1].to_array().tolist() - w_offsets = [0] + (path_data[2]-1).cumsum()[:-1].to_array().tolist() + v_offsets = [0] + path_data[2].cumsum()[:-1].to_numpy().tolist() + w_offsets = [0] + (path_data[2]-1).cumsum()[:-1].to_numpy().tolist() assert_series_equal(df['weight_sizes'], path_data[2]-1, check_names=False) - assert df['vertex_offsets'].to_array().tolist() == v_offsets - assert df['weight_offsets'].to_array().tolist() == w_offsets + assert df['vertex_offsets'].to_numpy().tolist() == v_offsets + assert df['weight_offsets'].to_numpy().tolist() == w_offsets @pytest.mark.parametrize("graph_file", utils.DATASETS_SMALL) @@ -208,7 +208,7 @@ def test_random_walks( edge_attr="weight") k = random.randint(1, 10) - start_vertices = random.sample(G.nodes().to_array().tolist(), k) + start_vertices = random.sample(G.nodes().to_numpy().tolist(), k) seeds = cudf.DataFrame() seeds['v'] = start_vertices diff --git a/python/cugraph/cugraph/tests/test_sorensen.py b/python/cugraph/cugraph/tests/test_sorensen.py index e736b8da0b5..5e46ac91910 100644 --- a/python/cugraph/cugraph/tests/test_sorensen.py +++ b/python/cugraph/cugraph/tests/test_sorensen.py @@ -87,9 +87,9 @@ def cugraph_call(benchamrk_callable, cu_M, edgevals=False): df = df.sort_values(["source", "destination"]).reset_index(drop=True) return ( - df["source"].to_array(), - df["destination"].to_array(), - df["sorensen_coeff"].to_array(), + df["source"].to_numpy(), + df["destination"].to_numpy(), + df["sorensen_coeff"].to_numpy(), ) diff --git a/python/cugraph/cugraph/tests/test_sssp.py b/python/cugraph/cugraph/tests/test_sssp.py index 9230b7a7b96..360370a9e5b 100644 --- a/python/cugraph/cugraph/tests/test_sssp.py +++ b/python/cugraph/cugraph/tests/test_sssp.py @@ -93,9 +93,9 @@ def cugraph_call(gpu_benchmark_callable, input_G_or_matrix, max_val = np.iinfo(result["distance"].dtype).max else: max_val = np.finfo(result["distance"].dtype).max - verts = result["vertex"].to_array() - dists = result["distance"].to_array() - preds = result["predecessor"].to_array() + verts = result["vertex"].to_numpy() + dists = result["distance"].to_numpy() + preds = result["predecessor"].to_numpy() # A CuPy/SciPy input means the return value will be a 2-tuple of: # distance: cupy.ndarray @@ -302,9 +302,9 @@ def test_sssp_data_type_conversion(graph_file, source): assert G.edgelist.edgelist_df["weights"].dtype == np.int32 df = cugraph.sssp(G, source) max_val = np.finfo(df["distance"].dtype).max - verts_np = df["vertex"].to_array() - dist_np = df["distance"].to_array() - pred_np = df["predecessor"].to_array() + verts_np = df["vertex"].to_numpy() + dist_np = df["distance"].to_numpy() + pred_np = df["predecessor"].to_numpy() cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) # networkx call with int32 weights diff --git a/python/cugraph/cugraph/tests/utils.py b/python/cugraph/cugraph/tests/utils.py index 4ce5b8afdb2..5213397cb82 100755 --- a/python/cugraph/cugraph/tests/utils.py +++ b/python/cugraph/cugraph/tests/utils.py @@ -178,10 +178,10 @@ def create_obj_from_csv( Return an object based on obj_type populated with the contents of csv_file_name """ - if obj_type is cugraph.Graph: + if obj_type in [cugraph.Graph, cugraph.DiGraph]: return generate_cugraph_graph_from_file( csv_file_name, - directed=directed, + directed=(obj_type is cugraph.DiGraph), edgevals=edgevals, ) From 3b074ffadd55d99ee8ac0adf101c2f7fba9ef539 Mon Sep 17 00:00:00 2001 From: BradReesWork Date: Wed, 1 Dec 2021 13:37:07 -0500 Subject: [PATCH 7/9] dropping use of "to_array" --- .../cugraph/cugraph/centrality/betweenness_centrality.py | 2 +- python/cugraph/cugraph/components/connectivity.py | 2 +- python/cugraph/cugraph/tests/test_connectivity.py | 3 +++ python/cugraph/cugraph/tests/utils.py | 8 ++++++-- python/cugraph/cugraph/traversal/bfs.py | 4 ++-- python/cugraph/cugraph/traversal/sssp.py | 6 +++--- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/python/cugraph/cugraph/centrality/betweenness_centrality.py b/python/cugraph/cugraph/centrality/betweenness_centrality.py index fb89d248280..8b13cea7a8a 100644 --- a/python/cugraph/cugraph/centrality/betweenness_centrality.py +++ b/python/cugraph/cugraph/centrality/betweenness_centrality.py @@ -318,6 +318,6 @@ def _initialize_vertices_from_identifiers_list(G, identifiers): if G.renumbered: vertices = G.lookup_internal_vertex_id( cudf.Series(vertices) - ).to_array() + ).to_numpy() return vertices diff --git a/python/cugraph/cugraph/components/connectivity.py b/python/cugraph/cugraph/components/connectivity.py index c1fdc6ac135..9522c866cc8 100644 --- a/python/cugraph/cugraph/components/connectivity.py +++ b/python/cugraph/cugraph/components/connectivity.py @@ -89,7 +89,7 @@ def _convert_df_to_output_type(df, input_type, return_labels): if is_cp_matrix_type(input_type): labels = cp.fromDlpack(sorted_df["labels"].to_dlpack()) else: - labels = sorted_df["labels"].to_array() + labels = sorted_df["labels"].to_numpy() return (n_components, labels) else: return n_components diff --git a/python/cugraph/cugraph/tests/test_connectivity.py b/python/cugraph/cugraph/tests/test_connectivity.py index 194147ab620..d726a4ee492 100644 --- a/python/cugraph/cugraph/tests/test_connectivity.py +++ b/python/cugraph/cugraph/tests/test_connectivity.py @@ -355,6 +355,9 @@ def test_strong_cc(gpubenchmark, dataset_nxresults_strong, cugraph.strongly_connected_components, input_G_or_matrix) + + assert isinstance(input_G_or_matrix, cugraph_input_type) + # while cugraph returns a component label for each vertex; cg_n_components = len(cugraph_labels) diff --git a/python/cugraph/cugraph/tests/utils.py b/python/cugraph/cugraph/tests/utils.py index 5213397cb82..f3d23cc79e4 100755 --- a/python/cugraph/cugraph/tests/utils.py +++ b/python/cugraph/cugraph/tests/utils.py @@ -135,7 +135,7 @@ CUGRAPH_DIR_INPUT_TYPES = [ pytest.param( - cugraph.Graph, marks=pytest.mark.cugraph_types, id="cugraph.DiGraph" + cugraph.DiGraph, marks=pytest.mark.cugraph_types, id="cugraph.DiGraph" ), ] @@ -306,7 +306,11 @@ def generate_nx_graph_from_file(graph_file, directed=True, edgevals=False): def generate_cugraph_graph_from_file(graph_file, directed=True, edgevals=False): cu_M = read_csv_file(graph_file) - G = cugraph.Graph(directed=directed) + + if directed is False: + G = cugraph.Graph() + else: + G = cugraph.DiGraph() if edgevals: G.from_cudf_edgelist(cu_M, source="0", destination="1", edge_attr="2") diff --git a/python/cugraph/cugraph/traversal/bfs.py b/python/cugraph/cugraph/traversal/bfs.py index 127ab3d0ba3..bba68532e1a 100644 --- a/python/cugraph/cugraph/traversal/bfs.py +++ b/python/cugraph/cugraph/traversal/bfs.py @@ -70,8 +70,8 @@ def _convert_df_to_output_type(df, input_type): preds = cp.fromDlpack(sorted_df["predecessor"].to_dlpack()) return (distances, preds) else: - distances = sorted_df["distance"].to_array() - preds = sorted_df["predecessor"].to_array() + distances = sorted_df["distance"].to_numpy() + preds = sorted_df["predecessor"].to_numpy() return (distances, preds) else: raise TypeError(f"input type {input_type} is not a supported type.") diff --git a/python/cugraph/cugraph/traversal/sssp.py b/python/cugraph/cugraph/traversal/sssp.py index 5d7041a4287..859b860b0db 100644 --- a/python/cugraph/cugraph/traversal/sssp.py +++ b/python/cugraph/cugraph/traversal/sssp.py @@ -101,13 +101,13 @@ def _convert_df_to_output_type(df, input_type, return_predecessors): return (cp.fromDlpack(sorted_df["distance"].to_dlpack()), cp.fromDlpack(sorted_df["predecessor"].to_dlpack())) else: - return (sorted_df["distance"].to_array(), - sorted_df["predecessor"].to_array()) + return (sorted_df["distance"].to_numpy(), + sorted_df["predecessor"].to_numpy()) else: if is_cp_matrix_type(input_type): return cp.fromDlpack(sorted_df["distance"].to_dlpack()) else: - return sorted_df["distance"].to_array() + return sorted_df["distance"].to_numpy() else: raise TypeError(f"input type {input_type} is not a supported type.") From 727d103b02ef51d2223f4c98d67da8fad8bf8381 Mon Sep 17 00:00:00 2001 From: BradReesWork Date: Wed, 1 Dec 2021 15:07:55 -0500 Subject: [PATCH 8/9] flake8 issues --- python/cugraph/cugraph/tests/test_connectivity.py | 1 - python/cugraph/cugraph/tests/utils.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/cugraph/cugraph/tests/test_connectivity.py b/python/cugraph/cugraph/tests/test_connectivity.py index d726a4ee492..37b86a7ab60 100644 --- a/python/cugraph/cugraph/tests/test_connectivity.py +++ b/python/cugraph/cugraph/tests/test_connectivity.py @@ -355,7 +355,6 @@ def test_strong_cc(gpubenchmark, dataset_nxresults_strong, cugraph.strongly_connected_components, input_G_or_matrix) - assert isinstance(input_G_or_matrix, cugraph_input_type) # while cugraph returns a component label for each vertex; diff --git a/python/cugraph/cugraph/tests/utils.py b/python/cugraph/cugraph/tests/utils.py index f3d23cc79e4..08205f2e030 100755 --- a/python/cugraph/cugraph/tests/utils.py +++ b/python/cugraph/cugraph/tests/utils.py @@ -172,7 +172,8 @@ def read_csv_for_nx(csv_file, read_weights_in_sp=True, read_weights=True): def create_obj_from_csv( - csv_file_name, obj_type, csv_has_weights=True, edgevals=False, directed=False + csv_file_name, obj_type, csv_has_weights=True, edgevals=False, + directed=False ): """ Return an object based on obj_type populated with the contents of From f7f774f67ece1acef09c355c1a7220bf849b1820 Mon Sep 17 00:00:00 2001 From: Brad Rees <34135411+BradReesWork@users.noreply.github.com> Date: Thu, 2 Dec 2021 12:54:52 -0500 Subject: [PATCH 9/9] Update SOURCEBUILD.md Co-authored-by: Rick Ratzel <3039903+rlratzel@users.noreply.github.com> --- SOURCEBUILD.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SOURCEBUILD.md b/SOURCEBUILD.md index 650934ae09e..548c25707fc 100644 --- a/SOURCEBUILD.md +++ b/SOURCEBUILD.md @@ -67,7 +67,7 @@ conda deactivate ```bash -# Wherer XXX is the CUDA 11 version +# Where XXX is the CUDA 11 version conda env update --name cugraph_dev --file conda/environments/cugraph_dev_cuda11.XXX.yml conda activate cugraph_dev