-
Notifications
You must be signed in to change notification settings - Fork 10
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
add CI workflows running tests #15
Merged
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1a03686
add CI workflows running tests
jameslamb 9b2913d
add filters to reduce CI matrix
jameslamb a72af9e
add 'test_python' dependency group in dependencies.yaml
jameslamb 2039797
remove matrix filters for conda jobs
jameslamb 9b7702b
fix paths in testing scripts
jameslamb b442bc5
Run tests for coverage from nx_cugraph/ directory
eriknw 09d876b
Xfail networkx test; also, no verbose test for now
eriknw 2baf14c
fix path
jameslamb e42d44d
guess this really was supposed to be _nx_cugraph
jameslamb ff75d3d
Fix `_nxver` comparisons for variable length tuples
eriknw 52eddd3
skip codecov
jameslamb ea00a10
run_nx_cugraph_pytests.sh verbose for first pytest
eriknw 768c8a9
oops fix
eriknw 0dfad33
Minor cleanup
eriknw b0089ac
Add ruff to pre-commit hook
eriknw 550d503
add check-executables-have-shebangs pre-commit hook
eriknw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ jobs: | |
- changed-files | ||
- checks | ||
- conda-python-build | ||
- conda-python-tests | ||
- wheel-build-nx-cugraph | ||
- wheel-tests-nx-cugraph | ||
secrets: inherit | ||
uses: rapidsai/shared-workflows/.github/workflows/[email protected] | ||
if: always() | ||
|
@@ -46,14 +48,30 @@ jobs: | |
uses: rapidsai/shared-workflows/.github/workflows/[email protected] | ||
with: | ||
build_type: pull-request | ||
# This selects "ARCH=amd64 + the latest supported Python + CUDA". | ||
matrix_filter: map(select(.ARCH == "amd64")) | group_by(.CUDA_VER|split(".")|map(tonumber)|.[0]) | map(max_by([(.PY_VER|split(".")|map(tonumber)), (.CUDA_VER|split(".")|map(tonumber))])) | ||
conda-python-tests: | ||
needs: [conda-python-build, changed-files] | ||
secrets: inherit | ||
uses: rapidsai/shared-workflows/.github/workflows/[email protected] | ||
if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python | ||
with: | ||
build_type: pull-request | ||
run_codecov: false | ||
wheel-build-nx-cugraph: | ||
needs: [checks] | ||
secrets: inherit | ||
uses: rapidsai/shared-workflows/.github/workflows/[email protected] | ||
with: | ||
build_type: pull-request | ||
script: ci/build_wheel_nx-cugraph.sh | ||
# This selects "ARCH=amd64 + the latest supported Python + CUDA". | ||
# This selects "ARCH=amd64 + the latest supported Python, 1 job per major CUDA version". | ||
matrix_filter: map(select(.ARCH == "amd64")) | group_by(.CUDA_VER|split(".")|map(tonumber)|.[0]) | map(max_by([(.PY_VER|split(".")|map(tonumber)), (.CUDA_VER|split(".")|map(tonumber))])) | ||
wheel-tests-nx-cugraph: | ||
needs: [wheel-build-nx-cugraph, changed-files] | ||
secrets: inherit | ||
uses: rapidsai/shared-workflows/.github/workflows/[email protected] | ||
if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python | ||
with: | ||
build_type: pull-request | ||
script: ci/test_wheel_nx-cugraph.sh | ||
# This selects "ARCH=amd64 + the latest supported Python, 1 job per major CUDA version". | ||
matrix_filter: map(select(.ARCH == "amd64")) | group_by(.CUDA_VER|split(".")|map(tonumber)|.[0]) | map(max_by([(.PY_VER|split(".")|map(tonumber)), (.CUDA_VER|split(".")|map(tonumber))])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ jobs: | |
branch: ${{ inputs.branch }} | ||
date: ${{ inputs.date }} | ||
sha: ${{ inputs.sha }} | ||
# This selects "ARCH=amd64 + the latest supported Python, 1 job per major CUDA version". | ||
matrix_filter: map(select(.ARCH == "amd64")) | group_by(.CUDA_VER|split(".")|map(tonumber)|.[0]) | map(max_by([(.PY_VER|split(".")|map(tonumber)), (.CUDA_VER|split(".")|map(tonumber))])) | ||
run_codecov: false | ||
wheel-tests-nx-cugraph: | ||
secrets: inherit | ||
uses: rapidsai/shared-workflows/.github/workflows/[email protected] | ||
|
@@ -31,3 +34,5 @@ jobs: | |
date: ${{ inputs.date }} | ||
sha: ${{ inputs.sha }} | ||
script: ci/test_wheel_nx-cugraph.sh | ||
# This selects "ARCH=amd64 + the latest supported Python, 1 job per major CUDA version". | ||
matrix_filter: map(select(.ARCH == "amd64")) | group_by(.CUDA_VER|split(".")|map(tonumber)|.[0]) | map(max_by([(.PY_VER|split(".")|map(tonumber)), (.CUDA_VER|split(".")|map(tonumber))])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
|
||
set -euo pipefail | ||
|
||
# Support invoking run_nx_cugraph_pytests.sh outside the script directory | ||
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/.. | ||
|
||
# Only be verbose and display print information for the first pytest command here | ||
NX_CUGRAPH_USE_COMPAT_GRAPHS=False pytest --capture=no --verbose --cache-clear --benchmark-disable "$@" ./nx_cugraph/tests | ||
NX_CUGRAPH_USE_COMPAT_GRAPHS=True pytest --cache-clear --benchmark-disable "$@" ./nx_cugraph/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2022-2024, NVIDIA CORPORATION. | ||
|
||
set -euo pipefail | ||
|
||
# Support invoking test_python.sh outside the script directory | ||
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ | ||
|
||
. /opt/conda/etc/profile.d/conda.sh | ||
|
||
RAPIDS_VERSION="$(rapids-version)" | ||
|
||
rapids-logger "Generate Python testing dependencies" | ||
rapids-dependency-file-generator \ | ||
--output conda \ | ||
--file-key test_python \ | ||
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml | ||
|
||
rapids-mamba-retry env create --yes -f env.yaml -n test | ||
|
||
# Temporarily allow unbound variables for conda activation. | ||
set +u | ||
conda activate test | ||
set -u | ||
|
||
rapids-logger "Downloading artifacts from previous jobs" | ||
PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) | ||
|
||
RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"} | ||
RAPIDS_COVERAGE_DIR=${RAPIDS_COVERAGE_DIR:-"${PWD}/coverage-results"} | ||
mkdir -p "${RAPIDS_TESTS_DIR}" "${RAPIDS_COVERAGE_DIR}" | ||
|
||
rapids-print-env | ||
|
||
# TODO: remove the '>=24.12.00a1000' once we start publishing nightly packages | ||
# from the 'nx-cugraph' repo and stop publishing them from the 'cugraph' repo | ||
rapids-mamba-retry install \ | ||
--channel "${PYTHON_CHANNEL}" \ | ||
"nx-cugraph=${RAPIDS_VERSION}.*,>=24.12.00a1000" | ||
|
||
rapids-logger "Check GPU usage" | ||
nvidia-smi | ||
|
||
# export LD_PRELOAD="${CONDA_PREFIX}/lib/libgomp.so.1" | ||
|
||
# RAPIDS_DATASET_ROOT_DIR is used by test scripts | ||
# export RAPIDS_DATASET_ROOT_DIR="$(realpath datasets)" | ||
# pushd "${RAPIDS_DATASET_ROOT_DIR}" | ||
# ./get_test_data.sh --benchmark | ||
# popd | ||
|
||
EXITCODE=0 | ||
trap "EXITCODE=1" ERR | ||
set +e | ||
|
||
rapids-logger "pytest nx-cugraph" | ||
./ci/run_nx_cugraph_pytests.sh \ | ||
--junitxml="${RAPIDS_TESTS_DIR}/junit-nx-cugraph.xml" \ | ||
--cov=nx_cugraph \ | ||
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/nx-cugraph-coverage.xml" \ | ||
--cov-report=term | ||
|
||
rapids-logger "pytest networkx using nx-cugraph backend" | ||
|
||
pushd nx_cugraph | ||
../run_nx_tests.sh | ||
|
||
# run_nx_tests.sh outputs coverage data, so check that total coverage is >0.0% | ||
# in case nx-cugraph failed to load but fallback mode allowed the run to pass. | ||
_coverage=$(coverage report | grep "^TOTAL") | ||
|
||
echo "nx-cugraph coverage from networkx tests: $_coverage" | ||
echo $_coverage | awk '{ if ($NF == "0.0%") exit 1 }' | ||
|
||
# Ensure all algorithms were called by comparing covered lines to function lines. | ||
# Run our tests again (they're fast enough) to add their coverage, then create coverage.json | ||
NX_CUGRAPH_USE_COMPAT_GRAPHS=False pytest \ | ||
--pyargs nx_cugraph \ | ||
--config-file=../pyproject.toml \ | ||
--cov-config=../pyproject.toml \ | ||
--cov=nx_cugraph \ | ||
--cov-append \ | ||
--cov-report= | ||
|
||
coverage report \ | ||
--include="*/nx_cugraph/algorithms/*" \ | ||
--omit=__init__.py \ | ||
--show-missing \ | ||
--rcfile=../pyproject.toml | ||
|
||
coverage json --rcfile=../pyproject.toml | ||
|
||
python -m nx_cugraph.tests.ensure_algos_covered | ||
|
||
# Exercise (and show results of) scripts that show implemented networkx algorithms | ||
python -m nx_cugraph.scripts.print_tree --dispatch-name --plc --incomplete --different | ||
python -m nx_cugraph.scripts.print_table | ||
popd | ||
|
||
rapids-logger "Test script exiting with value: $EXITCODE" | ||
exit ${EXITCODE} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2023-2024, NVIDIA CORPORATION. | ||
|
||
set -eoxu pipefail | ||
|
||
package_name="nx-cugraph" | ||
python_package_name=$(echo ${package_name}|sed 's/-/_/g') | ||
|
||
mkdir -p ./dist | ||
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" | ||
|
||
# nx-cugraph is a pure wheel, which is part of generating the download path | ||
RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" RAPIDS_PY_WHEEL_PURE="1" rapids-download-wheels-from-s3 ./dist | ||
|
||
# echo to expand wildcard before adding `[extra]` requires for pip | ||
python -m pip install \ | ||
"$(echo ./dist/${python_package_name}*.whl)[test]" | ||
|
||
# Run smoke tests for aarch64 pull requests | ||
arch=$(uname -m) | ||
if [[ "${arch}" == "aarch64" && ${RAPIDS_BUILD_TYPE} == "pull-request" ]]; then | ||
python ./ci/wheel_smoke_test_${package_name}.py | ||
else | ||
# --import-mode=append. See test_python.sh for details. | ||
# FIXME: Adding PY_IGNORE_IMPORTMISMATCH=1 to workaround conftest.py import | ||
# mismatch error seen by nx-cugraph after using pytest 8 and | ||
# --import-mode=append. | ||
RAPIDS_DATASET_ROOT_DIR=`pwd`/datasets \ | ||
PY_IGNORE_IMPORTMISMATCH=1 \ | ||
NX_CUGRAPH_USE_COMPAT_GRAPHS=False \ | ||
python -m pytest \ | ||
-v \ | ||
--import-mode=append \ | ||
--benchmark-disable \ | ||
./${python_package_name}/tests | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright (c) 2023-2024, 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 | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import math | ||
|
||
import networkx as nx | ||
|
||
import nx_cugraph as nxcg | ||
|
||
if __name__ == "__main__": | ||
G = nx.Graph() | ||
G.add_edges_from([(0, 1), (1, 2), (2, 3)]) | ||
|
||
nx_result = nx.betweenness_centrality(G) | ||
# nx_cugraph is intended to be called via the NetworkX dispatcher, like | ||
# this: | ||
# nxcu_result = nx.betweenness_centrality(G, backend="cugraph") | ||
# | ||
# but here it is being called directly since the NetworkX version that | ||
# supports the "backend" kwarg may not be available in the testing env. | ||
nxcu_result = nxcg.betweenness_centrality(G) | ||
|
||
nx_nodes, nxcu_nodes = nx_result.keys(), nxcu_result.keys() | ||
assert nxcu_nodes == nx_nodes | ||
for node_id in nx_nodes: | ||
nx_bc, nxcu_bc = nx_result[node_id], nxcu_result[node_id] | ||
assert math.isclose( | ||
nx_bc, nxcu_bc, rel_tol=1e-6 | ||
), f"bc for {node_id=} exceeds tolerance: {nx_bc=}, {nxcu_bc=}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saw codecov upload failing like this:
(build link)
Maybe this repo needs to be set up in the codecov UI. But since @eriknw mentioned that codecov isn't really event being used in development of this project right now, I'm proposing just skipping it.