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

Python code cleanup across docs, wrappers, testing (#2194) #54

Merged
merged 1 commit into from
May 2, 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
1 change: 0 additions & 1 deletion docs/cugraph/source/api_docs/centrality.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ Katz Centrality (MG)
:toctree: api/

cugraph.dask.centrality.katz_centrality.katz_centrality
cugraph.dask.centrality.katz_centrality.call_katz_centrality
1 change: 0 additions & 1 deletion docs/cugraph/source/api_docs/community.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Louvain (MG)
.. autosummary::
:toctree: api/

cugraph.dask.community.louvain.call_louvain
cugraph.dask.community.louvain.louvain

Spectral Clustering
Expand Down
1 change: 0 additions & 1 deletion docs/cugraph/source/api_docs/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ Connected Components (MG)
.. autosummary::
:toctree: api/

cugraph.dask.components.connectivity.call_wcc
cugraph.dask.components.connectivity.weakly_connected_components

8 changes: 8 additions & 0 deletions docs/cugraph/source/api_docs/helper_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@ Methods

cugraph.comms.comms.initialize
cugraph.comms.comms.destroy
cugraph.comms.comms.is_initialized
cugraph.comms.comms.get_comms
cugraph.comms.comms.get_workers
cugraph.comms.comms.get_session_id
cugraph.comms.comms.get_2D_partition
cugraph.comms.comms.get_default_handle
cugraph.comms.comms.get_handle
cugraph.comms.comms.get_worker_id
cugraph.dask.common.read_utils.get_chunksize

7 changes: 7 additions & 0 deletions docs/cugraph/source/api_docs/link_analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ HITS

cugraph.hits

HITS (MG)
---------
.. autosummary::
:toctree: api/

cugraph.dask.link_analysis.hits.hits


Pagerank
--------
Expand Down
9 changes: 8 additions & 1 deletion docs/cugraph/source/api_docs/sampling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ Random Walks

cugraph.random_walks
cugraph.ego_graph
cugraph.experimental.dask.uniform_neighborhood_sampling
cugraph.experimental.dask.uniform_neighborhood_sampling

Node2Vec
---------
.. autosummary::
:toctree: api/

cugraph.node2vec
21 changes: 20 additions & 1 deletion docs/cugraph/source/api_docs/structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,30 @@ Conversion from Other Formats
cugraph.to_pandas_adjacency
cugraph.to_pandas_edgelist

NumberMap
-----------------------------
.. autosummary::
:toctree: api/

cugraph.structure.NumberMap
cugraph.structure.NumberMap.MultiGPU
cugraph.structure.NumberMap.SingleGPU
cugraph.structure.NumberMap.from_internal_vertex_id
cugraph.structure.NumberMap.to_internal_vertex_id
cugraph.structure.NumberMap.add_internal_vertex_id
cugraph.structure.NumberMap.compute_vals
cugraph.structure.NumberMap.compute_vals_types
cugraph.structure.NumberMap.generate_unused_column_name
cugraph.structure.NumberMap.renumber
cugraph.structure.NumberMap.renumber_and_segment
cugraph.structure.NumberMap.set_renumbered_col_names
cugraph.structure.NumberMap.unrenumber
cugraph.structure.NumberMap.vertex_column_size

Other
-----------------------------
.. autosummary::
:toctree: api/

cugraph.hypergraph
cugraph.structure.shuffle
cugraph.structure.NumberMap
2 changes: 0 additions & 2 deletions docs/cugraph/source/api_docs/traversal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Breadth-first-search (MG)
:toctree: api/

cugraph.dask.traversal.bfs.bfs
cugraph.dask.traversal.bfs.call_bfs

Single-source-shortest-path
---------------------------
Expand All @@ -36,5 +35,4 @@ Single-source-shortest-path (MG)
.. autosummary::
:toctree: api/

cugraph.dask.traversal.sssp.call_sssp
cugraph.dask.traversal.sssp.sssp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def betweenness_centrality(
If true, include the endpoints in the shortest path counts.
(Not Supported)

seed : optional
seed : optional (default=None)
if k is specified and k is an integer, use seed to initialize the
random number generator.
Using None as seed relies on random.seed() behavior: using current
Expand Down
21 changes: 21 additions & 0 deletions python/cugraph/cugraph/comms/comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ def initialize(comms=None,
default) represents a partitioning resulting in prows*pcols
partitions. A non-1 value currently results in a partitioning of
p*pcols partitions, where p is the number of GPUs.

Examples
--------
>>> from dask.distributed import Client
>>> from dask_cuda import LocalCUDACluster
>>> import cugraph.comms as Comms
>>> cluster = LocalCUDACluster()
>>> client = Client(cluster)
>>> Comms.initialize(p2p=True)
>>> # DO WORK HERE
>>> # All done, clean up
>>> Comms.destroy()
>>> client.close()
>>> cluster.close()

"""

global __instance
Expand Down Expand Up @@ -200,11 +215,17 @@ def get_default_handle():
# Functions to be called from within workers

def get_handle(sID):
"""
Returns the handle from within the worker using the sessionstate.
"""
sessionstate = get_raft_comm_state(sID)
return sessionstate['handle']


def get_worker_id(sID):
"""
Returns the worker's sessionId from within the worker.
"""
sessionstate = get_raft_comm_state(sID)
return sessionstate['wid']

Expand Down
3 changes: 2 additions & 1 deletion python/cugraph/cugraph/community/egonet.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ def batched_ego_graphs(
... header=None)
>>> G = cugraph.Graph()
>>> G.from_cudf_edgelist(M, source='0', destination='1')
>>> b_ego_graph = cugraph.batched_ego_graphs(G, seeds=[1,5], radius=2)
>>> b_ego_graph, offsets = cugraph.batched_ego_graphs(G, seeds=[1,5],
... radius=2)

"""

Expand Down
9 changes: 9 additions & 0 deletions python/cugraph/cugraph/community/ktruss_subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ def k_truss(G, k):
G_truss : cuGraph.Graph or networkx.Graph
A cugraph graph descriptor with the k-truss subgraph for the given k.
The networkx graph will NOT have all attributes copied over

Examples
--------
>>> gdf = cudf.read_csv(datasets_path / 'karate.csv', delimiter=' ',
... dtype=['int32', 'int32', 'float32'], header=None)
>>> G = cugraph.Graph()
>>> G.from_cudf_edgelist(gdf, source='0', destination='1')
>>> k_subgraph = cugraph.k_truss(G, 3)

"""

_ensure_compatible_cuda_version()
Expand Down
19 changes: 10 additions & 9 deletions python/cugraph/cugraph/dask/centrality/katz_centrality.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,21 @@ def katz_centrality(input_graph,

Examples
--------
>>> # import cugraph.dask as dcg
>>> import cugraph.dask as dcg
>>> import dask_cudf
>>> # ... Init a DASK Cluster
>>> # see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
>>> # Download dataset from https://github.com/rapidsai/cugraph/datasets/..
>>> # chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> # ddf = dask_cudf.read_csv(input_data_path, chunksize=chunksize)
>>> # dg = cugraph.Graph(directed=True)
>>> # dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
>>> # edge_attr='value')
>>> # pr = dcg.katz_centrality(dg)
>>> chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> ddf = dask_cudf.read_csv(datasets_path / "karate.csv",
... chunksize=chunksize, delimiter=" ",
... names=["src", "dst", "value"],
... dtype=["int32", "int32", "float32"])
>>> dg = cugraph.Graph(directed=True)
>>> dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst')
>>> pr = dcg.katz_centrality(dg)

"""
# FIXME: Uncomment out the above (broken) example

nstart = None

client = default_client()
Expand Down
3 changes: 1 addition & 2 deletions python/cugraph/cugraph/dask/common/read_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ def get_chunksize(input_path):
Examples
--------
>>> import cugraph.dask as dcg
>>> # chunksize = dcg.get_chunksize(edge_list.csv)
>>> chunksize = dcg.get_chunksize(datasets_path / 'netscience.csv')

"""
# FIXME: Uncomment out the above example

import os
from glob import glob
Expand Down
29 changes: 12 additions & 17 deletions python/cugraph/cugraph/dask/community/louvain.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from cugraph.dask.common.input_utils import (get_distributed_data,
get_vertex_partition_offsets)
from cugraph.dask.community import louvain_wrapper as c_mg_louvain
from cugraph.utilities.utils import is_cuda_version_less_than

import dask_cudf

Expand Down Expand Up @@ -99,26 +98,22 @@ def louvain(input_graph, max_iter=100, resolution=1.0):

Examples
--------
>>> # import cugraph.dask as dcg
>>> import cugraph.dask as dcg
>>> import dask_cudf
>>> # ... Init a DASK Cluster
>>> # see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
>>> # Download dataset from https://github.com/rapidsai/cugraph/datasets/..
>>> # chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> # ddf = dask_cudf.read_csv(input_data_path, chunksize=chunksize)
>>> # dg = cugraph.Graph(directed=True)
>>> # dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
>>> # edge_attr='value')
>>> # parts, modularity_score = dcg.louvain(dg)
"""
# FIXME: Uncomment out the above (broken) example

# MG Louvain currently requires CUDA 10.2 or higher.
# FIXME: remove this check once RAPIDS drops support for CUDA < 10.2
if is_cuda_version_less_than((10, 2)):
raise NotImplementedError("Multi-GPU Louvain is not implemented for "
"this version of CUDA. Ensure CUDA version "
"10.2 or higher is installed.")
>>> chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> ddf = dask_cudf.read_csv(datasets_path / "karate.csv",
... chunksize=chunksize, delimiter=" ",
... names=["src", "dst", "value"],
... dtype=["int32", "int32", "float32"])
>>> dg = cugraph.Graph(directed=True)
>>> dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
... edge_attr='value')
>>> parts, modularity_score = dcg.louvain(dg)

"""
# FIXME: dask methods to populate graphs from edgelists are only present on
# DiGraph classes. Disable the Graph check for now and assume inputs are
# symmetric DiGraphs.
Expand Down
18 changes: 18 additions & 0 deletions python/cugraph/cugraph/dask/components/connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ def weakly_connected_components(input_graph):

Graph or matrix object, which should contain the connectivity
information

Examples
--------
>>> import cugraph.dask as dcg
>>> import dask_cudf
>>> # ... Init a DASK Cluster
>>> # see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
>>> # Download dataset from https://github.com/rapidsai/cugraph/datasets/..
>>> chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> ddf = dask_cudf.read_csv(datasets_path / "karate.csv",
... chunksize=chunksize, delimiter=" ",
... names=["src", "dst", "value"],
... dtype=["int32", "int32", "float32"])
>>> dg = cugraph.Graph(directed=True)
>>> dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
... edge_attr='value')
>>> result = dcg.weakly_connected_components(dg)

"""

client = default_client()
Expand Down
18 changes: 11 additions & 7 deletions python/cugraph/cugraph/dask/link_analysis/hits.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,20 @@ def hits(input_graph, tol=1.0e-5, max_iter=100, nstart=None, normalized=True):

Examples
--------
>>> # import cugraph.dask as dcg
>>> import cugraph.dask as dcg
>>> import dask_cudf
>>> # ... Init a DASK Cluster
>>> # see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
>>> # Download dataset from https://github.com/rapidsai/cugraph/datasets/..
>>> # chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> # ddf = dask_cudf.read_csv(input_data_path, chunksize=chunksize)
>>> # dg = cugraph.Graph(directed=True)
>>> # dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
>>> # edge_attr='value')
>>> # hits = dcg.hits(dg, max_iter = 50)
>>> chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> ddf = dask_cudf.read_csv(datasets_path / "karate.csv",
... chunksize=chunksize, delimiter=" ",
... names=["src", "dst", "value"],
... dtype=["int32", "int32", "float32"])
>>> dg = cugraph.Graph(directed=True)
>>> dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
... edge_attr='value')
>>> hits = dcg.hits(dg, max_iter = 50)

"""

Expand Down
17 changes: 10 additions & 7 deletions python/cugraph/cugraph/dask/link_analysis/pagerank.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,19 @@ def pagerank(input_graph,

Examples
--------
>>> # import cugraph.dask as dcg
>>> import cugraph.dask as dcg
>>> import dask_cudf
>>> # ... Init a DASK Cluster
>>> # see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
>>> # Download dataset from https://github.com/rapidsai/cugraph/datasets/..
>>> # chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> # ddf = dask_cudf.read_csv(input_data_path, chunksize=chunksize)
>>> # dg = cugraph.Graph(directed=True)
>>> # dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
>>> # edge_attr='value')
>>> # pr = dcg.pagerank(dg)
>>> chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> ddf = dask_cudf.read_csv(datasets_path / "karate.csv",
... chunksize=chunksize, delimiter=" ",
... names=["src", "dst", "value"],
... dtype=["int32", "int32", "float32"])
>>> dg = cugraph.Graph(directed=True)
>>> dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst')
>>> pr = dcg.pagerank(dg)

"""
nstart = None
Expand Down
19 changes: 11 additions & 8 deletions python/cugraph/cugraph/dask/traversal/bfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,22 @@ def bfs(input_graph,

Examples
--------
>>> # import cugraph.dask as dcg
>>> import cugraph.dask as dcg
>>> import dask_cudf
>>> # ... Init a DASK Cluster
>>> # see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
>>> # Download dataset from https://github.com/rapidsai/cugraph/datasets/..
>>> # chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> # ddf = dask_cudf.read_csv(input_data_path, chunksize=chunksize)
>>> # dg = cugraph.Graph(directed=True)
>>> # dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
>>> # edge_attr='value')
>>> # df = dcg.bfs(dg, 0)
>>> chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> ddf = dask_cudf.read_csv(datasets_path / "karate.csv",
... chunksize=chunksize, delimiter=" ",
... names=["src", "dst", "value"],
... dtype=["int32", "int32", "float32"])
>>> dg = cugraph.Graph(directed=True)
>>> dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
... edge_attr='value')
>>> df = dcg.bfs(dg, 0)

"""
# FIXME: Uncomment out the above (broken) example

client = default_client()

Expand Down
Loading