Skip to content

Commit

Permalink
Style check
Browse files Browse the repository at this point in the history
  • Loading branch information
betochimas committed Jul 12, 2023
1 parent beecde0 commit 5386a29
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 24 deletions.
6 changes: 2 additions & 4 deletions python/cugraph/cugraph/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
22 changes: 12 additions & 10 deletions python/cugraph/cugraph/testing/resultset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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


# =============================================================================
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand Down
10 changes: 8 additions & 2 deletions python/cugraph/cugraph/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import cugraph
from cugraph.dask.common.mg_utils import get_client

# from cugraph.experimental.datasets import default_download_dir


Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 7 additions & 3 deletions python/cugraph/cugraph/tests/traversal/test_bfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions python/cugraph/cugraph/tests/traversal/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions python/cugraph/cugraph/tests/traversal/test_sssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5386a29

Please sign in to comment.