Skip to content

Commit

Permalink
Merge pull request #12 from nv-rliu/24.12-pre-commit
Browse files Browse the repository at this point in the history
Update `.pre-commit-config.yaml` and Implement Suggestions
  • Loading branch information
nv-rliu authored Oct 31, 2024
2 parents 555f7fd + afe37ae commit 3e09b1c
Show file tree
Hide file tree
Showing 57 changed files with 150 additions and 1,922 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ per-file-ignores =
__init__.py:F401,F403,
_nx_cugraph/__init__.py:E501,
nx_cugraph/__init__.py:E402,F401,F403,
benchmarks/nx-cugraph/pytest-based/create_results_summary_page.py:E501,W605,
docs/nx-cugraph/source/conf.py:E501
44 changes: 5 additions & 39 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,13 @@ jobs:
pr-builder:
needs:
- checks
- docs-build
- wheel-build-nx-cugraph
- wheel-tests-nx-cugraph
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
if: always()
with:
needs: ${{ toJSON(needs) }}
checks:
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@python-3.12
uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.12
with:
enable_check_generated_files: false
conda-notebook-tests:
needs: conda-python-build
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: pull-request
node_type: "gpu-v100-latest-1"
arch: "amd64"
container_image: "rapidsai/ci-conda:cuda11.8.0-ubuntu22.04-py3.10"
run_script: "ci/test_notebooks.sh"
docs-build:
needs: conda-python-build
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: pull-request
node_type: "gpu-v100-latest-1"
arch: "amd64"
container_image: "rapidsai/ci-conda:cuda11.8.0-ubuntu22.04-py3.10"
run_script: "ci/build_docs.sh"
wheel-build-nx-cugraph:
needs: wheel-tests-pylibcugraph
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: pull-request
script: ci/build_wheel_nx-cugraph.sh
wheel-tests-nx-cugraph:
needs: wheel-build-nx-cugraph
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: pull-request
script: ci/test_wheel_nx-cugraph.sh
75 changes: 56 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,91 @@
## https://pre-commit.com/
#
# Before first use: `pre-commit install`
# To run: `pre-commit run --all-files`
# To run: `make lint`
# To update: `make lint-update`
# - &flake8_dependencies below needs updated manually
exclude: '^thirdparty'
fail_fast: false
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-ast
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude_types: [svg]
- id: mixed-line-ending
- id: no-commit-to-branch
args: [-p, "^branch-2....$"]
- id: trailing-whitespace
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
args: ["--config=.flake8"]
files: nx_cugraph.*$
types: [file]
types_or: [python] # TODO: Enable [python, cython]
additional_dependencies: ["flake8-force"]
args: ["--config=.flake8"] # uses config
additional_dependencies: &flake8_dependencies
# These versions need updated manually
- flake8==7.1.1
- flake8-bugbear==24.8.19
- flake8-simplify==0.21.0
- repo: https://github.com/asottile/yesqa
rev: v1.3.0
hooks:
- id: yesqa
additional_dependencies:
- flake8==7.1.1
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.6
additional_dependencies: *flake8_dependencies
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.19
hooks:
- id: validate-pyproject
name: Validate pyproject.toml
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
- id: autoflake
args: [--in-place]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: clang-format
types_or: [c, c++, cuda]
args: ["-fallback-style=none", "-style=file", "-i"]
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py310-plus]
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
types_or: [python, rst, markdown]
additional_dependencies: [tomli]
files: ^(nx_cugraph|docs)/
args: ["-L thirdparty,coo,COO,numer"]
- repo: https://github.com/rapidsai/pre-commit-hooks
rev: v0.4.0
hooks:
- id: verify-copyright
files: |
(?x)
[.](cmake|cpp|cu|cuh|h|hpp|sh|pxd|py|pyx)$|
CMakeLists[.]txt$|
CMakeLists_standalone[.]txt$|
[.](sh|py)$|
[.]flake8[.]cython$|
meta[.]yaml$|
setup[.]cfg$
- id: verify-alpha-spec
args: ["--fix"]
- repo: https://github.com/rapidsai/dependency-file-generator
rev: v1.13.11
rev: v1.16.0
hooks:
- id: rapids-dependency-file-generator
args: ["--clean"]
Expand All @@ -61,7 +98,7 @@ repos:
types: [python]
language: python
pass_filenames: false
additional_dependencies: ["networkx>=3.3"]
additional_dependencies: ["networkx>=3.4"]
- repo: local
hooks:
- id: nx-cugraph-readme-update
Expand Down
10 changes: 1 addition & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@
SHELL= /bin/bash

.PHONY: all
all: plugin-info lint readme

.PHONY: lint
lint:
git ls-files | xargs pre-commit run --config lint.yaml --files || true

.PHONY: lint-update
lint-update:
pre-commit autoupdate --config lint.yaml
all: plugin-info readme

.PHONY: plugin-info
plugin-info:
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/nx-cugraph/pytest-based/bench_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import random

import networkx as nx
import pandas as pd
import pytest
from cugraph import datasets

import nx_cugraph as nxcg

# Attempt to import the NetworkX dispatching module, which is only needed when
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
Empty file modified ci/check_style.sh
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ files:
- test_notebook
py_build_nx_cugraph:
output: pyproject
pyproject_dir: python/nx-cugraph
pyproject_dir: .
extras:
table: build-system
includes:
- python_build_rapids
- python_build_wheel
py_run_nx_cugraph:
output: pyproject
pyproject_dir: python/nx-cugraph
pyproject_dir: .
extras:
table: project
includes:
Expand All @@ -53,7 +53,7 @@ files:
- python_run_nx_cugraph
py_test_nx_cugraph:
output: pyproject
pyproject_dir: python/nx-cugraph
pyproject_dir: .
extras:
table: project.optional-dependencies
key: test
Expand Down
53 changes: 0 additions & 53 deletions docs/nx-cugraph/source/basics/cugraph_cascading.md

This file was deleted.

Loading

0 comments on commit 3e09b1c

Please sign in to comment.