Skip to content

Commit

Permalink
Add environment-agnostic scripts for running ctests and pytests (#4152)
Browse files Browse the repository at this point in the history
This PR adds environment-agnostic `run_*_{ctests,pytests}.sh` scripts, and updates `test_*_{cpp,python}.sh` to call them.

The `test_*_{cpp,python}.sh` scripts assume they're running in our CI environment, and they do more than just run the tests.

This PR allows devs and downstream consumers to only run the tests, and skip the unrelated logic in `test_*_{cpp,python}.sh`.

Authors:
  - Paul Taylor (https://github.com/trxcllnt)

Approvers:
  - Jake Awe (https://github.com/AyodeAwe)

URL: #4152
  • Loading branch information
trxcllnt authored Feb 21, 2024
1 parent be58be1 commit fef6440
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 76 deletions.
14 changes: 14 additions & 0 deletions ci/run_ctests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support customizing the ctests' install location
cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libcugraph/"
ctest --output-on-failure --no-tests=error "$@"

if [ -d "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libcugraph_c/" ]; then
# Support customizing the ctests' install location
cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/libcugraph_c/"
ctest --output-on-failure --no-tests=error "$@"
fi
9 changes: 9 additions & 0 deletions ci/run_cugraph_benchmark_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support invoking run_cugraph_benchmark_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../benchmarks

pytest --capture=no --benchmark-disable -m tiny "$@" cugraph/pytest-based/bench_algos.py
9 changes: 9 additions & 0 deletions ci/run_cugraph_dgl_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support invoking run_cugraph_dgl_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cugraph-dgl/tests

pytest --cache-clear --ignore=mg "$@" .
9 changes: 9 additions & 0 deletions ci/run_cugraph_equivariant_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support invoking run_cugraph_equivariant_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cugraph-equivariant/cugraph_equivariant

pytest --cache-clear "$@" .
9 changes: 9 additions & 0 deletions ci/run_cugraph_pyg_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support invoking run_cugraph_pyg_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cugraph-pyg/cugraph_pyg

pytest --cache-clear --ignore=tests/mg "$@" .
16 changes: 16 additions & 0 deletions ci/run_cugraph_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support invoking run_cugraph_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cugraph/cugraph

DASK_WORKER_DEVICES="${DASK_WORKER_DEVICES:-0}" \
DASK_DISTRIBUTED__SCHEDULER__WORKER_TTL="${DASK_DISTRIBUTED__SCHEDULER__WORKER_TTL:-1000s}" \
DASK_DISTRIBUTED__COMM__TIMEOUTS__CONNECT="${DASK_DISTRIBUTED__COMM__TIMEOUTS__CONNECT:-1000s}" \
DASK_CUDA_WAIT_WORKERS_MIN_TIMEOUT="${DASK_CUDA_WAIT_WORKERS_MIN_TIMEOUT:-1000s}" \
pytest --cache-clear --import-mode=append --benchmark-disable \
-k "not test_property_graph_mg and not test_bulk_sampler_io" \
"$@" \
tests
9 changes: 9 additions & 0 deletions ci/run_cugraph_service_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support invoking run_cugraph_service_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cugraph-service

pytest --capture=no --cache-clear --benchmark-disable -k "not mg" "$@" tests
9 changes: 9 additions & 0 deletions ci/run_nx_cugraph_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/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]}")")"/../python/nx-cugraph/nx_cugraph

pytest --capture=no --cache-clear --benchmark-disable "$@" tests
9 changes: 9 additions & 0 deletions ci/run_pylibcugraph_pytests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

# Support invoking run_pylibcugraph_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/pylibcugraph/pylibcugraph

pytest --cache-clear "$@" tests
15 changes: 4 additions & 11 deletions ci/test_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

set -euo pipefail

# Support invoking test_cpp.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../

. /opt/conda/etc/profile.d/conda.sh

rapids-logger "Generate C++ testing dependencies"
Expand Down Expand Up @@ -38,21 +41,11 @@ pushd "${RAPIDS_DATASET_ROOT_DIR}"
./get_test_data.sh --subset
popd

EXITCODE=0
trap "EXITCODE=1" ERR
set +e

export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/

# Run libcugraph gtests from libcugraph-tests package
rapids-logger "Run gtests"
cd "$CONDA_PREFIX"/bin/gtests/libcugraph/
ctest -j10 --output-on-failure --no-tests=error

if [ -d "$CONDA_PREFIX"/bin/gtests/libcugraph_c/ ]; then
cd "$CONDA_PREFIX"/bin/gtests/libcugraph_c/
ctest -j10 --output-on-failure --no-tests=error
fi
./ci/run_ctests.sh -j10 && EXITCODE=$? || EXITCODE=$?;

rapids-logger "Test script exiting with value: $EXITCODE"
exit ${EXITCODE}
87 changes: 22 additions & 65 deletions ci/test_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

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-logger "Generate Python testing dependencies"
Expand Down Expand Up @@ -52,16 +55,14 @@ trap "EXITCODE=1" ERR
set +e

rapids-logger "pytest pylibcugraph"
pushd python/pylibcugraph/pylibcugraph
pytest \
--cache-clear \
./ci/run_pylibcugraph_pytests.sh \
--verbose \
--junitxml="${RAPIDS_TESTS_DIR}/junit-pylibcugraph.xml" \
--cov-config=../../.coveragerc \
--cov=pylibcugraph \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/pylibcugraph-coverage.xml" \
--cov-report=term \
tests
popd
--cov-report=term


# Test runs that include tests that use dask require
# --import-mode=append. Those tests start a LocalCUDACluster that inherits
Expand All @@ -74,49 +75,26 @@ popd
# FIXME: TEMPORARILY disable MG PropertyGraph tests (experimental) tests and
# bulk sampler IO tests (hangs in CI)
rapids-logger "pytest cugraph"
pushd python/cugraph/cugraph
DASK_WORKER_DEVICES="0" \
DASK_DISTRIBUTED__SCHEDULER__WORKER_TTL="1000s" \
DASK_DISTRIBUTED__COMM__TIMEOUTS__CONNECT="1000s" \
DASK_CUDA_WAIT_WORKERS_MIN_TIMEOUT="1000s" \
pytest \
-v \
--import-mode=append \
--benchmark-disable \
--cache-clear \
./ci/run_cugraph_pytests.sh \
--verbose \
--junitxml="${RAPIDS_TESTS_DIR}/junit-cugraph.xml" \
--cov-config=../../.coveragerc \
--cov=cugraph \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cugraph-coverage.xml" \
--cov-report=term \
-k "not test_property_graph_mg and not test_bulk_sampler_io" \
tests
popd
--cov-report=term


rapids-logger "pytest cugraph benchmarks (run as tests)"
pushd benchmarks
pytest \
--capture=no \
--verbose \
-m tiny \
--benchmark-disable \
cugraph/pytest-based/bench_algos.py
popd
./ci/run_cugraph_benchmark_pytests.sh --verbose

rapids-logger "pytest nx-cugraph"
pushd python/nx-cugraph/nx_cugraph
pytest \
--capture=no \
./ci/run_nx_cugraph_pytests.sh \
--verbose \
--cache-clear \
--junitxml="${RAPIDS_TESTS_DIR}/junit-nx-cugraph.xml" \
--cov-config=../../.coveragerc \
--cov=nx_cugraph \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/nx-cugraph-coverage.xml" \
--cov-report=term \
--benchmark-disable \
tests
popd
--cov-report=term

rapids-logger "pytest networkx using nx-cugraph backend"
pushd python/nx-cugraph
Expand Down Expand Up @@ -150,21 +128,14 @@ python -m nx_cugraph.scripts.print_table
popd

rapids-logger "pytest cugraph-service (single GPU)"
pushd python/cugraph-service
pytest \
--capture=no \
./ci/run_cugraph_service_pytests.sh \
--verbose \
--cache-clear \
--junitxml="${RAPIDS_TESTS_DIR}/junit-cugraph-service.xml" \
--cov-config=../.coveragerc \
--cov=cugraph_service_client \
--cov=cugraph_service_server \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cugraph-service-coverage.xml" \
--cov-report=term \
--benchmark-disable \
-k "not mg" \
tests
popd
--cov-report=term

if [[ "${RAPIDS_CUDA_VERSION}" == "11.8.0" ]]; then
if [[ "${RUNNER_ARCH}" != "ARM64" ]]; then
Expand Down Expand Up @@ -195,17 +166,12 @@ if [[ "${RAPIDS_CUDA_VERSION}" == "11.8.0" ]]; then
rapids-print-env

rapids-logger "pytest cugraph_dgl (single GPU)"
pushd python/cugraph-dgl/tests
pytest \
--cache-clear \
--ignore=mg \
./ci/run_cugraph_dgl_pytests.sh \
--junitxml="${RAPIDS_TESTS_DIR}/junit-cugraph-dgl.xml" \
--cov-config=../../.coveragerc \
--cov=cugraph_dgl \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cugraph-dgl-coverage.xml" \
--cov-report=term \
.
popd
--cov-report=term

# Reactivate the test environment back
set +u
Expand Down Expand Up @@ -252,18 +218,13 @@ if [[ "${RAPIDS_CUDA_VERSION}" == "11.8.0" ]]; then
rapids-print-env

rapids-logger "pytest cugraph_pyg (single GPU)"
pushd python/cugraph-pyg/cugraph_pyg
# rmat is not tested because of multi-GPU testing
pytest \
--cache-clear \
--ignore=tests/mg \
./ci/run_cugraph_pyg_pytests.sh \
--junitxml="${RAPIDS_TESTS_DIR}/junit-cugraph-pyg.xml" \
--cov-config=../../.coveragerc \
--cov=cugraph_pyg \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cugraph-pyg-coverage.xml" \
--cov-report=term \
.
popd
--cov-report=term

# Reactivate the test environment back
set +u
Expand Down Expand Up @@ -296,16 +257,12 @@ if [[ "${RAPIDS_CUDA_VERSION}" == "11.8.0" ]]; then
rapids-print-env

rapids-logger "pytest cugraph-equivariant"
pushd python/cugraph-equivariant/cugraph_equivariant
pytest \
--cache-clear \
./ci/run_cugraph_equivariant_pytests.sh \
--junitxml="${RAPIDS_TESTS_DIR}/junit-cugraph-equivariant.xml" \
--cov-config=../../.coveragerc \
--cov=cugraph_equivariant \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cugraph-equivariant-coverage.xml" \
--cov-report=term \
.
popd
--cov-report=term

# Reactivate the test environment back
set +u
Expand Down

0 comments on commit fef6440

Please sign in to comment.