diff --git a/python/cugraph/cugraph/testing/__init__.py b/python/cugraph/cugraph/testing/__init__.py index 03785d0ee49..777ee70794e 100644 --- a/python/cugraph/cugraph/testing/__init__.py +++ b/python/cugraph/cugraph/testing/__init__.py @@ -11,12 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cugraph.testing.utils import ( - RAPIDS_DATASET_ROOT_DIR_PATH, ResultSet -) +from cugraph.testing.utils import RAPIDS_DATASET_ROOT_DIR_PATH, ResultSet from cugraph.testing.resultset import ( get_bfs_results, get_sssp_results, get_paths_results, -) \ No newline at end of file +) diff --git a/python/cugraph/cugraph/testing/resultset.py b/python/cugraph/cugraph/testing/resultset.py index 1611fc730ea..ec3a9705095 100644 --- a/python/cugraph/cugraph/testing/resultset.py +++ b/python/cugraph/cugraph/testing/resultset.py @@ -33,7 +33,7 @@ karate, polbooks, ) -from cugraph.testing import utils, ResultSet +from cugraph.testing import utils default_results_upload_dir = Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" @@ -80,9 +80,7 @@ Gnx = utils.generate_nx_graph_from_file(karate.get_path(), directed=dirctd) result = cugraph.bfs_edges(Gnx, source=7) cugraph_df = cudf.from_pandas(result) - test_bfs_results[ - "{},{},{}".format(ds, dirctd, "nonnative-nx") - ] = cugraph_df + test_bfs_results["{},{},{}".format(ds, dirctd, "nonnative-nx")] = cugraph_df # ============================================================================= @@ -208,9 +206,7 @@ test_paths_results["1,notarget,nx"] = nx.shortest_path_length( Gnx_DIS, source="1", weight="weight" ) -test_paths_results["1,notarget,cu"] = cugraph.shortest_path_length( - Gnx_DIS, "1" -) +test_paths_results["1,notarget,cu"] = cugraph.shortest_path_length(Gnx_DIS, "1") # serial_bfs_results = pickle.dumps(test_bfs_results) @@ -221,9 +217,15 @@ # pickle.dump(test_sssp_results, open("testing/sssp_results.pkl", "wb")) # pickle.dump(test_paths_results, open("testing/paths_results.pkl", "wb")) -pickle.dump(test_bfs_results, open(default_results_upload_dir / "bfs_results.pkl", "wb")) -pickle.dump(test_sssp_results, open(default_results_upload_dir / "sssp_results.pkl", "wb")) -pickle.dump(test_paths_results, open(default_results_upload_dir / "paths_results.pkl", "wb")) +pickle.dump( + test_bfs_results, open(default_results_upload_dir / "bfs_results.pkl", "wb") +) +pickle.dump( + test_sssp_results, open(default_results_upload_dir / "sssp_results.pkl", "wb") +) +pickle.dump( + test_paths_results, open(default_results_upload_dir / "paths_results.pkl", "wb") +) # Example of how ResultSet is used in each individual testing script # my_bfs_results = ResultSet(local_result_file="bfs_results.pkl") diff --git a/python/cugraph/cugraph/testing/utils.py b/python/cugraph/cugraph/testing/utils.py index add4f56687a..ef69be35072 100644 --- a/python/cugraph/cugraph/testing/utils.py +++ b/python/cugraph/cugraph/testing/utils.py @@ -32,6 +32,7 @@ import cugraph from cugraph.dask.common.mg_utils import get_client + # from cugraph.experimental.datasets import default_download_dir @@ -424,7 +425,10 @@ def compare_mst(mst_cugraph, mst_nx): Gnx_dict[u][v] = Gnx[u][v] return Gnx_dict""" -default_results_download_dir = Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" +default_results_download_dir = ( + Path(os.environ.get("RAPIDS_DATASET_ROOT_DIR")) / "results" +) + class ResultSet: """ @@ -459,7 +463,9 @@ def __init__(self, local_result_file=None, cloud_result_file=None): # try to load results, if file doesn't exist raise pref. RuntimeError raise FileNotFoundError(local_result_file) else: - with open(default_results_download_dir / local_result_file, "rb") as file: + with open( + default_results_download_dir / local_result_file, "rb" + ) as file: self.results = pickle.load(file) else: raise ValueError( diff --git a/python/cugraph/cugraph/tests/traversal/test_bfs.py b/python/cugraph/cugraph/tests/traversal/test_bfs.py index fa0333f7706..5d5ea8ffcc2 100644 --- a/python/cugraph/cugraph/tests/traversal/test_bfs.py +++ b/python/cugraph/cugraph/tests/traversal/test_bfs.py @@ -12,10 +12,10 @@ # limitations under the License. import gc + # import random import pytest -import pandas as pd import cupy as cp import numpy as np from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix @@ -267,7 +267,9 @@ def get_cu_graph_nx_results_and_params( # nx_values = get_bfs_results( # "{},{},{},{}".format(seed, depth_limit, dataset_name, directed) # ) - nx_values = bfs_results.results["{},{},{},{}".format(seed, depth_limit, dataset_name, directed)] + nx_values = bfs_results.results[ + "{},{},{},{}".format(seed, depth_limit, dataset_name, directed) + ] return (G, dataset_path, directed, nx_values, start_vertex, depth_limit) @@ -417,7 +419,9 @@ def test_bfs_nonnative_inputs_nx( _, ) = single_dataset_nxresults_startvertex_spc - cugraph_df = bfs_results.results["{},{},{}".format("karate", directed, "nonnative-nx")] + cugraph_df = bfs_results.results[ + "{},{},{}".format("karate", directed, "nonnative-nx") + ] compare_func = _compare_bfs compare_func(cugraph_df, nx_values, start_vertex) diff --git a/python/cugraph/cugraph/tests/traversal/test_paths.py b/python/cugraph/cugraph/tests/traversal/test_paths.py index 5d029500849..8b6330ac095 100644 --- a/python/cugraph/cugraph/tests/traversal/test_paths.py +++ b/python/cugraph/cugraph/tests/traversal/test_paths.py @@ -175,10 +175,10 @@ def test_shortest_path_length_no_target(graphs): cugraph_G, cupy_df = graphs cugraph_path_1_to_all = cugraph.shortest_path_length(cugraph_G, 1) - # nx_path_1_to_all = get_paths_results("1,notarget,nx") - # nx_gpu_path_1_to_all = cudf.DataFrame.from_dict(get_paths_results("1,notarget,cu")) nx_path_1_to_all = paths_results.results["1,notarget,nx"] - nx_gpu_path_1_to_all = cudf.DataFrame.from_dict(paths_results.results["1,notarget,cu"]) + nx_gpu_path_1_to_all = cudf.DataFrame.from_dict( + paths_results.results["1,notarget,cu"] + ) cupy_path_1_to_all = cugraph.shortest_path_length(cupy_df, 1) # Cast networkx graph on cugraph vertex column type from str to int. diff --git a/python/cugraph/cugraph/tests/traversal/test_sssp.py b/python/cugraph/cugraph/tests/traversal/test_sssp.py index a3c8d419fea..72db4999813 100644 --- a/python/cugraph/cugraph/tests/traversal/test_sssp.py +++ b/python/cugraph/cugraph/tests/traversal/test_sssp.py @@ -255,7 +255,9 @@ def test_sssp_nonnative_inputs_nx( gpubenchmark, single_dataset_source_nxresults, cugraph_input_type ): (_, _, _, source, nx_paths) = single_dataset_source_nxresults - result = sssp_results.results["nonnative_input,{},{}".format(cugraph_input_type, source)] + result = sssp_results.results[ + "nonnative_input,{},{}".format(cugraph_input_type, source) + ] # ^^ should be a pd dataframe result = cudf.from_pandas(result) if np.issubdtype(result["distance"].dtype, np.integer): @@ -355,7 +357,9 @@ def test_sssp_data_type_conversion(graph_file, source): dist_np = df["distance"].to_numpy() pred_np = df["predecessor"].to_numpy() cu_paths = dict(zip(verts_np, zip(dist_np, pred_np))) - nx_paths = sssp_results.results["nx_paths,data_type_conversion,{}".format(dataset_name)] + nx_paths = sssp_results.results[ + "nx_paths,data_type_conversion,{}".format(dataset_name) + ] # Calculating mismatch err = 0