Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated MG Test code to not use DiGraph #2213

Merged
merged 3 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions python/cugraph/cugraph/tests/dask/test_mg_bfs.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,17 +13,17 @@

import cugraph.dask as dcg
import gc
import pytest
# import pytest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this dead code be removed now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left that in there in case we want to re-enable MG only testing. pytest is needed for the skip

import cugraph
import dask_cudf
import cudf
from cugraph.dask.common.mg_utils import is_single_gpu
# from cugraph.dask.common.mg_utils import is_single_gpu
from cugraph.tests.utils import RAPIDS_DATASET_ROOT_DIR_PATH


@pytest.mark.skipif(
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
# @pytest.mark.skipif(
# is_single_gpu(), reason="skipping MG testing on Single GPU system"
# )
def test_dask_bfs(dask_client):
gc.collect()
Copy link
Contributor

@rlratzel rlratzel Apr 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: I've been using a single module-level setup function instead (like this) and removing all the individual gc.collect() calls.


Expand Down Expand Up @@ -60,10 +60,10 @@ def modify_dataset(df):

df = modify_dataset(df)

g = cugraph.DiGraph()
g = cugraph.Graph(directed=True)
g.from_cudf_edgelist(df, "src", "dst")

dg = cugraph.DiGraph()
dg = cugraph.Graph(directed=True)
dg.from_dask_cudf_edgelist(ddf, "src", "dst")

expected_dist = cugraph.bfs(g, [0, 1000])
Expand All @@ -85,9 +85,9 @@ def modify_dataset(df):
assert err == 0


@pytest.mark.skipif(
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
# @pytest.mark.skipif(
# is_single_gpu(), reason="skipping MG testing on Single GPU system"
# )
def test_dask_bfs_multi_column_depthlimit(dask_client):
gc.collect()

Expand Down Expand Up @@ -115,10 +115,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.DiGraph()
g = cugraph.Graph(directed=True)
g.from_cudf_edgelist(df, ["src_a", "src_b"], ["dst_a", "dst_b"])

dg = cugraph.DiGraph()
dg = cugraph.Graph(directed=True)
dg.from_dask_cudf_edgelist(ddf, ["src_a", "src_b"], ["dst_a", "dst_b"])

start = cudf.DataFrame()
Expand Down
10 changes: 5 additions & 5 deletions python/cugraph/cugraph/tests/dask/test_mg_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

import cugraph.dask as dcg
import gc
import pytest
# import pytest
import cugraph
import dask_cudf
import cudf
from cugraph.dask.common.mg_utils import is_single_gpu
# from cugraph.dask.common.mg_utils import is_single_gpu
from cugraph.tests.utils import RAPIDS_DATASET_ROOT_DIR_PATH


@pytest.mark.skipif(
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
# @pytest.mark.skipif(
# is_single_gpu(), reason="skipping MG testing on Single GPU system"
# )
def test_dask_pagerank(dask_client):
gc.collect()

Expand Down
16 changes: 8 additions & 8 deletions python/cugraph/cugraph/tests/dask/test_mg_connectivity.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,17 +13,17 @@

import cugraph.dask as dcg
import gc
import pytest
# import pytest
import cugraph
import dask_cudf
import cudf
from cugraph.dask.common.mg_utils import is_single_gpu
# from cugraph.dask.common.mg_utils import is_single_gpu
from cugraph.tests.utils import RAPIDS_DATASET_ROOT_DIR_PATH


@pytest.mark.skipif(
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
# @pytest.mark.skipif(
# is_single_gpu(), reason="skipping MG testing on Single GPU system"
# )
def test_dask_wcc(dask_client):
gc.collect()

Expand All @@ -47,10 +47,10 @@ def test_dask_wcc(dask_client):
dtype=["int32", "int32", "float32"],
)

g = cugraph.DiGraph()
g = cugraph.Graph(directed=True)
g.from_cudf_edgelist(df, "src", "dst", renumber=True)

dg = cugraph.DiGraph()
dg = cugraph.Graph(directed=True)
dg.from_dask_cudf_edgelist(ddf, "src", "dst")

expected_dist = cugraph.weakly_connected_components(g)
Expand Down
6 changes: 3 additions & 3 deletions python/cugraph/cugraph/tests/dask/test_mg_degree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018-2021, NVIDIA CORPORATION.
# Copyright (c) 2018-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
Expand Down Expand Up @@ -49,10 +49,10 @@ def test_dask_mg_degree(dask_client):
dtype=["int32", "int32", "float32"],
)

dg = cugraph.DiGraph()
dg = cugraph.Graph(directed=True)
dg.from_dask_cudf_edgelist(ddf, "src", "dst")

g = cugraph.DiGraph()
g = cugraph.Graph(directed=True)
g.from_cudf_edgelist(df, "src", "dst")

merge_df_in = (
Expand Down
8 changes: 4 additions & 4 deletions python/cugraph/cugraph/tests/dask/test_mg_hits.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import pytest
import cugraph
import dask_cudf
from cugraph.dask.common.mg_utils import is_single_gpu
# from cugraph.dask.common.mg_utils import is_single_gpu
from cugraph.tests import utils

# =============================================================================
Expand Down Expand Up @@ -97,9 +97,9 @@ def input_expected_output(input_combo):
# =============================================================================


@pytest.mark.skipif(
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
# @pytest.mark.skipif(
# is_single_gpu(), reason="skipping MG testing on Single GPU system"
# )
def test_dask_hits(dask_client, benchmark, input_expected_output):

dg = input_expected_output["MGGraph"]
Expand Down
18 changes: 9 additions & 9 deletions python/cugraph/cugraph/tests/dask/test_mg_louvain.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,7 +17,7 @@
import cugraph
import dask_cudf
from cugraph.tests import utils
from cugraph.dask.common.mg_utils import is_single_gpu
# from cugraph.dask.common.mg_utils import is_single_gpu

try:
from rapids_pytest_benchmark import setFixtureParamNames
Expand All @@ -39,9 +39,9 @@ def setFixtureParamNames(*args, **kwargs):

###############################################################################
# Fixtures
@pytest.mark.skipif(
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
# @pytest.mark.skipif(
# is_single_gpu(), reason="skipping MG testing on Single GPU system"
# )
@pytest.fixture(scope="module",
params=utils.DATASETS_UNDIRECTED,
ids=[f"dataset={d.as_posix()}"
Expand All @@ -64,16 +64,16 @@ def daskGraphFromDataset(request, dask_client):
dtype=["int32", "int32", "float32"],
)

dg = cugraph.DiGraph()
dg = cugraph.Graph(directed=True)
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"
)
# @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
Expand Down
14 changes: 7 additions & 7 deletions python/cugraph/cugraph/tests/dask/test_mg_pagerank.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,7 +17,7 @@
import cugraph
import dask_cudf
import cudf
from cugraph.dask.common.mg_utils import is_single_gpu
# from cugraph.dask.common.mg_utils import is_single_gpu
from cugraph.tests.utils import RAPIDS_DATASET_ROOT_DIR_PATH


Expand Down Expand Up @@ -50,9 +50,9 @@ def personalize(vertices, personalization_perc):
PERSONALIZATION_PERC = [0, 10, 50]


@pytest.mark.skipif(
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
# @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):
gc.collect()
Expand All @@ -77,10 +77,10 @@ def test_dask_pagerank(dask_client, personalization_perc):
dtype=["int32", "int32", "float32"],
)

g = cugraph.DiGraph()
g = cugraph.Graph(directed=True)
g.from_cudf_edgelist(df, "src", "dst")

dg = cugraph.DiGraph()
dg = cugraph.Graph(directed=True)
dg.from_dask_cudf_edgelist(ddf, "src", "dst")

personalization = None
Expand Down
16 changes: 8 additions & 8 deletions python/cugraph/cugraph/tests/dask/test_mg_sssp.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,17 +13,17 @@

import cugraph.dask as dcg
import gc
import pytest
# import pytest
import cugraph
import dask_cudf
import cudf
from cugraph.dask.common.mg_utils import is_single_gpu
# from cugraph.dask.common.mg_utils import is_single_gpu
from cugraph.tests.utils import RAPIDS_DATASET_ROOT_DIR_PATH


@pytest.mark.skipif(
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
# @pytest.mark.skipif(
# is_single_gpu(), reason="skipping MG testing on Single GPU system"
# )
def test_dask_sssp(dask_client):
gc.collect()

Expand All @@ -47,10 +47,10 @@ def test_dask_sssp(dask_client):
dtype=["int32", "int32", "float32"],
)

g = cugraph.DiGraph()
g = cugraph.Graph(directed=True)
g.from_cudf_edgelist(df, "src", "dst", "value", renumber=True)

dg = cugraph.DiGraph()
dg = cugraph.Graph(directed=True)
dg.from_dask_cudf_edgelist(ddf, "src", "dst", "value")

expected_dist = cugraph.sssp(g, 0)
Expand Down
12 changes: 6 additions & 6 deletions python/cugraph/cugraph/tests/dask/test_mg_utility.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018-2021, NVIDIA CORPORATION.
# Copyright (c) 2018-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
Expand Down Expand Up @@ -35,9 +35,9 @@ def setup_function():
gc.collect()


@pytest.mark.skipif(
is_single_gpu(), reason="skipping MG testing on Single GPU system"
)
# @pytest.mark.skipif(
# is_single_gpu(), reason="skipping MG testing on Single GPU system"
# )
def test_from_edgelist(dask_client):
input_data_path = (RAPIDS_DATASET_ROOT_DIR_PATH /
"karate.csv").as_posix()
Expand All @@ -53,9 +53,9 @@ def test_from_edgelist(dask_client):

dg1 = cugraph.from_edgelist(
ddf, source="src", destination="dst", edge_attr="value",
create_using=cugraph.DiGraph)
create_using=cugraph.Graph(directed=True))

dg2 = cugraph.DiGraph()
dg2 = cugraph.Graph(directed=True)
dg2.from_dask_cudf_edgelist(
ddf, source="src", destination="dst", edge_attr="value"
)
Expand Down
12 changes: 6 additions & 6 deletions python/cugraph/cugraph/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import networkx as nx
import numpy as np
import cupy as cp
from cupyx.scipy.sparse.coo import coo_matrix as cp_coo_matrix
from cupyx.scipy.sparse.csr import csr_matrix as cp_csr_matrix
from cupyx.scipy.sparse.csc import csc_matrix as cp_csc_matrix
from scipy.sparse.coo import coo_matrix as sp_coo_matrix
from scipy.sparse.csr import csr_matrix as sp_csr_matrix
from scipy.sparse.csc import csc_matrix as sp_csc_matrix
from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix
from cupyx.scipy.sparse import csr_matrix as cp_csr_matrix
from cupyx.scipy.sparse import csc_matrix as cp_csc_matrix
from scipy.sparse import coo_matrix as sp_coo_matrix
from scipy.sparse import csr_matrix as sp_csr_matrix
from scipy.sparse import csc_matrix as sp_csc_matrix
from pathlib import Path
import cudf
import dask_cudf
Expand Down
12 changes: 6 additions & 6 deletions python/cugraph/cugraph/utilities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
# optional dependencies
try:
import cupy as cp
from cupyx.scipy.sparse.coo import coo_matrix as cp_coo_matrix
from cupyx.scipy.sparse.csr import csr_matrix as cp_csr_matrix
from cupyx.scipy.sparse.csc import csc_matrix as cp_csc_matrix
from cupyx.scipy.sparse import coo_matrix as cp_coo_matrix
from cupyx.scipy.sparse import csr_matrix as cp_csr_matrix
from cupyx.scipy.sparse import csc_matrix as cp_csc_matrix

__cp_matrix_types = [cp_coo_matrix, cp_csr_matrix, cp_csc_matrix]
__cp_compressed_matrix_types = [cp_csr_matrix, cp_csc_matrix]
Expand All @@ -39,9 +39,9 @@

try:
import scipy as sp
from scipy.sparse.coo import coo_matrix as sp_coo_matrix
from scipy.sparse.csr import csr_matrix as sp_csr_matrix
from scipy.sparse.csc import csc_matrix as sp_csc_matrix
from scipy.sparse import coo_matrix as sp_coo_matrix
from scipy.sparse import csr_matrix as sp_csr_matrix
from scipy.sparse import csc_matrix as sp_csc_matrix

__sp_matrix_types = [sp_coo_matrix, sp_csr_matrix, sp_csc_matrix]
__sp_compressed_matrix_types = [sp_csr_matrix, sp_csc_matrix]
Expand Down