Skip to content

Commit

Permalink
Add pre-commit suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
nv-rliu committed Oct 30, 2024
1 parent 6eabafa commit 6a4b71c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 50 deletions.
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ repos:
types_or: [python, rst, markdown]
additional_dependencies: [tomli]
files: ^(nx_cugraph|docs)/
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.7
hooks:
- id: ruff
args: [--show-fixes]
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.6
hooks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
# limitations under the License.


import re
import pathlib
import json
import pathlib
import platform
import psutil
import re
import socket
import subprocess

import psutil


def get_formatted_time_value(time):
res = ""
if time < 1:
if time < 0.001:
units = "us"
Expand All @@ -40,7 +40,8 @@ def get_all_benchmark_info():
# Populate benchmarks dir from .json files
for json_file in logs_dir.glob("*.json"):
try:
data = json.loads(open(json_file).read())
with open(json_file) as file:
data = json.loads(file.read())
except json.decoder.JSONDecodeError:
continue

Expand Down Expand Up @@ -155,8 +156,8 @@ def get_system_info():
if __name__ == "__main__":
logs_dir = pathlib.Path("logs")

dataset_patt = re.compile(".*ds=([\w-]+).*")
backend_patt = re.compile(".*backend=(\w+).*")
dataset_patt = re.compile(r".*ds=([\w-]+).*")
backend_patt = re.compile(r".*backend=(\w+).*")
k_patt = re.compile(".*k=(10*).*")

# Organize all benchmark runs by the following hierarchy: algo -> backend -> dataset
Expand Down Expand Up @@ -266,7 +267,7 @@ def get_system_info():
f" <td>{nx_formatted} / {cg_formatted}<br>{speedup}<br>{runtime_delta}</td>"
)
else:
print(f" <td></td>")
print(" <td></td>")

# If a comparison between cugraph and NX cannot be made, output empty cells
# for each dataset
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/nx-cugraph/pytest-based/get_graph_bench_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
Positional Arguments:
1) dataset name (e.g. 'email_Eu_core', 'cit-patents')
available datasets can be found here: `python/cugraph/cugraph/datasets/__init__.py`
available datasets can be found here:
- `python/cugraph/cugraph/datasets/__init__.py`
"""

import sys

import cugraph.datasets as cgds


if __name__ == "__main__":
# download and store dataset (csv) by using the Datasets API
dataset = sys.argv[1].replace("-", "_")
Expand Down
77 changes: 42 additions & 35 deletions docs/nx-cugraph/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@
import os
import sys

from packaging.version import Version

import cugraph
from github_link import make_linkcode_resolve
from packaging.version import Version

# If extensions (or modules to document with autodoc) are in another
# directory, add these directories to sys.path here. If the directory
# is relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here.
sys.path.insert(0, os.path.abspath('sphinxext'))
sys.path.insert(0, os.path.abspath("sphinxext"))

from github_link import make_linkcode_resolve # noqa

# -- General configuration ------------------------------------------------

Expand All @@ -47,8 +46,8 @@
"sphinx.ext.autosummary",
"numpydoc",
"sphinx_markdown_tables",
'sphinx.ext.doctest',
'sphinx.ext.linkcode',
"sphinx.ext.doctest",
"sphinx.ext.linkcode",
"IPython.sphinxext.ipython_console_highlighting",
"IPython.sphinxext.ipython_directive",
"nbsphinx",
Expand All @@ -57,10 +56,10 @@
]


ipython_mplbackend = 'str'
ipython_mplbackend = "str"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
Expand All @@ -69,12 +68,12 @@
source_suffix = {".rst": "restructuredtext", ".md": "markdown"}

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'cugraph'
copyright = '2019-2023, NVIDIA Corporation'
author = 'NVIDIA Corporation'
project = "cugraph"
copyright = "2019-2023, NVIDIA Corporation"
author = "NVIDIA Corporation"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -84,22 +83,23 @@
# The short X.Y version.
version = f"{CUGRAPH_VERSION.major:02}.{CUGRAPH_VERSION.minor:02}"
# The full version, including alpha/beta/rc tags.
release = f"{CUGRAPH_VERSION.major:02}.{CUGRAPH_VERSION.minor:02}.{CUGRAPH_VERSION.micro:02}"
release = f"{CUGRAPH_VERSION.major:02}.{CUGRAPH_VERSION.minor:02}.\
{CUGRAPH_VERSION.micro:02}"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -111,7 +111,7 @@
# a list of builtin themes.
#

html_theme = 'pydata_sphinx_theme'
html_theme = "pydata_sphinx_theme"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -131,13 +131,13 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'cugraphdoc'
htmlhelp_basename = "cugraphdoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -146,15 +146,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -164,19 +161,21 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'cugraph.tex', 'cugraph Documentation',
'NVIDIA Corporation', 'manual'),
(
master_doc,
"cugraph.tex",
"cugraph Documentation",
"NVIDIA Corporation",
"manual",
),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'cugraph', 'cugraph Documentation',
[author], 1)
]
man_pages = [(master_doc, "cugraph", "cugraph Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -185,9 +184,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'cugraph', 'cugraph Documentation',
author, 'cugraph', 'GPU-accelerated graph analysis.',
'Miscellaneous'),
(
master_doc,
"cugraph",
"cugraph Documentation",
author,
"cugraph",
"GPU-accelerated graph analysis.",
"Miscellaneous",
),
]

# Connect docs in other projects
Expand All @@ -209,21 +214,23 @@

def setup(app):
app.add_css_file("https://docs.rapids.ai/assets/css/custom.css")
app.add_js_file("https://docs.rapids.ai/assets/js/custom.js", loading_method="defer")
app.add_js_file(
"https://docs.rapids.ai/assets/js/custom.js", loading_method="defer"
)
app.add_css_file("references.css")


source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]

# The following is used by sphinx.ext.linkcode to provide links to github
linkcode_resolve = make_linkcode_resolve(
"https://github.com/rapidsai/cugraph/blob/{revision}/python/{path}#L{lineno}"
)

breathe_projects = {
'libcugraph': os.environ['XML_DIR_LIBCUGRAPH'],
'libcugraphops': os.environ['XML_DIR_LIBCUGRAPHOPS'],
'libwholegraph': os.environ['XML_DIR_LIBWHOLEGRAPH']
"libcugraph": os.environ["XML_DIR_LIBCUGRAPH"],
"libcugraphops": os.environ["XML_DIR_LIBCUGRAPHOPS"],
"libwholegraph": os.environ["XML_DIR_LIBWHOLEGRAPH"],
}

breathe_default_project = "libcugraph"

0 comments on commit 6a4b71c

Please sign in to comment.