From f072c8f8aaeb59aca5af90eb32fe7a97dccb8d0a Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Mon, 22 Jan 2024 18:37:10 -0800 Subject: [PATCH 01/12] nx-cugraph: use coverage to ensure all algorithms were run --- ci/test_python.sh | 5 ++ .../nx_cugraph/tests/ensure_algos_covered.py | 82 +++++++++++++++++++ python/nx-cugraph/run_nx_tests.sh | 8 +- 3 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py diff --git a/ci/test_python.sh b/ci/test_python.sh index 7eb5a08edc8..f0d878a87f8 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -116,6 +116,11 @@ pushd python/nx-cugraph _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 +pytest --cov=nx_cugraph --cov-append --cov-report= +coverage json +python nx_cugraph/tests/ensure_algos_covered.py popd rapids-logger "pytest cugraph-service (single GPU)" diff --git a/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py b/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py new file mode 100644 index 00000000000..88d3d01927b --- /dev/null +++ b/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py @@ -0,0 +1,82 @@ +# Copyright (c) 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. +"""Ensure that all functions wrapped by @networkx_algorithm were called. + +This file is run by CI and should not normally be run manually. +""" +import inspect +import json +from pathlib import Path + +from nx_cugraph.interface import BackendInterface +from nx_cugraph.utils import networkx_algorithm + +with Path("coverage.json").open() as f: + coverage = json.load(f) + +filenames_to_executed_lines = { + filename: set(coverage_info["executed_lines"]) + for filename, coverage_info in coverage["files"].items() +} + + +def unwrap(func): + while hasattr(func, "__wrapped__"): + func = func.__wrapped__ + return func + + +def get_func_filename(func): + return "nx_cugraph" + inspect.getfile(unwrap(func)).rsplit("nx_cugraph", 1)[-1] + + +def get_func_linenos(func): + lines, lineno = inspect.getsourcelines(unwrap(func)) + for i, line in enumerate(lines, lineno): + if ":\n" in line: + return set(range(i + 1, lineno + len(lines))) + raise RuntimeError(f"Could not determine line numbers for function {func}") + + +def has_any_coverage(func): + return bool( + filenames_to_executed_lines[get_func_filename(func)] & get_func_linenos(func) + ) + + +def main(): + no_coverage = set() + for attr, func in vars(BackendInterface).items(): + if not isinstance(func, networkx_algorithm): + continue + if not has_any_coverage(func): + no_coverage.add(attr) + if no_coverage: + msg = "The following algorithms have no coverage: " + ", ".join( + sorted(no_coverage) + ) + # Create a border of "!" + msg = ( + "\n\n" + + "!" * (len(msg) + 6) + + "\n!! " + + msg + + " !!\n" + + "!" * (len(msg) + 6) + + "\n" + ) + raise AssertionError(msg) + + +if __name__ == "__main__": + main() diff --git a/python/nx-cugraph/run_nx_tests.sh b/python/nx-cugraph/run_nx_tests.sh index 07c97cdf947..936af75e53b 100755 --- a/python/nx-cugraph/run_nx_tests.sh +++ b/python/nx-cugraph/run_nx_tests.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. # # NETWORKX_GRAPH_CONVERT=cugraph # Used by networkx versions 3.0 and 3.1 @@ -30,7 +30,7 @@ NETWORKX_TEST_BACKEND=cugraph \ NETWORKX_FALLBACK_TO_NX=True \ pytest \ --pyargs networkx \ - --cov=nx_cugraph.algorithms \ - --cov-report term-missing \ - --no-cov-on-fail \ + --cov=nx_cugraph \ + --cov-report= \ "$@" +coverage report --include="nx_cugraph/algorithms/*" --omit=__init__.py --show-missing From 0f10c635825c9f05f979ccb1375fef2dd57f602e Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Tue, 23 Jan 2024 06:48:02 -0800 Subject: [PATCH 02/12] investigate --- ci/test_python.sh | 7 +++++-- python/nx-cugraph/run_nx_tests.sh | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ci/test_python.sh b/ci/test_python.sh index f0d878a87f8..76041899c43 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -118,8 +118,11 @@ 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 -pytest --cov=nx_cugraph --cov-append --cov-report= -coverage json +coverage report +coverage report --data-file=.coverage +pytest --cov=nx_cugraph --cov-append --data-file=.coverage +coverage json --data-file=.coverage +cat coverage.json python nx_cugraph/tests/ensure_algos_covered.py popd diff --git a/python/nx-cugraph/run_nx_tests.sh b/python/nx-cugraph/run_nx_tests.sh index 936af75e53b..b0bed6741f9 100755 --- a/python/nx-cugraph/run_nx_tests.sh +++ b/python/nx-cugraph/run_nx_tests.sh @@ -31,6 +31,5 @@ NETWORKX_FALLBACK_TO_NX=True \ pytest \ --pyargs networkx \ --cov=nx_cugraph \ - --cov-report= \ "$@" -coverage report --include="nx_cugraph/algorithms/*" --omit=__init__.py --show-missing +coverage report --include="nx_cugraph/algorithms/*" --omit=__init__.py --show-missing --data-file=.coverage From ca8e60c28f1aaa3caa79d1bfedd7b381ad861ecd Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Wed, 24 Jan 2024 17:17:53 -0800 Subject: [PATCH 03/12] More investigations --- ci/test_python.sh | 6 ++++-- python/nx-cugraph/run_nx_tests.sh | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ci/test_python.sh b/ci/test_python.sh index 76041899c43..4bde7e47c88 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -110,6 +110,8 @@ popd rapids-logger "pytest networkx using nx-cugraph backend" pushd python/nx-cugraph +rm nx_cugraph/.coverage +env ./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. @@ -119,8 +121,8 @@ 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 coverage report -coverage report --data-file=.coverage -pytest --cov=nx_cugraph --cov-append --data-file=.coverage +coverage report --data-file=.coverage --rcfile=pyproject.toml +pytest --cov=nx_cugraph --cov-append --cov-config=pyproject.toml coverage json --data-file=.coverage cat coverage.json python nx_cugraph/tests/ensure_algos_covered.py diff --git a/python/nx-cugraph/run_nx_tests.sh b/python/nx-cugraph/run_nx_tests.sh index b0bed6741f9..852e0735aca 100755 --- a/python/nx-cugraph/run_nx_tests.sh +++ b/python/nx-cugraph/run_nx_tests.sh @@ -31,5 +31,11 @@ NETWORKX_FALLBACK_TO_NX=True \ pytest \ --pyargs networkx \ --cov=nx_cugraph \ + --cov-config=pyproject.toml \ "$@" -coverage report --include="nx_cugraph/algorithms/*" --omit=__init__.py --show-missing --data-file=.coverage +coverage report \ + --include="nx_cugraph/algorithms/*" \ + --omit=__init__.py \ + --show-missing \ + --data-file=.coverage \ + --rcfile=pyproject.toml From 90b7f4cff2d4a34e15d97fc0baa4a2ea0be94a05 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Wed, 24 Jan 2024 17:24:33 -0800 Subject: [PATCH 04/12] More info --- ci/test_python.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/test_python.sh b/ci/test_python.sh index 4bde7e47c88..c53369271fc 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -112,6 +112,7 @@ rapids-logger "pytest networkx using nx-cugraph backend" pushd python/nx-cugraph rm nx_cugraph/.coverage env +conda list ./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. From 9c89875da75c1979197f20a5a40a42b26189212d Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Wed, 24 Jan 2024 17:58:43 -0800 Subject: [PATCH 05/12] Update to maybe work with non-editable installs --- ci/test_python.sh | 20 +++++++++---------- .../nx_cugraph/tests/ensure_algos_covered.py | 2 +- python/nx-cugraph/run_nx_tests.sh | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ci/test_python.sh b/ci/test_python.sh index c53369271fc..e090373e9c9 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -110,10 +110,11 @@ popd rapids-logger "pytest networkx using nx-cugraph backend" pushd python/nx-cugraph -rm nx_cugraph/.coverage -env -conda list -./run_nx_tests.sh +mkdir new_directory_for_coverage +cd new_directory_for_coverage +env # XXX: delete me +conda list # XXX: delete me +../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") @@ -121,12 +122,11 @@ 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 -coverage report -coverage report --data-file=.coverage --rcfile=pyproject.toml -pytest --cov=nx_cugraph --cov-append --cov-config=pyproject.toml -coverage json --data-file=.coverage -cat coverage.json -python nx_cugraph/tests/ensure_algos_covered.py +coverage report --rcfile=../pyproject.toml # XXX: delete me +pytest --pyargs nx_cugraph --cov=nx_cugraph --cov-append --cov-config=../pyproject.toml +coverage json --rcfile=../pyproject.toml +cat coverage.json # XXX: delete me +python -m nx_cugraph.tests.ensure_algos_covered popd rapids-logger "pytest cugraph-service (single GPU)" diff --git a/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py b/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py index 88d3d01927b..ee096c428af 100644 --- a/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py +++ b/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py @@ -25,7 +25,7 @@ coverage = json.load(f) filenames_to_executed_lines = { - filename: set(coverage_info["executed_lines"]) + filename.rsplit("nx-cugraph/", 1)[-1]: set(coverage_info["executed_lines"]) for filename, coverage_info in coverage["files"].items() } diff --git a/python/nx-cugraph/run_nx_tests.sh b/python/nx-cugraph/run_nx_tests.sh index 852e0735aca..dfc85f25f1f 100755 --- a/python/nx-cugraph/run_nx_tests.sh +++ b/python/nx-cugraph/run_nx_tests.sh @@ -31,11 +31,11 @@ NETWORKX_FALLBACK_TO_NX=True \ pytest \ --pyargs networkx \ --cov=nx_cugraph \ - --cov-config=pyproject.toml \ + --cov-config=$(dirname $0)/pyproject.toml \ "$@" + # --cov-report= # XXX: uncomment me and move me above coverage report \ - --include="nx_cugraph/algorithms/*" \ + --include="*/nx_cugraph/algorithms/*" \ --omit=__init__.py \ --show-missing \ - --data-file=.coverage \ - --rcfile=pyproject.toml + --rcfile=$(dirname $0)/pyproject.toml From 762436be5f4365f0431f920e0ba3ab4c3a7e3e4f Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Thu, 25 Jan 2024 07:49:50 -0800 Subject: [PATCH 06/12] Fix (hopefully) and clean up --- ci/test_python.sh | 6 +----- python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py | 3 ++- python/nx-cugraph/run_nx_tests.sh | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ci/test_python.sh b/ci/test_python.sh index e090373e9c9..6793357cabc 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -112,8 +112,6 @@ rapids-logger "pytest networkx using nx-cugraph backend" pushd python/nx-cugraph mkdir new_directory_for_coverage cd new_directory_for_coverage -env # XXX: delete me -conda list # XXX: delete me ../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. @@ -122,10 +120,8 @@ 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 -coverage report --rcfile=../pyproject.toml # XXX: delete me -pytest --pyargs nx_cugraph --cov=nx_cugraph --cov-append --cov-config=../pyproject.toml +pytest --pyargs nx_cugraph --cov=nx_cugraph --cov-append --cov-config=../pyproject.toml --cov-report= coverage json --rcfile=../pyproject.toml -cat coverage.json # XXX: delete me python -m nx_cugraph.tests.ensure_algos_covered popd diff --git a/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py b/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py index ee096c428af..fb70864edb5 100644 --- a/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py +++ b/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py @@ -25,7 +25,8 @@ coverage = json.load(f) filenames_to_executed_lines = { - filename.rsplit("nx-cugraph/", 1)[-1]: set(coverage_info["executed_lines"]) + "nx_cugraph/" + + filename.rsplit("nx_cugraph/", 1)[-1]: set(coverage_info["executed_lines"]) for filename, coverage_info in coverage["files"].items() } diff --git a/python/nx-cugraph/run_nx_tests.sh b/python/nx-cugraph/run_nx_tests.sh index dfc85f25f1f..d275a79c397 100755 --- a/python/nx-cugraph/run_nx_tests.sh +++ b/python/nx-cugraph/run_nx_tests.sh @@ -32,8 +32,8 @@ NETWORKX_FALLBACK_TO_NX=True \ --pyargs networkx \ --cov=nx_cugraph \ --cov-config=$(dirname $0)/pyproject.toml \ + --cov-report= \ "$@" - # --cov-report= # XXX: uncomment me and move me above coverage report \ --include="*/nx_cugraph/algorithms/*" \ --omit=__init__.py \ From 109535047eb4b39fd4129e0a276411e56eba1d1d Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Thu, 25 Jan 2024 12:23:09 -0800 Subject: [PATCH 07/12] Test generic_bfs_edges --- .../traversal/breadth_first_search.py | 2 +- .../nx-cugraph/nx_cugraph/tests/test_bfs.py | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 python/nx-cugraph/nx_cugraph/tests/test_bfs.py diff --git a/python/nx-cugraph/nx_cugraph/algorithms/traversal/breadth_first_search.py b/python/nx-cugraph/nx_cugraph/algorithms/traversal/breadth_first_search.py index ef1c011363a..f5d5e2a995d 100644 --- a/python/nx-cugraph/nx_cugraph/algorithms/traversal/breadth_first_search.py +++ b/python/nx-cugraph/nx_cugraph/algorithms/traversal/breadth_first_search.py @@ -68,7 +68,7 @@ def generic_bfs_edges(G, source, neighbors=None, depth_limit=None, sort_neighbor raise NotImplementedError( "sort_neighbors argument in generic_bfs_edges is not currently supported" ) - return bfs_edges(source, depth_limit=depth_limit) + return bfs_edges(G, source, depth_limit=depth_limit) @generic_bfs_edges._can_run diff --git a/python/nx-cugraph/nx_cugraph/tests/test_bfs.py b/python/nx-cugraph/nx_cugraph/tests/test_bfs.py new file mode 100644 index 00000000000..7733f63c210 --- /dev/null +++ b/python/nx-cugraph/nx_cugraph/tests/test_bfs.py @@ -0,0 +1,34 @@ +# Copyright (c) 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 networkx as nx +import pytest +from packaging.version import parse + + +nxver = parse(nx.__version__) + +if nxver.major == 3 and nxver.minor < 2: + pytest.skip("Need NetworkX >=3.2 to test clustering", allow_module_level=True) + + +def test_generic_bfs_edges(): + # generic_bfs_edges currently isn't exercised by networkx tests + Gnx = nx.karate_club_graph() + Gcg = nx.karate_club_graph(backend="cugraph") + for depth_limit in (0, 1, 2): + for source in Gnx: + # Some ordering is arbitrary, so I think there's a chance + # this test may fail if networkx or nx-cugraph changes. + nx_result = nx.generic_bfs_edges(Gnx, source, depth_limit=depth_limit) + cg_result = nx.generic_bfs_edges(Gcg, source, depth_limit=depth_limit) + assert sorted(nx_result) == sorted(cg_result), (source, depth_limit) From dc2dfeb5df42d20b42a48f44b80610a508843062 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Thu, 25 Jan 2024 12:24:51 -0800 Subject: [PATCH 08/12] bump --- python/nx-cugraph/lint.yaml | 2 +- python/nx-cugraph/nx_cugraph/tests/test_bfs.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/python/nx-cugraph/lint.yaml b/python/nx-cugraph/lint.yaml index 5a4773168b6..8e87fc23592 100644 --- a/python/nx-cugraph/lint.yaml +++ b/python/nx-cugraph/lint.yaml @@ -26,7 +26,7 @@ repos: - id: mixed-line-ending - id: trailing-whitespace - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.15 + rev: v0.16 hooks: - id: validate-pyproject name: Validate pyproject.toml diff --git a/python/nx-cugraph/nx_cugraph/tests/test_bfs.py b/python/nx-cugraph/nx_cugraph/tests/test_bfs.py index 7733f63c210..c2b22e98949 100644 --- a/python/nx-cugraph/nx_cugraph/tests/test_bfs.py +++ b/python/nx-cugraph/nx_cugraph/tests/test_bfs.py @@ -14,7 +14,6 @@ import pytest from packaging.version import parse - nxver = parse(nx.__version__) if nxver.major == 3 and nxver.minor < 2: From 240891f8af70bb05e679a882c226bbb7fef91336 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Thu, 25 Jan 2024 17:25:19 -0800 Subject: [PATCH 09/12] try this --- ci/test_python.sh | 19 +++++++++++++++---- python/nx-cugraph/run_nx_tests.sh | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ci/test_python.sh b/ci/test_python.sh index 6793357cabc..652b015c3b0 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -109,10 +109,10 @@ pytest \ popd rapids-logger "pytest networkx using nx-cugraph backend" -pushd python/nx-cugraph +pushd python mkdir new_directory_for_coverage cd new_directory_for_coverage -../run_nx_tests.sh +../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") @@ -120,8 +120,19 @@ 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 -pytest --pyargs nx_cugraph --cov=nx_cugraph --cov-append --cov-config=../pyproject.toml --cov-report= -coverage json --rcfile=../pyproject.toml +pytest \ + --pyargs nx_cugraph \ + --config-file=../nx-cugraph/pyproject.toml \ + --cov-config=../nx-cugraph/pyproject.toml \ + --cov=nx_cugraph \ + --cov-append \ + --cov-report= +coverage report \ + --include="*/nx_cugraph/algorithms/*" \ + --omit=__init__.py \ + --show-missing \ + --rcfile=../nx-cugraph/pyproject.toml +coverage json --rcfile=../nx-cugraph/pyproject.toml python -m nx_cugraph.tests.ensure_algos_covered popd diff --git a/python/nx-cugraph/run_nx_tests.sh b/python/nx-cugraph/run_nx_tests.sh index d275a79c397..da7a2014cef 100755 --- a/python/nx-cugraph/run_nx_tests.sh +++ b/python/nx-cugraph/run_nx_tests.sh @@ -30,8 +30,9 @@ NETWORKX_TEST_BACKEND=cugraph \ NETWORKX_FALLBACK_TO_NX=True \ pytest \ --pyargs networkx \ - --cov=nx_cugraph \ + --config-file=$(dirname $0)/pyproject.toml \ --cov-config=$(dirname $0)/pyproject.toml \ + --cov=nx_cugraph \ --cov-report= \ "$@" coverage report \ From f50f34eedcdcd5bafffb6036481430acce005412 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 26 Jan 2024 08:09:23 -0800 Subject: [PATCH 10/12] Try using editable install to make coverage work --- ci/test_python.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ci/test_python.sh b/ci/test_python.sh index 652b015c3b0..965ec4f66e2 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -109,10 +109,10 @@ pytest \ popd rapids-logger "pytest networkx using nx-cugraph backend" -pushd python -mkdir new_directory_for_coverage -cd new_directory_for_coverage -../nx-cugraph/run_nx_tests.sh +pushd python/nx-cugraph +# Use editable install to make coverage work +pip install -e . --no-deps +./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") @@ -122,8 +122,8 @@ echo $_coverage | awk '{ if ($NF == "0.0%") exit 1 }' # Run our tests again (they're fast enough) to add their coverage, then create coverage.json pytest \ --pyargs nx_cugraph \ - --config-file=../nx-cugraph/pyproject.toml \ - --cov-config=../nx-cugraph/pyproject.toml \ + --config-file=./pyproject.toml \ + --cov-config=./pyproject.toml \ --cov=nx_cugraph \ --cov-append \ --cov-report= @@ -131,8 +131,8 @@ coverage report \ --include="*/nx_cugraph/algorithms/*" \ --omit=__init__.py \ --show-missing \ - --rcfile=../nx-cugraph/pyproject.toml -coverage json --rcfile=../nx-cugraph/pyproject.toml + --rcfile=./pyproject.toml +coverage json --rcfile=./pyproject.toml python -m nx_cugraph.tests.ensure_algos_covered popd From 89d71ac3f852660dd11c582902afefbae5ced3dd Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 26 Jan 2024 08:20:13 -0800 Subject: [PATCH 11/12] Exercise (and show results of) scripts that show implemented networkx algorithms in CI --- ci/test_python.sh | 3 +++ python/nx-cugraph/nx_cugraph/scripts/print_table.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/test_python.sh b/ci/test_python.sh index 965ec4f66e2..62d84683c2a 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -134,6 +134,9 @@ coverage report \ --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 "pytest cugraph-service (single GPU)" diff --git a/python/nx-cugraph/nx_cugraph/scripts/print_table.py b/python/nx-cugraph/nx_cugraph/scripts/print_table.py index 7e69de63dc1..117a1444f48 100755 --- a/python/nx-cugraph/nx_cugraph/scripts/print_table.py +++ b/python/nx-cugraph/nx_cugraph/scripts/print_table.py @@ -59,7 +59,7 @@ def main(path_to_info=None, *, file=sys.stdout): if path_to_info is None: path_to_info = get_path_to_info(version_added_sep=".") lines = ["networkx_path,dispatch_name,version_added,plc,is_incomplete,is_different"] - lines.extend(",".join(info) for info in path_to_info.values()) + lines.extend(",".join(map(str, info)) for info in path_to_info.values()) text = "\n".join(lines) print(text, file=file) return text From 89212ab8e546711d137ffe3c84e3255e8232ae69 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 26 Jan 2024 10:56:17 -0800 Subject: [PATCH 12/12] Print success message --- python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py b/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py index fb70864edb5..7047f0eeafd 100644 --- a/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py +++ b/python/nx-cugraph/nx_cugraph/tests/ensure_algos_covered.py @@ -77,6 +77,7 @@ def main(): + "\n" ) raise AssertionError(msg) + print("\nSuccess: coverage determined all algorithms were called!\n") if __name__ == "__main__":